Пример #1
0
 /**
  * @test
  */
 public function storeIsNotRunnable()
 {
     // init container
     $container = new Container();
     $this->actionDispatcher->container = $container;
     // init pipeline
     $action = new Action("profile_created");
     $store = new Store("profile_network");
     $store->setService("pipeline.store.profile.dashboard");
     $store->addTriggeredByAction($action);
     $pipeline = new Pipeline();
     $pipeline->addStore($store);
     $this->actionDispatcher->pipelineProvider->setPipeline($pipeline);
     // dispatch action
     $returnedValue = $this->actionDispatcher->dispatch($action);
     $this->assertThat($returnedValue, $this->isFalse());
 }
Пример #2
0
 /**
  * @test
  * @expectedException \Wizbii\PipelineBundle\Exception\CircularPipelineException
  */
 public function circularReferencesThrowsException()
 {
     $pipeline = new Pipeline("wizbii_profile");
     $profileIdentityCardStore = new Store("profile_identity_card");
     $profileNetworkStore = new Store("profile_network");
     $profileThanxStore = new Store("profile_thanx");
     $profileIdentityCardStore->addTriggeredByStore($profileNetworkStore);
     $profileNetworkStore->addTriggeredByStore($profileThanxStore);
     $profileThanxStore->addTriggeredByStore($profileIdentityCardStore);
     $pipeline->addStore($profileIdentityCardStore);
     $pipeline->addStore($profileNetworkStore);
     $pipeline->addStore($profileThanxStore);
     $pipeline->checkForCircularReferences();
 }
Пример #3
0
 /**
  * @param Pipeline $pipeline
  * @param string $storeName
  * @param array $storeConfiguration
  * @throws InvalidConfigurationException
  */
 public function buildStore($pipeline, $storeName, $storeConfiguration = [])
 {
     $triggeredByActions = is_array($storeConfiguration) && array_key_exists("triggered_by_actions", $storeConfiguration) ? $storeConfiguration["triggered_by_actions"] : [];
     $triggeredByStores = is_array($storeConfiguration) && array_key_exists("triggered_by_stores", $storeConfiguration) ? $storeConfiguration["triggered_by_stores"] : [];
     $triggeredEvent = is_array($storeConfiguration) && array_key_exists("triggered_event", $storeConfiguration) ? $storeConfiguration["triggered_event"] : null;
     $service = is_array($storeConfiguration) && array_key_exists("service", $storeConfiguration) ? $storeConfiguration["service"] : null;
     $store = $pipeline->hasStore($storeName) ? $pipeline->getStore($storeName) : new Store($storeName);
     $store->setService($service);
     foreach ($triggeredByActions as $triggeredByAction) {
         if (!$pipeline->hasAction($triggeredByAction)) {
             throw new InvalidConfigurationException("Store {$storeName} depends on an unknown action : {$triggeredByAction}");
         }
         $store->addTriggeredByAction($pipeline->getAction($triggeredByAction));
     }
     foreach ($triggeredByStores as $storeName) {
         $triggeredByStore = new Store($storeName);
         if ($pipeline->hasStore($storeName)) {
             $triggeredByStore = $pipeline->getStore($storeName);
         }
         $store->addTriggeredByStore($triggeredByStore);
     }
     // check that store is triggered by an action or another store.
     if ($store->isNeverTriggered()) {
         throw new InvalidConfigurationException("Store {$storeName} is never triggered");
     }
     // add triggered event
     if (isset($triggeredEvent)) {
         $event = $pipeline->hasOutgoingEvent($triggeredEvent) ? $pipeline->getOutgoingEvent($triggeredEvent) : new Event($triggeredEvent);
         $store->setTriggeredEvent($event);
         $pipeline->addOutgoingEvent($event);
     }
     $pipeline->addStore($store);
 }