Пример #1
0
 /**
  * @param EventInterface $eventModel
  * @param string $commandService
  */
 public function initEventAndSave(EventInterface $eventModel, string $commandService)
 {
     $event = new Event();
     $event->setEventName($eventModel->getName())->setFrequency($eventModel->getFrequency());
     if (!$this->container->get($commandService) instanceof EventCommandInterface) {
         throw new \RuntimeException("service {$commandService} is not EventCommandInterface instance");
     }
     $event->setEventModel($eventModel)->setEventCommandService($commandService);
     try {
         $this->initNextRun($event);
         $this->saveEvent($event);
     } catch (EventFrequencyEmptyException $e) {
         $this->saveEvent($event);
     }
 }