1
0
mirror of synced 2025-03-22 16:03:49 +03:00

Update docs/en/reference/events.rst

Docs for lifecycle-callback event arg
This commit is contained in:
Fabio B. Silva 2013-01-29 12:19:47 -02:00
parent 7177306536
commit 76c4be1b74

View File

@ -336,6 +336,30 @@ The ``key`` of the lifecycleCallbacks is the name of the method and
the value is the event type. The allowed event types are the ones
listed in the previous Lifecycle Events section.
.. versionadded:: 2.4
Lifecycle Callbacks Event Argument
-----------------------------------
Since 2.4 the triggered event is given to the lifecycle-callback.
With the additional argument you have access to the
``EntityManager`` and ``UnitOfWork`` APIs inside these callback methods.
.. code-block:: php
<?php
// ...
class User
{
public function preUpdate(PreUpdateEventArgs $event)
{
if ($event->hasChangedField('username')) {
// Do something when the username is changed.
}
}
}
Listening to Lifecycle Events
-----------------------------