prooph / event-store-symfony-bundle

Event Store Symfony Bundle
http://getprooph.org/
BSD 3-Clause "New" or "Revised" License
109 stars 39 forks source link

Prevent autowiring to malfunction while defining aggregate repositories #50

Closed gquemener closed 3 years ago

gquemener commented 6 years ago

The "problem"

Today, there are two ways to define aggregate repositories using this bundle:

 prooph_event_store:
     stores:
         user_store:
             event_store: 'app.event_store.default'
             repositories:
                 user_collection:
                     repository_class: App\Infrastructure\User\Repository\EventStoreUserCollection

and

 prooph_event_store:
     stores:
         user_store:
             event_store: 'app.event_store.default'
             repositories:
                 App\Infrastructure\User\Repository\EventStoreUserCollection: ~

The later has the huge benefit of allowing autowiring to work out of the box.

As a matter of fact, the repositories key will be used as the service id and this is not obvious from a developer perspective.

The result will be that developers will get an error stating than the EventStoreUserCollection argument cannot be autowired when using the first form.

It is still doable though, through a service alias:

services:
    App\Infrastructure\User\Repository\EventStoreUserCollection: '@user_collection`

The suggestion

Remove the first form, aka force the repository service id to be a FQCN, thus making the autowiring always work.

The source

The issue appeared to me while reviewing this PR

unixslayer commented 3 years ago

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