@@ -585,16 +585,15 @@ application handlers::
585
585
}
586
586
}
587
587
588
-
589
588
Tagged Services with Priority
590
589
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
591
590
592
591
.. versionadded :: 4.4
593
592
594
593
The ability to prioritize tagged services was introduced in Symfony 4.4.
595
594
596
- The tagged services can be prioritized using the ``priority `` attribute, thus providing
597
- a way to inject a sorted collection.
595
+ The tagged services can be prioritized using the ``priority `` attribute,
596
+ thus providing a way to inject a sorted collection of services:
598
597
599
598
.. configuration-block ::
600
599
@@ -627,23 +626,21 @@ a way to inject a sorted collection.
627
626
// config/services.php
628
627
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
629
628
629
+ use App\Handler\One;
630
+
630
631
return function(ContainerConfigurator $configurator) {
631
632
$services = $configurator->services();
632
633
633
- $services->set(App\Handler\ One::class)
634
+ $services->set(One::class)
634
635
->tag('app.handler', ['priority' => 20])
635
636
;
636
637
};
637
638
638
- .. note ::
639
-
640
- Note that any other custom attribute will be ignored by this feature.
641
-
642
-
643
- Another option, which is particularly useful when using autoconfiguring tags, is to implement the
644
- static ``getDefaultPriority `` method on the service itself::
639
+ Another option, which is particularly useful when using autoconfiguring
640
+ tags, is to implement the static ``getDefaultPriority() `` method on the
641
+ service itself::
645
642
646
- // src/App/ Handler/One.php
643
+ // src/Handler/One.php
647
644
namespace App/Handler;
648
645
649
646
class One
@@ -654,7 +651,8 @@ static ``getDefaultPriority`` method on the service itself::
654
651
}
655
652
}
656
653
657
- If you want to have another method defining the priority, you can define it in the configuration of the collecting service:
654
+ If you want to have another method defining the priority, you can define it
655
+ in the configuration of the collecting service:
658
656
659
657
.. configuration-block ::
660
658
0 commit comments