Spaces:
No application file
No application file
File size: 2,015 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
<?php
namespace Mautic\CampaignBundle\Command;
use Mautic\CampaignBundle\Executioner\ScheduledExecutioner;
use Mautic\CoreBundle\Twig\Helper\FormatterHelper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class ExecuteEventCommand extends Command
{
use WriteCountTrait;
public function __construct(
private ScheduledExecutioner $scheduledExecutioner,
private TranslatorInterface $translator,
private FormatterHelper $formatterHelper
) {
parent::__construct();
}
protected function configure()
{
$this
->setName('mautic:campaigns:execute')
->addOption(
'--scheduled-log-ids',
null,
InputOption::VALUE_REQUIRED,
'CSV of specific scheduled log IDs to execute.'
)
->addOption(
'--execution-time',
null,
InputOption::VALUE_REQUIRED,
'Scheduled execution time of event log'
);
parent::configure();
}
/**
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
defined('MAUTIC_CAMPAIGN_SYSTEM_TRIGGERED') or define('MAUTIC_CAMPAIGN_SYSTEM_TRIGGERED', 1);
$now = empty($input->getOption('execution-time')) ? null : new \DateTime($input->getOption('execution-time'));
$ids = $this->formatterHelper->simpleCsvToArray($input->getOption('scheduled-log-ids'), 'int');
$counter = $this->scheduledExecutioner->executeByIds($ids, $output, $now);
$this->writeCounts($output, $this->translator, $counter);
return Command::SUCCESS;
}
protected static $defaultDescription = 'Execute specific scheduled events.';
}
|