Merge pull request #107 from frosas/document-pre-and-post-flush-events
Document preFlush and postFlush events
This commit is contained in:
commit
b3119c0a5f
@ -163,9 +163,13 @@ the life-time of their registered entities.
|
|||||||
- loadClassMetadata - The loadClassMetadata event occurs after the
|
- loadClassMetadata - The loadClassMetadata event occurs after the
|
||||||
mapping metadata for a class has been loaded from a mapping source
|
mapping metadata for a class has been loaded from a mapping source
|
||||||
(annotations/xml/yaml).
|
(annotations/xml/yaml).
|
||||||
|
- preFlush - The preFlush event occurs at the very beginning of a flush
|
||||||
|
operation. This event is not a lifecycle callback.
|
||||||
- onFlush - The onFlush event occurs after the change-sets of all
|
- onFlush - The onFlush event occurs after the change-sets of all
|
||||||
managed entities are computed. This event is not a lifecycle
|
managed entities are computed. This event is not a lifecycle
|
||||||
callback.
|
callback.
|
||||||
|
- postFlush - The postFlush event occurs at the end of a flush operation. This
|
||||||
|
event is not a lifecycle callback.
|
||||||
- onClear - The onClear event occurs when the EntityManager#clear() operation is
|
- onClear - The onClear event occurs when the EntityManager#clear() operation is
|
||||||
invoked, after all references to entities have been removed from the unit of
|
invoked, after all references to entities have been removed from the unit of
|
||||||
work.
|
work.
|
||||||
@ -420,6 +424,27 @@ There are no restrictions to what methods can be called inside the
|
|||||||
``preRemove`` event, except when the remove method itself was
|
``preRemove`` event, except when the remove method itself was
|
||||||
called during a flush operation.
|
called during a flush operation.
|
||||||
|
|
||||||
|
preFlush
|
||||||
|
~~~~~~~~
|
||||||
|
|
||||||
|
``preFlush`` is called at ``EntityManager#flush()`` before
|
||||||
|
anything else. ``EntityManager#flush()`` can be called safely
|
||||||
|
inside its listeners.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Doctrine\ORM\Event\PreFlushEventArgs;
|
||||||
|
|
||||||
|
class PreFlushExampleListener
|
||||||
|
{
|
||||||
|
public function preFlush(PreFlushEventArgs $args)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onFlush
|
onFlush
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
@ -483,6 +508,27 @@ The following restrictions apply to the onFlush event:
|
|||||||
affected entity. This can be done by either calling
|
affected entity. This can be done by either calling
|
||||||
``$unitOfWork->recomputeSingleEntityChangeSet($classMetadata, $entity)``.
|
``$unitOfWork->recomputeSingleEntityChangeSet($classMetadata, $entity)``.
|
||||||
|
|
||||||
|
postFlush
|
||||||
|
~~~~~~~~~
|
||||||
|
|
||||||
|
``postFlush`` is called at the end of ``EntityManager#flush()`` before the
|
||||||
|
lists of scheduled changes are cleared. ``EntityManager#flush()`` can be
|
||||||
|
called safely inside its listeners.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Doctrine\ORM\Event\PostFlushEventArgs;
|
||||||
|
|
||||||
|
class PostFlushExampleListener
|
||||||
|
{
|
||||||
|
public function postFlush(PostFlushEventArgs $args)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
preUpdate
|
preUpdate
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user