maks-rafalko / tactician-domain-events-bundle

Bundle to integrate Tactician Domain Events library with Symfony project
https://maks-rafalko.github.io/tactician-domain-events-bundle/
MIT License
10 stars 9 forks source link

Service or alias has been removed or inlined when the container was compiled #13

Open tmcnicholls opened 5 years ago

tmcnicholls commented 5 years ago

Hi,

I'm using this bundle in a Symfony 4 app and am getting the following warning when clearing cache etc:

The "App\Application\EventListener\User\PasswordResetRequestedListener" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

My event listener is wired up in services.yaml as follows:

App\Application\EventListener\User\PasswordResetRequestedListener:
    class: App\Application\EventListener\User\PasswordResetRequestedListener
    tags:
        - { name: tactician.event_listener, event: App\Domain\Events\PasswordResetRequested }

My Tactician config is as follows:

tactician:
    commandbus:
        default:
            middleware:
                - tactician_domain_events.middleware.release_recorded_events
                - tactician.middleware.locking
                - tactician.middleware.doctrine
                - tactician.middleware.command_handler

tactician_domain_event:
    collect_from_all_managed_entities: true

I've done some searching and it seems to be related to Symfony 4 making services private by default. I don't want to override this for every event listener. Am I missing something in the config?

Thanks

kermorgant commented 5 years ago

I'm in the process of upgrading a project towards sf4 and hit the same error.

My services were previously private by default but I made my subscribers implement an interface and made them public via this

    _instanceof:
        App\EventListener\DomainEventSubscriberInterface:
            public: true
            tags:
                - { name: tactician.event_subscriber }

But now, this does not seem to have the appropriate effect at the right moment. It could also very well be something else happening during this migration.

maks-rafalko commented 5 years ago

did you find a solutin @tmcnicholls ?

tmcnicholls commented 5 years ago

@borNfreee not yet, other than making the listeners explicitly public as a temporary measure like the below:

App\Application\EventListener\User\PasswordResetRequestedListener:
    public: true
    tags:
        - { name: tactician.event_listener, event: App\Domain\Events\PasswordResetRequested }

Do you have any other ideas?

Thanks