Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a2fd23f

Browse filesBrowse files
authored
Update tags.rst
1 parent 000b801 commit a2fd23f
Copy full SHA for a2fd23f

File tree

Expand file treeCollapse file tree

1 file changed

+38
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+38
-9
lines changed

‎service_container/tags.rst

Copy file name to clipboardExpand all lines: service_container/tags.rst
+38-9Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ first constructor argument to the ``App\HandlerCollection`` service:
425425

426426
.. code-block:: yaml
427427
428+
# app/config/services.yml
428429
services:
429430
App\Handler\One:
430431
tags: [app.handler]
@@ -438,6 +439,7 @@ first constructor argument to the ``App\HandlerCollection`` service:
438439
439440
.. code-block:: xml
440441
442+
<!-- app/config/services.xml -->
441443
<?xml version="1.0" encoding="UTF-8" ?>
442444
<container xmlns="http://symfony.com/schema/dic/services"
443445
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -462,15 +464,16 @@ first constructor argument to the ``App\HandlerCollection`` service:
462464
463465
.. code-block:: php
464466
467+
// app/config/services.php
465468
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
466469
467-
$container->register(\App\Handler\One::class)
470+
$container->register(App\Handler\One::class)
468471
->addTag('app.handler');
469472
470-
$container->register(\App\Handler\Two::class)
473+
$container->register(App\Handler\Two::class)
471474
->addTag('app.handler');
472475
473-
$container->register(\App\HandlerCollection::class)
476+
$container->register(App\HandlerCollection::class)
474477
// inject all services tagged with app.handler as first argument
475478
->addArgument(new TaggedIteratorArgument('app.handler'));
476479
@@ -488,11 +491,37 @@ application handlers.
488491
489492
.. tip::
490493

491-
The collected services can be prioritized using the ``priority`` attribute.
494+
The collected services can be prioritized using the ``priority`` attribute:
492495

493-
.. code-block:: yaml
496+
497+
.. configuration-block::
494498

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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.