Updates based on feedback from Ocramius
Addresses all comments made so far, except the one about persists/updates
This commit is contained in:
parent
d5bc48623a
commit
c715d91dc7
@ -228,7 +228,8 @@ Lifecycle Callbacks
|
|||||||
Lifecycle Callbacks are defined on an entity class. They allow you to
|
Lifecycle Callbacks are defined on an entity class. They allow you to
|
||||||
trigger callbacks whenever an instance of that entity class experiences
|
trigger callbacks whenever an instance of that entity class experiences
|
||||||
a relevant lifecycle event. More than one callback can be defined for each
|
a relevant lifecycle event. More than one callback can be defined for each
|
||||||
lifecycle event.
|
lifecycle event. Lifecycle Callbacks are best used for simple operations
|
||||||
|
specific to a particular entity class's lifecycle.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
@ -278,8 +279,9 @@ lifecycle event.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Note that when using annotations you have to apply the
|
Note that the methods set as lifecycle callbacks need to be public and,
|
||||||
@HasLifecycleCallbacks marker annotation on the entity class.
|
when using these annotations, you have to apply the
|
||||||
|
``@HasLifecycleCallbacks`` marker annotation on the entity class.
|
||||||
|
|
||||||
If you want to register lifecycle callbacks from YAML or XML you
|
If you want to register lifecycle callbacks from YAML or XML you
|
||||||
can do it with the following.
|
can do it with the following.
|
||||||
@ -297,8 +299,8 @@ can do it with the following.
|
|||||||
postPersist: [ doStuffOnPostPersist ]
|
postPersist: [ doStuffOnPostPersist ]
|
||||||
|
|
||||||
In YAML the ``key`` of the lifecycleCallbacks entry is the event that you
|
In YAML the ``key`` of the lifecycleCallbacks entry is the event that you
|
||||||
are triggering on and the values are the methods to call. The allowed event
|
are triggering on and the value is the method (or methods) to call. The allowed
|
||||||
types are the ones listed in the previous Lifecycle Events section.
|
event types are the ones listed in the previous Lifecycle Events section.
|
||||||
|
|
||||||
XML would look something like this:
|
XML would look something like this:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user