@@ -166,7 +166,7 @@ with the ``doctrine.event_listener`` tag:
166
166
# this is the only required option for the lifecycle listener tag
167
167
event : ' postPersist'
168
168
169
- # listeners can define their priority in case multiple listeners are associated
169
+ # listeners can define their priority in case multiple subscribers or listeners are associated
170
170
# to the same event (default priority = 0; higher numbers = listener is run earlier)
171
171
priority : 500
172
172
@@ -184,7 +184,7 @@ with the ``doctrine.event_listener`` tag:
184
184
185
185
<!--
186
186
* 'event' is the only required option that defines the lifecycle listener
187
- * 'priority': used when multiple listeners are associated to the same event
187
+ * 'priority': used when multiple subscribers or listeners are associated to the same event
188
188
* (default priority = 0; higher numbers = listener is run earlier)
189
189
* 'connection': restricts the listener to a specific Doctrine connection
190
190
-->
@@ -213,7 +213,7 @@ with the ``doctrine.event_listener`` tag:
213
213
// this is the only required option for the lifecycle listener tag
214
214
'event' => 'postPersist',
215
215
216
- // listeners can define their priority in case multiple listeners are associated
216
+ // listeners can define their priority in case multiple subscribers or listeners are associated
217
217
// to the same event (default priority = 0; higher numbers = listener is run earlier)
218
218
'priority' => 500,
219
219
@@ -428,7 +428,14 @@ with the ``doctrine.event_subscriber`` tag:
428
428
429
429
App\EventListener\DatabaseActivitySubscriber :
430
430
tags :
431
- - { name: 'doctrine.event_subscriber' }
431
+ - name : ' doctrine.event_subscriber'
432
+
433
+ # subscribers can define their priority in case multiple subscribers or listeners are associated
434
+ # to the same event (default priority = 0; higher numbers = listener is run earlier)
435
+ priority : 500
436
+
437
+ # you can also restrict listeners to a specific Doctrine connection
438
+ connection : ' default'
432
439
433
440
.. code-block :: xml
434
441
@@ -439,8 +446,15 @@ with the ``doctrine.event_subscriber`` tag:
439
446
<services >
440
447
<!-- ... -->
441
448
449
+ <!--
450
+ * 'priority': used when multiple subscribers or listeners are associated to the same event
451
+ * (default priority = 0; higher numbers = listener is run earlier)
452
+ * 'connection': restricts the listener to a specific Doctrine connection
453
+ -->
442
454
<service id =" App\EventListener\DatabaseActivitySubscriber" >
443
- <tag name =" doctrine.event_subscriber" />
455
+ <tag name =" doctrine.event_subscriber" priority =" 500" connection =" default" />
456
+ </service >
457
+
444
458
</service >
445
459
</services >
446
460
</container >
@@ -456,7 +470,14 @@ with the ``doctrine.event_subscriber`` tag:
456
470
$services = $configurator->services();
457
471
458
472
$services->set(DatabaseActivitySubscriber::class)
459
- ->tag('doctrine.event_subscriber')
473
+ ->tag('doctrine.event_subscriber'[
474
+ // subscribers can define their priority in case multiple subscribers or listeners are associated
475
+ // to the same event (default priority = 0; higher numbers = listener is run earlier)
476
+ 'priority' => 500,
477
+
478
+ # you can also restrict listeners to a specific Doctrine connection
479
+ 'connection' => 'default',
480
+ ])
460
481
;
461
482
};
462
483
@@ -505,6 +526,10 @@ can do it in the service configuration:
505
526
;
506
527
};
507
528
529
+ .. versionadded :: 5.3
530
+
531
+ Handling priority for subscribers alongside listeners has been introduced in Symfony 5.3.
532
+
508
533
.. tip ::
509
534
510
535
Symfony loads (and instantiates) Doctrine subscribers whenever the
0 commit comments