コード例 #1
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @throws \InvalidArgumentException
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     //Set up is ported from https://github.com/prooph/ProophEventStoreModule/blob/master/src/ProophEventStoreModule/Factory/EventStoreFactory.php
     $config = $serviceLocator->get("configuration");
     if (!isset($config['prooph.event_store'])) {
         throw new \InvalidArgumentException("Missing key prooph.event_store in application configuration");
     }
     $config = $config['prooph.event_store'];
     if (!isset($config['adapter'])) {
         throw new \InvalidArgumentException("Missing adapter configuration in prooph.event_store configuration");
     }
     $adapterType = isset($config['adapter']["type"]) ? $config['adapter']["type"] : 'Prooph\\EventStore\\Adapter\\InMemoryAdapter';
     $adapterOptions = isset($config['adapter']["options"]) ? $config['adapter']["options"] : [];
     if ($adapterType == 'Prooph\\EventStore\\Adapter\\Zf2\\Zf2EventStoreAdapter' && isset($adapterOptions['zend_db_adapter']) && is_string($adapterOptions['zend_db_adapter'])) {
         $config['adapter']['options']['zend_db_adapter'] = $serviceLocator->get($adapterOptions['zend_db_adapter']);
     }
     $featureManagerConfig = null;
     if (isset($config['feature_manager'])) {
         $featureManagerConfig = new Config($config['feature_manager']);
         unset($config['feature_manager']);
     }
     $esConfiguration = new Configuration($config);
     $featureManager = new ZF2FeatureManager($featureManagerConfig);
     $featureManager->setServiceLocator($serviceLocator);
     $esConfiguration->setFeatureManager(Zf2ServiceManagerProxy::proxy($featureManager));
     return new EventStore($esConfiguration);
 }
コード例 #2
0
ファイル: TestCase.php プロジェクト: prooph/processing
 /**
  * @return EventStore
  */
 protected function getOtherMachineEventStore()
 {
     if (is_null($this->otherMachineEventStore)) {
         $inMemoryAdapter = new InMemoryAdapter();
         $config = new Configuration();
         $config->setAdapter($inMemoryAdapter);
         $this->otherMachineEventStore = new EventStore($config);
         $this->otherMachineEventStore->getActionEventDispatcher()->attachListener("commit.post", function (PostCommitEvent $postCommitEvent) {
             $this->otherMachineLastPostCommitEvent = $postCommitEvent;
             foreach ($postCommitEvent->getRecordedEvents() as $event) {
                 $this->otherMachineEventNameLog[] = $event->messageName();
             }
         });
         $this->otherMachineEventStore->beginTransaction();
         $this->otherMachineEventStore->create(new Stream(new StreamName('prooph_processing_stream'), []));
         $this->otherMachineEventStore->commit();
     }
     return $this->otherMachineEventStore;
 }