prooph / event-store-symfony-bundle

Event Store Symfony Bundle

Home Page:http://getprooph.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configure repositories using tags

UFOMelkor opened this issue · comments

Currently projections and plugins can be configured using tags and in the service bus bundle plugins and routing can be done using tags.

Just aggregate repositories cannot be configured using tags.

Hi!
It looks like an easy pick, but I don't get what should be configured here.

Repository definition looks pretty straightforward, so what should be handled there? Aliasing?

@kejwmen It's about the ability to mark a service as a repository using a tag (probably with some metadata) instead of explicitly listing it in the bundle configuration. When that's the case services can be found and configured automatically using compiler passes meaning no explicit configuration for each repository.

I got this, but everything you can set using bundle configuration (service references, parameters) is already configurable when you create your own service definition because of prooph_event_store.repository_factory.

That's how repo definition created in extension looks currently:

$repositoryDefinition = $container
	->setDefinition(
        $repositoryName,
        new DefinitionDecorator('prooph_event_store.repository_definition')
	)
    ->setFactory([new Reference('prooph_event_store.repository_factory'), 'create'])
    ->setArguments(
        [
            $repositoryClass,
            new Reference($eventStoreId),
            $repositoryConfig['aggregate_type'],
            new Reference($repositoryConfig['aggregate_translator']),
            $repositoryConfig['snapshot_store'] ? new Reference($repositoryConfig['snapshot_store']) : null,
            $repositoryConfig['stream_name'],
            $repositoryConfig['one_stream_per_aggregate'],
        ]
);

Factory is also straightforward:

    public function create(
        string $repositoryClass,
        EventStore $eventStore,
        string $aggregateType,
        AggregateTranslator $aggregateTranslator,
        SnapshotStore $snapshotStore = null,
        string $streamName = null,
        bool $oneStreamPerAggregate = false
    ) {
        return new $repositoryClass(
            $eventStore,
            AggregateType::fromAggregateRootClass($aggregateType),
            $aggregateTranslator,
            $snapshotStore,
            $streamName ? new StreamName($streamName) : null,
            $oneStreamPerAggregate
        );
    }

If I understand it correctly there is nothing that could be done here automatically when you want to configure service by yourself because this is the only thing that is created by bundle.

Starting from 0.9.x, this bundle no longer handle repositories