@@ -425,6 +425,7 @@ first constructor argument to the ``App\HandlerCollection`` service:
425
425
426
426
.. code-block :: yaml
427
427
428
+ # app/config/services.yml
428
429
services :
429
430
App\Handler\One :
430
431
tags : [app.handler]
@@ -438,6 +439,7 @@ first constructor argument to the ``App\HandlerCollection`` service:
438
439
439
440
.. code-block :: xml
440
441
442
+ <!-- app/config/services.xml -->
441
443
<?xml version =" 1.0" encoding =" UTF-8" ?>
442
444
<container xmlns =" http://symfony.com/schema/dic/services"
443
445
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -462,15 +464,16 @@ first constructor argument to the ``App\HandlerCollection`` service:
462
464
463
465
.. code-block :: php
464
466
467
+ // app/config/services.php
465
468
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
466
469
467
- $container->register(\ App\Handler\One::class)
470
+ $container->register(App\Handler\One::class)
468
471
->addTag('app.handler');
469
472
470
- $container->register(\ App\Handler\Two::class)
473
+ $container->register(App\Handler\Two::class)
471
474
->addTag('app.handler');
472
475
473
- $container->register(\ App\HandlerCollection::class)
476
+ $container->register(App\HandlerCollection::class)
474
477
// inject all services tagged with app.handler as first argument
475
478
->addArgument(new TaggedIteratorArgument('app.handler'));
476
479
@@ -488,11 +491,37 @@ application handlers.
488
491
489
492
.. tip ::
490
493
491
- The collected services can be prioritized using the ``priority `` attribute.
494
+ The collected services can be prioritized using the ``priority `` attribute:
492
495
493
- .. code-block :: yaml
496
+
497
+ .. configuration-block ::
494
498
495
- services :
496
- App\Handler\One :
497
- tags :
498
- - { name: app.handler, priority: 20 }
499
+ .. code-block :: yaml
500
+
501
+ # app/config/services.yml
502
+ services :
503
+ App\Handler\One :
504
+ tags :
505
+ - { name: app.handler, priority: 20 }
506
+
507
+ .. code-block :: xml
508
+
509
+ <!-- app/config/services.xml -->
510
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
511
+ <container xmlns =" http://symfony.com/schema/dic/services"
512
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
513
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
514
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
515
+
516
+ <services >
517
+ <service id =" App\Handler\One" >
518
+ <tag name =" app.handler" priority =" 20" />
519
+ </service >
520
+ </services >
521
+ </container >
522
+
523
+ .. code-block :: php
524
+
525
+ // app/config/services.php
526
+ $container->register(App\Handler\One::class)
527
+ ->addTag('app.handler', array('priority' => 20));
0 commit comments