Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf5b1f23

Browse files
committed
Documented short DI tag syntax.
1 parent52404c9 commitf5b1f23

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

‎service_container/tags.rst‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ to be used for a specific purpose. Take the following example:
1919
app.twig_extension:
2020
class:AppBundle\Twig\AppExtension
2121
public:false
22-
tags:
23-
-{ name: twig.extension }
22+
tags:[twig.extension]
2423
2524
..code-block::xml
2625
@@ -148,13 +147,11 @@ For example, you may add the following transports as services:
148147
app.smtp_transport:
149148
class:\Swift_SmtpTransport
150149
arguments:['%mailer_host%']
151-
tags:
152-
-{ name: app.mail_transport }
150+
tags:[app.mail_transport]
153151
154152
app.sendmail_transport:
155153
class:\Swift_SendmailTransport
156-
tags:
157-
-{ name: app.mail_transport }
154+
tags:[app.mail_transport]
158155
159156
..code-block::xml
160157
@@ -341,6 +338,26 @@ To answer this, change the service declaration:
341338
$definitionSendmail->addTag('app.mail_transport', array('alias' => 'bar'));
342339
$container->setDefinition('app.sendmail_transport', $definitionSendmail);
343340
341+
..tip::
342+
343+
In YAML format, you may provide the tag as a simple string as long as you don't need to specify additional
344+
attributes. The following definitions are equivalent.
345+
346+
..code-block::yaml
347+
348+
services:
349+
350+
# Compact syntax
351+
app.sendmail_transport:
352+
class:\Swift_SendmailTransport
353+
tags:[app.mail_transport]
354+
355+
# Verbose syntax
356+
app.sendmail_transport:
357+
class:\Swift_SendmailTransport
358+
tags:
359+
-{ name: app.mail_transport }
360+
344361
Notice that you've added a generic ``alias`` key to the tag. To actually
345362
use this, update the compiler::
346363

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp