Lifecycle callbacks on embeddables, possible or not? #5788

Closed
opened 2026-01-22 15:17:54 +01:00 by admin · 4 comments
Owner

Originally created by @holtkamp on GitHub (Nov 28, 2017).

Originally assigned to: @holtkamp on GitHub.

Encountered behaviour where embeddables seem not to respect lifecycle callbacks, but do "listen" to a given configuration, as also described here.

The documentation does not mention embeddables, so I suppose it is not supported. If so: might be good to document this more explicitly?

The strange thing: when defining a lifecycle callback that points to a non-existing function: an exception is thrown, so the definition is respected.

Originally created by @holtkamp on GitHub (Nov 28, 2017). Originally assigned to: @holtkamp on GitHub. Encountered behaviour where embeddables seem not to respect lifecycle callbacks, but do "listen" to a given configuration, as also [described here](https://groups.google.com/forum/#!topic/doctrine-user/g2_vurFHEMM). The [documentation](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#lifecycle-callbacks) does not mention embeddables, so I suppose it is not supported. If so: might be good to document this more explicitly? The strange thing: when defining a lifecycle callback that points to a non-existing function: an exception is thrown, so the definition *is* respected.
admin added the DocumentationDeprecation labels 2026-01-22 15:17:54 +01:00
admin closed this issue 2026-01-22 15:17:54 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 28, 2017):

Not possible: an embeddable has no lifecycle on its own. The lifecycle is
the one of the entity.

On 28 Nov 2017 18:15, "Menno Holtkamp" notifications@github.com wrote:

Encountered behaviour where embeddables seem not to respect lifecycle
callbacks, but do respect when the configuration, as also described here
https://groups.google.com/forum/#!topic/doctrine-user/g2_vurFHEMM.

The documentation
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#lifecycle-callbacks
does not mention embeddables, so I suppose it is not supported. If so:
might be good to document this more explicitly?

The strange thing: when defining a lifecycle callback that points to a
non-existing function: an exception is thrown, so the definition is
respected.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6855, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakFYKpEWWtDx-Kax0ZuK9kBFhBxaZks5s7D-3gaJpZM4QtmI3
.

@Ocramius commented on GitHub (Nov 28, 2017): Not possible: an embeddable has no lifecycle on its own. The lifecycle is the one of the entity. On 28 Nov 2017 18:15, "Menno Holtkamp" <notifications@github.com> wrote: > Encountered behaviour where embeddables seem not to respect lifecycle > callbacks, but do respect when the configuration, as also described here > <https://groups.google.com/forum/#!topic/doctrine-user/g2_vurFHEMM>. > > The documentation > <http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#lifecycle-callbacks> > does not mention embeddables, so I suppose it is not supported. If so: > might be good to document this more explicitly? > > The strange thing: when defining a lifecycle callback that points to a > non-existing function: an exception is thrown, so the definition *is* > respected. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/6855>, or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakFYKpEWWtDx-Kax0ZuK9kBFhBxaZks5s7D-3gaJpZM4QtmI3> > . >
Author
Owner

@holtkamp commented on GitHub (Nov 28, 2017):

Wow, < 1 minute response time, raspact!

Should I submit a PR for the documentation on the Entity LifeCycle to explicitly indicate this will not work for embeddables? Or... is that too much 😉 . Maybe others have the same "use case".

@holtkamp commented on GitHub (Nov 28, 2017): Wow, < 1 minute response time, raspact! Should I submit a PR for the documentation on the Entity LifeCycle to explicitly indicate this will not work for embeddables? Or... is that too much 😉 . Maybe others have the same "use case".
Author
Owner

@Ocramius commented on GitHub (Nov 28, 2017):

Sending a PR to the docs would be fab!

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On Tue, Nov 28, 2017 at 6:18 PM, Menno Holtkamp notifications@github.com
wrote:

Wow, < 1 minute response time, raspact!

Should I submit a PR for the documentation on the Entity LifeCycle to
explicitly indicated this will not work for embeddables? Or... is that too
much ;). Maybe others have the same "use case".


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6855#issuecomment-347596420,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakM8rG7gIuc_pY6EsI_Ti8igNA0etks5s7EBugaJpZM4QtmI3
.

@Ocramius commented on GitHub (Nov 28, 2017): Sending a PR to the docs would be fab! Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Tue, Nov 28, 2017 at 6:18 PM, Menno Holtkamp <notifications@github.com> wrote: > Wow, < 1 minute response time, raspact! > > Should I submit a PR for the documentation on the Entity LifeCycle to > explicitly indicated this will not work for embeddables? Or... is that too > much ;). Maybe others have the same "use case". > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/6855#issuecomment-347596420>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakM8rG7gIuc_pY6EsI_Ti8igNA0etks5s7EBugaJpZM4QtmI3> > . >
Author
Owner

@holtkamp commented on GitHub (May 18, 2018):

This behaviour is also discussed in https://github.com/doctrine/doctrine2/issues/4568, and can maybe be covered using https://packagist.org/packages/tarifhaus/doctrine-nullable-embeddable

@holtkamp commented on GitHub (May 18, 2018): This behaviour is also discussed in https://github.com/doctrine/doctrine2/issues/4568, and can maybe be covered using https://packagist.org/packages/tarifhaus/doctrine-nullable-embeddable
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5788