Skip to content

Commit 8683ab5

Browse files
committed
minor #18802 [DependencyInjection] Allow loading and dumping tags with an attribute named "name" (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Allow loading and dumping tags with an attribute named "name" Not an easy one to fully understand. Friendly ping `@stof` as you participated to the issue 🙂 Thanks! Fix #13613 Commits ------- 52aee81 [DependencyInjection] Allow loading and dumping tags with an attribute named "name"
2 parents 5582881 + 52aee81 commit 8683ab5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

service_container/tags.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,45 @@ To answer this, change the service declaration:
515515
;
516516
};
517517
518+
.. tip::
519+
520+
In XML and YAML format, you may provide the tag an attribute called ``name``.
521+
When doing so, this is the syntax you should follow:
522+
523+
.. configuration-block::
524+
525+
.. code-block:: yaml
526+
527+
# config/services.yaml
528+
services:
529+
MailerSmtpTransport:
530+
arguments: ['%mailer_host%']
531+
tags:
532+
- app.mail_transport: { name: 'arbitrary-value', alias: 'smtp' }
533+
534+
.. code-block:: xml
535+
536+
<!-- config/services.xml -->
537+
<?xml version="1.0" encoding="UTF-8" ?>
538+
<container xmlns="http://symfony.com/schema/dic/services"
539+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
540+
xsi:schemaLocation="http://symfony.com/schema/dic/services
541+
https://symfony.com/schema/dic/services/services-1.0.xsd">
542+
543+
<services>
544+
<service id="MailerSmtpTransport">
545+
<argument>%mailer_host%</argument>
546+
547+
<tag name="arbitrary-value" alias="smtp">app.mail_transport</tag>
548+
</service>
549+
</services>
550+
</container>
551+
552+
.. versionadded:: 5.1
553+
554+
The possibility to add the ``name`` attribute to a tag in XML and YAML
555+
formats was introduced in Symfony 5.1.
556+
518557
.. tip::
519558

520559
In YAML format, you may provide the tag as a simple string as long as

0 commit comments

Comments
 (0)