Exemplo n.º 1
0
 /**
  * Add actions inside Pipeline based on the configuration provided by Symfony Configuration
  * @param Pipeline $pipeline
  * @param string $actionName
  * @param array $actionConfiguration
  */
 public function buildAction($pipeline, $actionName, $actionConfiguration = [])
 {
     $triggeredByEvents = is_array($actionConfiguration) && array_key_exists("triggered_by_events", $actionConfiguration) ? $actionConfiguration["triggered_by_events"] : [];
     if (empty($triggeredByEvents)) {
         // default behavior : auto-wiring action to the same event name
         $triggeredByEvents = [$actionName];
     }
     // create the action and the action creator
     $action = new Action($actionName);
     $actionCreator = new ActionCreator($action);
     foreach ($triggeredByEvents as $triggeredByEvent) {
         $event = $pipeline->hasIncomingEvent($triggeredByEvent) ? $pipeline->getIncomingEvent($triggeredByEvent) : new Event($triggeredByEvent);
         $actionCreator->addTriggeredByEvent($event);
         $pipeline->addIncomingEvent($event);
     }
     $pipeline->addAction($action);
     $pipeline->addActionCreator($actionCreator);
 }
Exemplo n.º 2
0
 /**
  * @param ActionCreator $actionCreator
  */
 public function addActionCreator($actionCreator)
 {
     $this->actionCreators[$actionCreator->getCreatedAction()->getName()] = $actionCreator;
 }