@@ -136,38 +136,38 @@ entity, see :ref:`Lifecycle Callbacks<lifecycle-callbacks>`.
136136Events Overview
137137---------------
138138
139- +-----------------------------------------------------------------+-----------------------+-----------+
140- | Event | Dispatched by | Lifecycle |
141- | | | Callback |
142- +=================================================================+=======================+===========+
143- | :ref: `preRemove<reference-events-pre-remove> ` | ``$em->remove() `` | Yes |
144- +-----------------------------------------------------------------+-----------------------+-----------+
145- | :ref: `postRemove<reference-events-post-update-remove-persist> ` | ``$em->flush() `` | Yes |
146- +-----------------------------------------------------------------+-----------------------+-----------+
147- | :ref: `prePersist<reference-events-pre-persist> ` | ``$em->persist() `` | Yes |
148- | | on *initial * persist | |
149- +-----------------------------------------------------------------+-----------------------+-----------+
150- | :ref: `postPersist<reference-events-post-update-remove-persist> ` | ``$em->flush() `` | Yes |
151- +-----------------------------------------------------------------+-----------------------+-----------+
152- | :ref: `preUpdate<reference-events-pre-update> ` | ``$em->flush() `` | Yes |
153- +-----------------------------------------------------------------+-----------------------+-----------+
154- | :ref: `postUpdate<reference-events-post-update-remove-persist> ` | ``$em->flush() `` | Yes |
155- +-----------------------------------------------------------------+-----------------------+-----------+
156- | :ref: `postLoad<reference-events-post-load> ` | Loading from database | Yes |
157- +-----------------------------------------------------------------+-----------------------+-----------+
158- | :ref: `loadClassMetadata<reference-events-load-class-metadata> ` | Loading of mapping | No |
159- | | metadata | |
160- +-----------------------------------------------------------------+-----------------------+-----------+
161- | ``onClassMetadataNotFound `` | ``MappingException `` | No |
162- +-----------------------------------------------------------------+-----------------------+-----------+
163- | :ref: `preFlush<reference-events-pre-flush> ` | ``$em->flush() `` | Yes |
164- +-----------------------------------------------------------------+-----------------------+-----------+
165- | :ref: `onFlush<reference-events-on-flush> ` | ``$em->flush() `` | No |
166- +-----------------------------------------------------------------+-----------------------+-----------+
167- | :ref: `postFlush<reference-events-post-flush> ` | ``$em->flush() `` | No |
168- +-----------------------------------------------------------------+-----------------------+-----------+
169- | ``onClear `` | ``$em->clear() `` | No |
170- +-----------------------------------------------------------------+-----------------------+-----------+
139+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
140+ | Event | Dispatched by | Lifecycle | Passed |
141+ | | | Callback | Argument |
142+ +=================================================================+=======================+===========+=====================================+
143+ | :ref: `preRemove<reference-events-pre-remove> ` | ``$em->remove() `` | Yes | ` _LifecycleEventArgs `_ |
144+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
145+ | :ref: `postRemove<reference-events-post-update-remove-persist> ` | ``$em->flush() `` | Yes | ` _LifecycleEventArgs `_ |
146+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
147+ | :ref: `prePersist<reference-events-pre-persist> ` | ``$em->persist() `` | Yes | ` _LifecycleEventArgs `_ |
148+ | | on *initial * persist | | |
149+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
150+ | :ref: `postPersist<reference-events-post-update-remove-persist> ` | ``$em->flush() `` | Yes | ` _LifecycleEventArgs `_ |
151+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
152+ | :ref: `preUpdate<reference-events-pre-update> ` | ``$em->flush() `` | Yes | ` _PreUpdateEventArgs `_ |
153+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
154+ | :ref: `postUpdate<reference-events-post-update-remove-persist> ` | ``$em->flush() `` | Yes | ` _LifecycleEventArgs `_ |
155+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
156+ | :ref: `postLoad<reference-events-post-load> ` | Loading from database | Yes | ` _LifecycleEventArgs `_ |
157+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
158+ | :ref: `loadClassMetadata<reference-events-load-class-metadata> ` | Loading of mapping | No | ` _LoadClassMetadataEventArgs ` |
159+ | | metadata | | |
160+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
161+ | ``onClassMetadataNotFound `` | ``MappingException `` | No | ` _OnClassMetadataNotFoundEventArgs ` |
162+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
163+ | :ref: `preFlush<reference-events-pre-flush> ` | ``$em->flush() `` | Yes | ` _PreFlushEventArgs `_ |
164+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
165+ | :ref: `onFlush<reference-events-on-flush> ` | ``$em->flush() `` | No | ` _OnFlushEventArgs ` |
166+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
167+ | :ref: `postFlush<reference-events-post-flush> ` | ``$em->flush() `` | No | ` _PostFlushEventArgs ` |
168+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
169+ | ``onClear `` | ``$em->clear() `` | No | ` _OnClearEventArgs ` |
170+ +-----------------------------------------------------------------+-----------------------+-----------+-------------------------------------+
171171
172172Naming convention
173173~~~~~~~~~~~~~~~~~
@@ -294,6 +294,9 @@ specific to a particular entity class's lifecycle.
294294 .. code-block :: attribute
295295
296296 <?php
297+
298+ use Doctrine\DBAL\Types\Types;
299+ use Doctrine\Persistence\Event\LifecycleEventArgs;
297300
298301 /**
299302 * #[Entity]
@@ -303,11 +306,11 @@ specific to a particular entity class's lifecycle.
303306 {
304307 // ...
305308
306- #[Column(type: 'string' , length: 255)]
309+ #[Column(type: Types::STRING , length: 255)]
307310 public $value;
308311
309312 #[PrePersist]
310- public function doStuffOnPrePersist()
313+ public function doStuffOnPrePersist(LifecycleEventArgs $eventArgs )
311314 {
312315 $this->createdAt = date('Y-m-d H:i:s');
313316 }
@@ -318,15 +321,17 @@ specific to a particular entity class's lifecycle.
318321 $this->value = 'changed from prePersist callback!';
319322 }
320323
321- #[PostLoad ]
322- public function doStuffOnPostLoad( )
324+ #[PreUpdate ]
325+ public function doStuffOnPreUpdate(PreUpdateEventArgs $eventArgs )
323326 {
324- $this->value = 'changed from postLoad callback!';
327+ $this->value = 'changed from preUpdate callback!';
325328 }
326329 }
327330 .. code-block :: annotation
328331
329332 <?php
333+
334+ use Doctrine\Persistence\Event\LifecycleEventArgs;
330335
331336 /**
332337 * @Entity
@@ -340,7 +345,7 @@ specific to a particular entity class's lifecycle.
340345 public $value;
341346
342347 /** @PrePersist */
343- public function doStuffOnPrePersist()
348+ public function doStuffOnPrePersist(LifecycleEventArgs $eventArgs )
344349 {
345350 $this->createdAt = date('Y-m-d H:i:s');
346351 }
@@ -351,10 +356,10 @@ specific to a particular entity class's lifecycle.
351356 $this->value = 'changed from prePersist callback!';
352357 }
353358
354- /** @PostLoad */
355- public function doStuffOnPostLoad( )
359+ /** @PreUpdate */
360+ public function doStuffOnPreUpdate(PreUpdateEventArgs $eventArgs )
356361 {
357- $this->value = 'changed from postLoad callback!';
362+ $this->value = 'changed from preUpdate callback!';
358363 }
359364 }
360365 .. code-block :: xml
@@ -370,7 +375,7 @@ specific to a particular entity class's lifecycle.
370375 <lifecycle-callbacks >
371376 <lifecycle-callback type =" prePersist" method =" doStuffOnPrePersist" />
372377 <lifecycle-callback type =" prePersist" method =" doOtherStuffOnPrePersist" />
373- <lifecycle-callback type =" postLoad " method =" doStuffOnPostLoad " />
378+ <lifecycle-callback type =" preUpdate " method =" doStuffOnPreUpdate " />
374379 </lifecycle-callbacks >
375380 </entity >
376381 </doctrine-mapping >
@@ -384,7 +389,7 @@ specific to a particular entity class's lifecycle.
384389 type : string(255)
385390 lifecycleCallbacks :
386391 prePersist : [ doStuffOnPrePersist, doOtherStuffOnPrePersist ]
387- postLoad : [ doStuffOnPostLoad ]
392+ preUpdate : [ doStuffOnPreUpdate ]
388393
389394 Lifecycle Callbacks Event Argument
390395----------------------------------
@@ -1083,3 +1088,12 @@ and the EntityManager.
10831088 $em = $eventArgs->getEntityManager();
10841089 }
10851090 }
1091+
1092+ .. _LifecycleEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/LifecycleEventArgs.php
1093+ .. _PreUpdateEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreUpdateEventArgs.php
1094+ .. _PreFlushEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PreFlushEventArgs.php
1095+ .. _PostFlushEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/PostFlushEventArgs.php
1096+ .. _OnFlushEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnFlushEventArgs.php
1097+ .. _OnClearEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClearEventArgs.php
1098+ .. _LoadClassMetadataEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php
1099+ .. _OnClassMetadataNotFoundEventArgs : https://github.com/doctrine/orm/blob/HEAD/lib/Doctrine/ORM/Event/OnClassMetadataNotFoundEventArgs.php
0 commit comments