Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Registering the entity listener on the entity is still required #1548

Closed
stollr opened this issue Jul 13, 2022 · 3 comments
Closed

[doc] Registering the entity listener on the entity is still required #1548

stollr opened this issue Jul 13, 2022 · 3 comments

Comments

@stollr
Copy link
Contributor

stollr commented Jul 13, 2022

In the documentation it's said that

Starting with doctrine/orm 2.5 and Doctrine bundle 1.5.2, instead of registering the entity listener on the entity, you can declare all options from the service definition

I have installed doctrine/orm 2.12.3 and Doctrine bundle 2.7.0. But in my case the following service definition was not sufficient to get the listener working:

services:
    AppBundle\EventListener\EntityListener\ReversalInvoiceListener:
        tags:
            - { name: doctrine.orm.entity_listener, entity: AppBundle\Entity\Accounting\ReversalInvoice, lazy: true }

I had to add @ORM\EntityListeners({"AppBundle\EventListener\EntityListener\ReversalInvoiceListener"}) to the entity. Or is there anything else missing on my definition?

Without the annotation in the entity, the $metadata->entityListeners array was empty, so that ListenersInvoker::getSubscribedSystems returned 4 instead of 5, which means that the bit for the listener invokation was missing.

So either the documentation is not clear or there is a bug in the code.

@ostrolucky
Copy link
Member

You didn't specify event in your tag, so you didn't follow example in documentation closely enough.

@stollr
Copy link
Contributor Author

stollr commented Jul 14, 2022

Okay, it wasn't clear to me, that the event attribute is required.

@stollr
Copy link
Contributor Author

stollr commented Jul 14, 2022

I have created a tiny PR to add a sentence to make this more clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants