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

[DoctrineBridge] update doctrine event listeners doc for Symfony 4.2 change #9973

Merged
merged 4 commits into from
Jun 29, 2018

Conversation

dmaicher
Copy link
Contributor

See symfony/symfony#27675.

Doctrine entity listeners are always lazily instantiated as of Symfony 4.2.

@dmaicher dmaicher changed the title Update event_listeners_subscribers.rst [DoctrineBridge] update doctrine event listeners doc for Symfony 4.2 change Jun 27, 2018
symfony-splitter pushed a commit to symfony/doctrine-bridge that referenced this pull request Jun 28, 2018
…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
fabpot added a commit to symfony/symfony that referenced this pull request Jun 28, 2018
…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
@HeahDude HeahDude added this to the 4.2 milestone Jun 28, 2018
Copy link
Contributor

@HeahDude HeahDude left a 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.
Copy link
Contributor

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
Copy link
Contributor Author

@dmaicher dmaicher Jun 28, 2018

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 😊

Copy link
Contributor Author

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 👍

Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Contributor Author

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 😄

@javiereguiluz
Copy link
Member

Thanks David.

@javiereguiluz javiereguiluz merged commit 4409fd6 into symfony:master Jun 29, 2018
javiereguiluz added a commit that referenced this pull request Jun 29, 2018
…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
@dmaicher dmaicher deleted the patch-5 branch June 29, 2018 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants