Browse files

Update docs/en/reference/events.rst

Docs for lifecycle-callback event arg
  • Loading branch information...
1 parent 7177306 commit 76c4be1b7483dadd98ff5495e5cdf1337378bc65 @FabioBatSilva committed Jan 29, 2013
Showing with 24 additions and 0 deletions.
  1. +24 −0 docs/en/reference/events.rst
View
24 docs/en/reference/events.rst
@@ -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
-----------------------------

0 comments on commit 76c4be1

Please sign in to comment.