@@ -239,7 +239,7 @@ define a listener for the ``postUpdate`` Doctrine event::
239
239
{
240
240
// the entity listener methods receive two arguments:
241
241
// the entity instance and the lifecycle event
242
- public function checkUserChanges (User $user, LifecycleEventArgs $event)
242
+ public function postUpdate (User $user, LifecycleEventArgs $event)
243
243
{
244
244
// ... do something to notify the changes
245
245
}
@@ -260,21 +260,23 @@ with the ``doctrine.orm.entity_listener`` tag:
260
260
App\EventListener\UserChangedNotifier :
261
261
tags :
262
262
-
263
- # these are the basic options that define the entity listener
263
+ # these are the options required to define the entity listener
264
264
name : ' doctrine.orm.entity_listener'
265
265
event : ' postUpdate'
266
266
entity : ' App\Entity\User'
267
267
268
+ # these are other options that you may define if needed
269
+
268
270
# set the 'lazy' option to TRUE to only instantiate listeners when they are used
269
- lazy : true
271
+ # lazy: true
270
272
271
- # you can also associate an entity listener to a specific entity manager
272
- entity_manager : ' custom'
273
+ # set the 'entity_manager' option if the listener is not associated to the default manager
274
+ # entity_manager: 'custom'
273
275
274
276
# by default, Symfony looks for a method called after the event (e.g. postUpdate())
275
277
# if it doesn't exist, it tries to execute the '__invoke()' method, but you can
276
278
# configure a custom method name with the 'method' option
277
- method : ' checkUserChanges'
279
+ # method: 'checkUserChanges'
278
280
279
281
.. code-block :: xml
280
282
@@ -287,11 +289,15 @@ with the ``doctrine.orm.entity_listener`` tag:
287
289
288
290
<service id =" App\EventListener\UserChangedNotifier" >
289
291
<!--
290
- * 'event' and 'entity' are the basic options that define the entity listener
291
- * 'lazy': if TRUE, listeners are only instantiated when they are used
292
- * 'entity_manager': define it if the listener is not associated to the
293
- * default entity manager
294
- * 'method': by default, Symfony looks for a method called after the event (e.g. postUpdate())
292
+ * These are the options required to define the entity listener:
293
+ * * name
294
+ * * event
295
+ * * entity
296
+ *
297
+ * These are other options that you may define if needed:
298
+ * * lazy: if TRUE, listeners are only instantiated when they are used
299
+ * * entity_manager: define it if the listener is not associated to the default manager
300
+ * * method: by default, Symfony looks for a method called after the event (e.g. postUpdate())
295
301
* if it doesn't exist, it tries to execute the '__invoke()' method, but
296
302
* you can configure a custom method name with the 'method' option
297
303
-->
@@ -313,20 +319,22 @@ with the ``doctrine.orm.entity_listener`` tag:
313
319
314
320
$container->autowire(UserChangedNotifier::class)
315
321
->addTag('doctrine.orm.entity_listener', [
316
- // these are the basic options that define the entity listener
322
+ // These are the options required to define the entity listener:
317
323
'event' => 'postUpdate',
318
324
'entity' => User::class,
319
325
326
+ // These are other options that you may define if needed:
327
+
320
328
// set the 'lazy' option to TRUE to only instantiate listeners when they are used
321
- 'lazy' => true,
329
+ // 'lazy' => true,
322
330
323
- // you can also associate an entity listener to a specific entity manager
324
- 'entity_manager' => 'custom',
331
+ // set the 'entity_manager' option if the listener is not associated to the default manager
332
+ // 'entity_manager' => 'custom',
325
333
326
334
// by default, Symfony looks for a method called after the event (e.g. postUpdate())
327
335
// if it doesn't exist, it tries to execute the '__invoke()' method, but you can
328
336
// configure a custom method name with the 'method' option
329
- 'method' => 'checkUserChanges',
337
+ // 'method' => 'checkUserChanges',
330
338
])
331
339
;
332
340
0 commit comments