-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[DoctrineBridge] update doctrine event listeners doc for Symfony 4.2 change #9973
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
Conversation
…ServiceLocator (dmaicher) This PR was squashed before being merged into the 4.2-dev branch (closes #27675). Discussion ---------- [DoctrineBridge] always load event listeners lazy via ServiceLocator | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes/no | Tests pass? | yes | Fixed tickets | symfony/symfony#27661 | License | MIT | Doc PR | symfony/symfony-docs#9973 As described in symfony/symfony#27661 this PR suggests to always load doctrine event listeners lazily from a service locator instead of the full service container. If we agree to move forward I could tackle the remaining todos: - [x] update UPGRADE.md - [x] documentation PR - [x] tested on real app Commits ------- 130ec0525d [DoctrineBridge] always load event listeners lazy via ServiceLocator
…ServiceLocator (dmaicher) This PR was squashed before being merged into the 4.2-dev branch (closes #27675). Discussion ---------- [DoctrineBridge] always load event listeners lazy via ServiceLocator | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes/no | Tests pass? | yes | Fixed tickets | #27661 | License | MIT | Doc PR | symfony/symfony-docs#9973 As described in #27661 this PR suggests to always load doctrine event listeners lazily from a service locator instead of the full service container. If we agree to move forward I could tackle the remaining todos: - [x] update UPGRADE.md - [x] documentation PR - [x] tested on real app Commits ------- 130ec05 [DoctrineBridge] always load event listeners lazy via ServiceLocator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your work on this.
|
||
.. _`The Event System`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html | ||
.. _`the Doctrine Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#entity-listeners | ||
So whenever possible it is preferable to use entity listeners instead of subscribers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm we might need another PR in core before merging such thing x).
whenever possible. | ||
|
||
.. versionadded:: 4.2 | ||
The default lazy behavior of Doctrine entity listeners was introduced in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically this is not correct. It was possible even before Symfony 4.2 but you had to manually add a 😊lazy=true
attribute for the tag. Now since 4.2 it will be always lazy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry I missed the "default" while reading it. All good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that phrase I tried to say: "in 4.2 the new thing is that is lazy by default". But it looks like I failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmaicher in 4.2 they are lazy by default ... or are they mandatory lazy? In other words, can you say lazy:false
in 4.2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No they are always lazy now. So mandatory.
@@ -198,4 +198,5 @@ That's why it is preferable to use entity listeners instead of subscribers | |||
whenever possible. | |||
|
|||
.. versionadded:: 4.2 | |||
Starting from Symfony 4.2, Doctrine entity listeners are lazy by default. | |||
Starting from Symfony 4.2, Doctrine entity listeners are always lazy. In |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now its more clear 👍 Thanks 😄
Thanks David. |
…Symfony 4.2 change (dmaicher, javiereguiluz) This PR was merged into the master branch. Discussion ---------- [DoctrineBridge] update doctrine event listeners doc for Symfony 4.2 change See symfony/symfony#27675. Doctrine entity listeners are always lazily instantiated as of Symfony 4.2. Commits ------- 4409fd6 Explain that lazy listeners are mandatory, not default b56ef9e Update event_listeners_subscribers.rst d8bb849 Reworded and added the versionadded directive 601450e Update event_listeners_subscribers.rst
See symfony/symfony#27675.
Doctrine entity listeners are always lazily instantiated as of Symfony 4.2.