Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oro 6.0.x compatibility added #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Command/SendSmsCampaignsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
/**
* Command to send scheduled SMS campaigns
*/
#[\Symfony\Component\Console\Attribute\AsCommand('oro:cron:send-sms-campaigns', 'Send SMS campaigns')]
class SendSmsCampaignsCommand extends Command implements CronCommandScheduleDefinitionInterface
{
/** @var string */
protected static $defaultName = 'oro:cron:send-sms-campaigns';

/** @var ManagerRegistry */
private $registry;

Expand Down Expand Up @@ -82,20 +80,20 @@ protected function getSmsCampaignRepository()
/**
* {@inheritdoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
if (!$this->featureChecker->isFeatureEnabled('campaign')) {
$output->writeln('The campaign feature is disabled. The command will not run.');

return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}

$smsCampaigns = $this->getSmsCampaignRepository()->findSmsCampaignsToSend();

if (!$smsCampaigns) {
$output->writeln('<info>No SMS campaigns to send</info>');

return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}

$output->writeln(
Expand All @@ -105,7 +103,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->send($output, $smsCampaigns);
$output->writeln(sprintf('<info>Finished SMS campaigns sending</info>'));

return 0;
return \Symfony\Component\Console\Command\Command::SUCCESS;
}

/**
Expand All @@ -129,7 +127,5 @@ protected function send($output, array $smsCampaigns)
*/
protected function configure()
{
$this
->setDescription('Send SMS campaigns');
}
}
67 changes: 19 additions & 48 deletions Controller/SmsCampaignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use Diglin\Bundle\SmsCampaignBundle\Form\Type\SmsCampaignType;
use Diglin\Bundle\SmsCampaignBundle\Model\SmsCampaignSenderBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Oro\Bundle\SecurityBundle\Annotation\Acl;
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
use Oro\Bundle\SecurityBundle\Attribute\Acl;
use Oro\Bundle\SecurityBundle\Attribute\AclAncestor;
use Oro\Bundle\UIBundle\Route\Router;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand All @@ -24,15 +24,14 @@
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Serve CRUD of SmsCampaign entity.
*
* @Route("/campaign/sms")
*/
#[\Symfony\Component\Routing\Attribute\Route(path: '/campaign/sms')]
class SmsCampaignController extends AbstractController
{
private FormFactoryInterface $formFactory;
Expand Down Expand Up @@ -70,7 +69,7 @@ public function setValidator(ValidatorInterface $validator): void
/**
* {@inheritdoc}
*/
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return array_merge(
parent::getSubscribedServices(),
Expand All @@ -86,11 +85,9 @@ public static function getSubscribedServices()
);
}

/**
* @Route("/", name="diglin_sms_campaign_index")
* @AclAncestor("diglin_sms_campaign_view")
* @Template
*/
#[\Symfony\Component\Routing\Attribute\Route(path: '/', name: 'diglin_sms_campaign_index')]
#[AclAncestor('diglin_sms_campaign_view')]
#[Template]
public function indexAction()
{
return [
Expand All @@ -100,16 +97,10 @@ public function indexAction()

/**
* Create SMS campaign
*
* @Route("/create", name="diglin_sms_campaign_create")
* @Template("@SmsCampaign/SmsCampaign/update.html.twig")
* @Acl(
* id="diglin_sms_campaign_create",
* type="entity",
* permission="CREATE",
* class="SmsCampaignBundle:SmsCampaign"
* )
*/
#[\Symfony\Component\Routing\Attribute\Route(path: '/create', name: 'diglin_sms_campaign_create')]
#[Template('@SmsCampaign/SmsCampaign/update.html.twig')]
#[Acl(id: 'diglin_sms_campaign_create', type: 'entity', permission: 'CREATE', class: 'SmsCampaignBundle:SmsCampaign')]
public function createAction()
{
return $this->update(new SmsCampaign());
Expand Down Expand Up @@ -154,19 +145,13 @@ protected function update(SmsCampaign $entity)
/**
* Edit SMS campaign
*
* @Route("/update/{id}", name="diglin_sms_campaign_update", requirements={"id"="\d+"}, defaults={"id"=0})
* @Template
* @Acl(
* id="diglin_sms_campaign_update",
* type="entity",
* permission="EDIT",
* class="SmsCampaignBundle:SmsCampaign"
* )
*
* @param SmsCampaign $entity
*
* @return array
*/
#[\Symfony\Component\Routing\Attribute\Route(path: '/update/{id}', name: 'diglin_sms_campaign_update', requirements: ['id' => '\d+'], defaults: ['id' => 0])]
#[Template]
#[Acl(id: 'diglin_sms_campaign_update', type: 'entity', permission: 'EDIT', class: 'SmsCampaignBundle:SmsCampaign')]
public function updateAction(SmsCampaign $entity)
{
return $this->update($entity);
Expand All @@ -175,19 +160,13 @@ public function updateAction(SmsCampaign $entity)
/**
* View SMS campaign
*
* @Route("/view/{id}", name="diglin_sms_campaign_view", requirements={"id"="\d+"})
* @Acl(
* id="diglin_sms_campaign_view",
* type="entity",
* permission="VIEW",
* class="SmsCampaignBundle:SmsCampaign"
* )
* @Template
*
* @param SmsCampaign $entity
*
* @return array
*/
#[\Symfony\Component\Routing\Attribute\Route(path: '/view/{id}', name: 'diglin_sms_campaign_view', requirements: ['id' => '\d+'])]
#[Acl(id: 'diglin_sms_campaign_view', type: 'entity', permission: 'VIEW', class: 'SmsCampaignBundle:SmsCampaign')]
#[Template]
public function viewAction(SmsCampaign $entity)
{
$stats = $this->managerRegistry
Expand Down Expand Up @@ -226,20 +205,12 @@ protected function isManualSendAllowed(SmsCampaign $entity)
}

/**
* @Route("/send/{id}", name="diglin_sms_campaign_send", requirements={"id"="\d+"})
* @Acl(
* id="diglin_sms_campaign_send",
* type="action",
* label="oro.campaign.acl.send_emails.label",
* description="oro.campaign.acl.send_emails.description",
* group_name="",
* category="marketing"
* )
*
* @param SmsCampaign $entity
*
* @return RedirectResponse
*/
#[\Symfony\Component\Routing\Attribute\Route(path: '/send/{id}', name: 'diglin_sms_campaign_send', requirements: ['id' => '\d+'])]
#[Acl(id: 'diglin_sms_campaign_send', type: 'action', label: 'oro.campaign.acl.send_emails.label', description: 'oro.campaign.acl.send_emails.description', group_name: '', category: 'marketing')]
public function sendAction(SmsCampaign $entity)
{
if ($this->isManualSendAllowed($entity)) {
Expand Down
Loading