Skip to content

Commit 5e6608b

Browse files
Update events.rst
1 parent dbaf99f commit 5e6608b

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

docs/en/reference/events.rst

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ specific to a particular entity class's lifecycle.
305305
306306
<?php
307307
308-
/** @Entity @HasLifecycleCallbacks */
308+
/**
309+
* @Entity
310+
* @HasLifecycleCallbacks // Not needed for XML and YAML mapping
311+
*/
309312
class User
310313
{
311314
// ...
@@ -315,9 +318,6 @@ specific to a particular entity class's lifecycle.
315318
*/
316319
public $value;
317320
318-
/** @Column(name="created_at", type="string", length=255) */
319-
private $createdAt;
320-
321321
/** @PrePersist */
322322
public function doStuffOnPrePersist()
323323
{
@@ -330,23 +330,11 @@ specific to a particular entity class's lifecycle.
330330
$this->value = 'changed from prePersist callback!';
331331
}
332332
333-
/** @PostPersist */
334-
public function doStuffOnPostPersist()
335-
{
336-
$this->value = 'changed from postPersist callback!';
337-
}
338-
339333
/** @PostLoad */
340334
public function doStuffOnPostLoad()
341335
{
342336
$this->value = 'changed from postLoad callback!';
343337
}
344-
345-
/** @PreUpdate */
346-
public function doStuffOnPreUpdate()
347-
{
348-
$this->value = 'changed from preUpdate callback!';
349-
}
350338
}
351339
.. code-block:: xml
352340
@@ -361,7 +349,8 @@ specific to a particular entity class's lifecycle.
361349
362350
<lifecycle-callbacks>
363351
<lifecycle-callback type="prePersist" method="doStuffOnPrePersist"/>
364-
<lifecycle-callback type="postPersist" method="doStuffOnPostPersist"/>
352+
<lifecycle-callback type="prePersist" method="doOtherStuffOnPrePersist"/>
353+
<lifecycle-callback type="postLoad" method="doStuffOnPostLoad"/>
365354
</lifecycle-callbacks>
366355
367356
</entity>
@@ -372,16 +361,12 @@ specific to a particular entity class's lifecycle.
372361
User:
373362
type: entity
374363
fields:
375-
# ...
376-
name:
377-
type: string(50)
364+
# ...
365+
value:
366+
type: string(255)
378367
lifecycleCallbacks:
379368
prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersist ]
380-
postPersist: [ doStuffOnPostPersist ]
381-
382-
Note that the methods set as lifecycle callbacks need to be public and,
383-
when using these annotations, you have to apply the
384-
``@HasLifecycleCallbacks`` marker annotation on the entity class.
369+
postLoad: [ doStuffOnPostLoad ]
385370
386371
Lifecycle Callbacks Event Argument
387372
----------------------------------

0 commit comments

Comments
 (0)