diff --git a/src/ProcessManagerBundle/Maintenance/CronTask.php b/src/ProcessManagerBundle/Maintenance/CronTask.php index 2a63937..dcc5fcc 100644 --- a/src/ProcessManagerBundle/Maintenance/CronTask.php +++ b/src/ProcessManagerBundle/Maintenance/CronTask.php @@ -17,15 +17,19 @@ use Pimcore\Maintenance\TaskInterface; use CoreShop\Component\Registry\ServiceRegistry; use Cron\CronExpression; +use ProcessManagerBundle\Message\ProcessMessage; use ProcessManagerBundle\Model\Executable; +use Symfony\Component\Messenger\MessageBusInterface; class CronTask implements TaskInterface { private ServiceRegistry $registry; + private MessageBusInterface $messageBus; - public function __construct(ServiceRegistry $registry) + public function __construct(ServiceRegistry $registry, MessageBusInterface $messageBus) { $this->registry = $registry; + $this->messageBus = $messageBus; } public function execute() @@ -43,7 +47,8 @@ public function execute() if($cron->getPreviousRunDate() > $lastrun) { $executable->setLastrun($cron->getPreviousRunDate()->getTimestamp()); $executable->save(); - $this->registry->get($executable->getType())->run($executable); + + $this->messageBus->dispatch(new ProcessMessage($exe->getId())); } } } diff --git a/src/ProcessManagerBundle/Resources/config/services.yml b/src/ProcessManagerBundle/Resources/config/services.yml index ccf2d92..eda60fb 100644 --- a/src/ProcessManagerBundle/Resources/config/services.yml +++ b/src/ProcessManagerBundle/Resources/config/services.yml @@ -48,6 +48,7 @@ services: ProcessManagerBundle\Maintenance\CronTask: arguments: - '@process_manager.registry.processes' + - '@messenger.default_bus' tags: - { name: pimcore.maintenance.task, type: process_manager.maintenance.cron }