Prooph\EventStore\Metadata\MetadataEnricherPlugin::setUp PHP Метод

setUp() публичный Метод

public setUp ( EventStore $eventStore )
$eventStore Prooph\EventStore\EventStore
    public function setUp(EventStore $eventStore)
    {
        $eventEmitter = $eventStore->getActionEventEmitter();
        $eventEmitter->attachListener('create.pre', [$this, 'onEventStoreCreateStream'], -1000);
        $eventEmitter->attachListener('appendTo.pre', [$this, 'onEventStoreAppendToStream'], -1000);
    }

Usage Example

Пример #1
0
 /**
  * @param ContainerInterface $container
  * @return EventStore
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->get('config');
     $config = $this->options($config);
     $adapter = $container->get($config['adapter']['type']);
     if (!isset($config['event_emitter'])) {
         $eventEmitter = new ProophActionEventEmitter();
     } else {
         $eventEmitter = $container->get($config['event_emitter']);
     }
     $eventStore = new EventStore($adapter, $eventEmitter);
     foreach ($config['plugins'] as $pluginAlias) {
         $plugin = $container->get($pluginAlias);
         if (!$plugin instanceof Plugin) {
             throw ConfigurationException::configurationError(sprintf('Plugin %s does not implement the Plugin interface', $pluginAlias));
         }
         $plugin->setUp($eventStore);
     }
     if (count($config['metadata_enrichers']) > 0) {
         $metadataEnrichers = [];
         foreach ($config['metadata_enrichers'] as $metadataEnricherAlias) {
             $metadataEnricher = $container->get($metadataEnricherAlias);
             if (!$metadataEnricher instanceof MetadataEnricher) {
                 throw ConfigurationException::configurationError(sprintf('Metadata enricher %s does not implement the MetadataEnricher interface', $metadataEnricherAlias));
             }
             $metadataEnrichers[] = $metadataEnricher;
         }
         $plugin = new MetadataEnricherPlugin(new MetadataEnricherAggregate($metadataEnrichers));
         $plugin->setUp($eventStore);
     }
     return $eventStore;
 }