Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function process(ActionInterface $action, ActionDefinitionInterface $definition)
 {
     $event = new ActionEvent($action);
     $eventName = $definition->getEventName();
     if (null == $eventName) {
         $eventName = 'v.action.' . $action->getName() . '.execute';
     }
     if (!$this->eventDispatcher->hasListeners($eventName)) {
         throw new \RuntimeException('No listener configured for action execution ' . $eventName);
     }
     $this->eventDispatcher->dispatch($eventName, $event);
 }
Exemplo n.º 2
0
 /**
  * Start the execution of an action or schedule the action for processing later on
  *
  * @param ActionInterface $action
  * @param bool $reprocess
  */
 protected function doExecute(ActionInterface $action, $reprocess = false)
 {
     // The first question is, are we even allowed to reprocess this action?
     $definition = $this->findActionDefinitionByName($action->getName());
     if (null == $definition) {
         throw new \RuntimeException(sprintf('Could not load action definition for action %a', $action->getName()));
     }
     $handler = $this->handlers[$definition->getHandlerClass()];
     if ($reprocess) {
         // Delegate to the action handler to see if the action is reprocessable
         $isReprocessable = $handler->isReprocessable($action, $definition);
         if (false == $isReprocessable) {
             throw new \RuntimeException(sprintf('Reprocessing is not allowed for action %a', $action->getName()));
         }
     }
     // Cool, we can process the action!
     $handler->process($action, $definition);
     // Save the state of the action
     $this->actionGateway->updateAction($action);
 }