/** * 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); }
/** * @test */ public function doesNotHaveIncomingEvent() { $pipeline = new Pipeline("wizbii_profile"); $pipeline->addIncomingEvent(new Event("first_name_updated")); $this->assertThat($pipeline->hasIncomingEvent("new_friend"), $this->isFalse()); }