@@ -501,6 +501,51 @@ To answer this, change the service declaration:
501
501
502
502
Support for attributes as array was introduced in Symfony 6.2.
503
503
504
+ .. tip ::
505
+
506
+ The ``name `` attribute is used by default to define the name of the tag.
507
+ If you want to add a ``name `` attribute to some tag in XML or YAML formats,
508
+ you need to use this special syntax:
509
+
510
+ .. configuration-block ::
511
+
512
+ .. code-block :: yaml
513
+
514
+ # config/services.yaml
515
+ services :
516
+ MailerSmtpTransport :
517
+ arguments : ['%mailer_host%']
518
+ tags :
519
+ # this is a tag called 'app.mail_transport'
520
+ - { name: 'app.mail_transport', alias: 'smtp' }
521
+ # this is a tag called 'app.mail_transport' with two attributes ('name' and 'alias')
522
+ - app.mail_transport : { name: 'arbitrary-value', alias: 'smtp' }
523
+
524
+ .. code-block :: xml
525
+
526
+ <!-- config/services.xml -->
527
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
528
+ <container xmlns =" http://symfony.com/schema/dic/services"
529
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
530
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
531
+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
532
+
533
+ <services >
534
+ <service id =" MailerSmtpTransport" >
535
+ <argument >%mailer_host%</argument >
536
+ <!-- this is a tag called 'app.mail_transport' -->
537
+ <tag name =" app.mail_transport" alias =" sendmail" />
538
+ <!-- this is a tag called 'app.mail_transport' with two attributes ('name' and 'alias') -->
539
+ <tag name =" arbitrary-value" alias =" smtp" >app.mail_transport</tag >
540
+ </service >
541
+ </services >
542
+ </container >
543
+
544
+ .. versionadded :: 5.1
545
+
546
+ The possibility to add the ``name `` attribute to a tag in XML and YAML
547
+ formats was introduced in Symfony 5.1.
548
+
504
549
.. tip ::
505
550
506
551
In YAML format, you may provide the tag as a simple string as long as
0 commit comments