Пример #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);
 }
Пример #2
0
 /**
  * @test
  */
 public function doesNotHaveActionCreator()
 {
     $pipeline = new Pipeline("wizbii_profile");
     $pipeline->addActionCreator(new ActionCreator(new Action("first_name_updated")));
     $this->assertThat($pipeline->hasActionCreatorFor("new_friend"), $this->isFalse());
 }