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

Repository autowiring doesn't work #65

Closed siwymilek closed 3 years ago

siwymilek commented 5 years ago

I can't autowire repositories – is this an issue or deliberate action? Here is my event store configuration:

prooph_event_store:
    stores:
        user_store:
            event_store: 'prooph_event_store.pdo_mysql_event_store'
            repositories:
                App\Infrastructure\User\Repository\EventStoreUserRepository:
                    aggregate_type: App\Domain\User\Model\User
                    aggregate_translator: 'prooph_event_sourcing.aggregate_translator'

And here is the error:

Cannot autowire service "App\Infrastructure\User\Repository\EventStoreUserRepository": argument "$aggregateType" of method "Prooph\EventSourcing\Aggregate\AggregateRepository::__construct()" references class "Prooph\EventSourcing\Aggregate\AggregateType" but no such service exists.

RSalo commented 4 years ago

I have the same problem.

superbull commented 4 years ago

@siwymilek @RSalo I come across the same problem. It takes me 1 day to fix.

Change your config to something like below will work. Assume your Repository interface is App\Domain\Model\User\UserRepository, change it to what ever you type hinted.

prooph_event_store:
    stores:
        user_store:
            event_store: 'prooph_event_store.pdo_mysql_event_store'
            repositories:
                user_repository:
                    repository_class: App\Infrastructure\User\Repository\EventStoreUserRepository
                    aggregate_type: App\Domain\User\Model\User
                    aggregate_translator: 'prooph_event_sourcing.aggregate_translator'

services:
    # change below to your type hinted type
    App\Domain\Model\User\UserRepository: '@user_repository'
unixslayer commented 3 years ago

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