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