['updateCommandTaskNextExecution', EventPriorities::POST_WRITE], ]; } /** * @throws \Exception */ public function updateCommandTaskNextExecution(ViewEvent $event): void { $commandTaskScheduleOutput = $event->getControllerResult(); $method = $event->getRequest()->getMethod(); if (!$commandTaskScheduleOutput instanceof CommandTaskScheduleOutput || !in_array($method, [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE])) { return; } /** @var CommandTaskSchedule $commandTaskSchedule */ $commandTaskSchedule = $commandTaskScheduleOutput->getEntity(); $commandTask = $commandTaskSchedule->getCommandTask(); if ($commandTask === null) { return; } $commandTask->setNextExecution($commandTask->calculateNextExecutionDate()); $this->entityManager->persist($commandTask); $this->entityManager->flush(); } }