Skip to content

Commit 5a4ddb2

Browse files
authored
Merge pull request #9184 from ThomasLandauer/patch-1
[Documentation] Events Overview Table: Adding "Passed Argument" column
2 parents 68fa55f + 0b0c3e7 commit 5a4ddb2

File tree

1 file changed

+57
-43
lines changed

1 file changed

+57
-43
lines changed

docs/en/reference/events.rst

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -135,38 +135,38 @@ see :ref:`Lifecycle Callbacks<lifecycle-callbacks>`
135135
Events Overview
136136
---------------
137137

138-
+-----------------------------------------------------------------+-----------------------+-----------+
139-
| Event | Dispatched by | Lifecycle |
140-
| | | Callback |
141-
+=================================================================+=======================+===========+
142-
| :ref:`preRemove<reference-events-pre-remove>` | ``$em->remove()`` | Yes |
143-
+-----------------------------------------------------------------+-----------------------+-----------+
144-
| :ref:`postRemove<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes |
145-
+-----------------------------------------------------------------+-----------------------+-----------+
146-
| :ref:`prePersist<reference-events-pre-persist>` | ``$em->persist()`` | Yes |
147-
| | on *initial* persist | |
148-
+-----------------------------------------------------------------+-----------------------+-----------+
149-
| :ref:`postPersist<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes |
150-
+-----------------------------------------------------------------+-----------------------+-----------+
151-
| :ref:`preUpdate<reference-events-pre-update>` | ``$em->flush()`` | Yes |
152-
+-----------------------------------------------------------------+-----------------------+-----------+
153-
| :ref:`postUpdate<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes |
154-
+-----------------------------------------------------------------+-----------------------+-----------+
155-
| :ref:`postLoad<reference-events-post-load>` | Loading from database | Yes |
156-
+-----------------------------------------------------------------+-----------------------+-----------+
157-
| :ref:`loadClassMetadata<reference-events-load-class-metadata>` | Loading of mapping | No |
158-
| | metadata | |
159-
+-----------------------------------------------------------------+-----------------------+-----------+
160-
| ``onClassMetadataNotFound`` | ``MappingException`` | No |
161-
+-----------------------------------------------------------------+-----------------------+-----------+
162-
| :ref:`preFlush<reference-events-pre-flush>` | ``$em->flush()`` | Yes |
163-
+-----------------------------------------------------------------+-----------------------+-----------+
164-
| :ref:`onFlush<reference-events-on-flush>` | ``$em->flush()`` | No |
165-
+-----------------------------------------------------------------+-----------------------+-----------+
166-
| :ref:`postFlush<reference-events-post-flush>` | ``$em->flush()`` | No |
167-
+-----------------------------------------------------------------+-----------------------+-----------+
168-
| ``onClear`` | ``$em->clear()`` | No |
169-
+-----------------------------------------------------------------+-----------------------+-----------+
138+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
139+
| Event | Dispatched by | Lifecycle | Passed |
140+
| | | Callback | Argument |
141+
+=================================================================+=======================+===========+=====================================+
142+
| :ref:`preRemove<reference-events-pre-remove>` | ``$em->remove()`` | Yes | `_LifecycleEventArgs`_ |
143+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
144+
| :ref:`postRemove<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
145+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
146+
| :ref:`prePersist<reference-events-pre-persist>` | ``$em->persist()`` | Yes | `_LifecycleEventArgs`_ |
147+
| | on *initial* persist | | |
148+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
149+
| :ref:`postPersist<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
150+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
151+
| :ref:`preUpdate<reference-events-pre-update>` | ``$em->flush()`` | Yes | `_PreUpdateEventArgs`_ |
152+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
153+
| :ref:`postUpdate<reference-events-post-update-remove-persist>` | ``$em->flush()`` | Yes | `_LifecycleEventArgs`_ |
154+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
155+
| :ref:`postLoad<reference-events-post-load>` | Loading from database | Yes | `_LifecycleEventArgs`_ |
156+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
157+
| :ref:`loadClassMetadata<reference-events-load-class-metadata>` | Loading of mapping | No | `_LoadClassMetadataEventArgs` |
158+
| | metadata | | |
159+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
160+
| ``onClassMetadataNotFound`` | ``MappingException`` | No | `_OnClassMetadataNotFoundEventArgs` |
161+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
162+
| :ref:`preFlush<reference-events-pre-flush>` | ``$em->flush()`` | Yes | `_PreFlushEventArgs`_ |
163+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
164+
| :ref:`onFlush<reference-events-on-flush>` | ``$em->flush()`` | No | `_OnFlushEventArgs` |
165+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
166+
| :ref:`postFlush<reference-events-post-flush>` | ``$em->flush()`` | No | `_PostFlushEventArgs` |
167+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
168+
| ``onClear`` | ``$em->clear()`` | No | `_OnClearEventArgs` |
169+
+-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
170170

171171
Naming convention
172172
~~~~~~~~~~~~~~~~~
@@ -296,6 +296,9 @@ specific to a particular entity class's lifecycle.
296296
.. code-block:: attribute
297297
298298
<?php
299+
300+
use Doctrine\DBAL\Types\Types;
301+
use Doctrine\Persistence\Event\LifecycleEventArgs;
299302
300303
/**
301304
* #[Entity]
@@ -305,11 +308,11 @@ specific to a particular entity class's lifecycle.
305308
{
306309
// ...
307310
308-
#[Column(type: 'string', length: 255)]
311+
#[Column(type: Types::STRING, length: 255)]
309312
public $value;
310313
311314
#[PrePersist]
312-
public function doStuffOnPrePersist()
315+
public function doStuffOnPrePersist(LifecycleEventArgs $eventArgs)
313316
{
314317
$this->createdAt = date('Y-m-d H:i:s');
315318
}
@@ -320,15 +323,17 @@ specific to a particular entity class's lifecycle.
320323
$this->value = 'changed from prePersist callback!';
321324
}
322325
323-
#[PostLoad]
324-
public function doStuffOnPostLoad()
326+
#[PreUpdate]
327+
public function doStuffOnPreUpdate(PreUpdateEventArgs $eventArgs)
325328
{
326-
$this->value = 'changed from postLoad callback!';
329+
$this->value = 'changed from preUpdate callback!';
327330
}
328331
}
329332
.. code-block:: annotation
330333
331334
<?php
335+
336+
use Doctrine\Persistence\Event\LifecycleEventArgs;
332337
333338
/**
334339
* @Entity
@@ -342,7 +347,7 @@ specific to a particular entity class's lifecycle.
342347
public $value;
343348
344349
/** @PrePersist */
345-
public function doStuffOnPrePersist()
350+
public function doStuffOnPrePersist(LifecycleEventArgs $eventArgs)
346351
{
347352
$this->createdAt = date('Y-m-d H:i:s');
348353
}
@@ -353,10 +358,10 @@ specific to a particular entity class's lifecycle.
353358
$this->value = 'changed from prePersist callback!';
354359
}
355360
356-
/** @PostLoad */
357-
public function doStuffOnPostLoad()
361+
/** @PreUpdate */
362+
public function doStuffOnPreUpdate(PreUpdateEventArgs $eventArgs)
358363
{
359-
$this->value = 'changed from postLoad callback!';
364+
$this->value = 'changed from preUpdate callback!';
360365
}
361366
}
362367
.. code-block:: xml
@@ -372,7 +377,7 @@ specific to a particular entity class's lifecycle.
372377
<lifecycle-callbacks>
373378
<lifecycle-callback type="prePersist" method="doStuffOnPrePersist"/>
374379
<lifecycle-callback type="prePersist" method="doOtherStuffOnPrePersist"/>
375-
<lifecycle-callback type="postLoad" method="doStuffOnPostLoad"/>
380+
<lifecycle-callback type="preUpdate" method="doStuffOnPreUpdate"/>
376381
</lifecycle-callbacks>
377382
</entity>
378383
</doctrine-mapping>
@@ -386,7 +391,7 @@ specific to a particular entity class's lifecycle.
386391
type: string(255)
387392
lifecycleCallbacks:
388393
prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersist ]
389-
postLoad: [ doStuffOnPostLoad ]
394+
preUpdate: [ doStuffOnPreUpdate ]
390395
391396
Lifecycle Callbacks Event Argument
392397
----------------------------------
@@ -1085,3 +1090,12 @@ and the EntityManager.
10851090
$em = $eventArgs->getEntityManager();
10861091
}
10871092
}
1093+
1094+
.. _LifecycleEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/LifecycleEventArgs.php
1095+
.. _PreUpdateEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php
1096+
.. _PreFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreFlushEventArgs.php
1097+
.. _PostFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostFlushEventArgs.php
1098+
.. _OnFlushEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnFlushEventArgs.php
1099+
.. _OnClearEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClearEventArgs.php
1100+
.. _LoadClassMetadataEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php
1101+
.. _OnClassMetadataNotFoundEventArgs: https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php

0 commit comments

Comments
 (0)