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

Documented short DI tag syntax#7769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
xabbuh merged 1 commit intosymfony:masterfromderrabus:3.3-short-di-tags-in-yaml
Apr 8, 2017
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletionsservice_container/tags.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,8 +19,7 @@ to be used for a specific purpose. Take the following example:
app.twig_extension:
class: AppBundle\Twig\AppExtension
public: false
tags:
- { name: twig.extension }
tags: [twig.extension]

.. code-block:: xml

Expand DownExpand Up@@ -148,13 +147,11 @@ For example, you may add the following transports as services:
app.smtp_transport:
class: \Swift_SmtpTransport
arguments: ['%mailer_host%']
tags:
- { name: app.mail_transport }
tags: [app.mail_transport]

app.sendmail_transport:
class: \Swift_SendmailTransport
tags:
- { name: app.mail_transport }
tags: [app.mail_transport]

.. code-block:: xml

Expand DownExpand Up@@ -341,6 +338,26 @@ To answer this, change the service declaration:
$definitionSendmail->addTag('app.mail_transport', array('alias' => 'bar'));
$container->setDefinition('app.sendmail_transport', $definitionSendmail);

.. tip::

In YAML format, you may provide the tag as a simple string as long as you don't need to specify additional
attributes. The following definitions are equivalent.

.. code-block:: yaml

services:

# Compact syntax
app.sendmail_transport:
class: \Swift_SendmailTransport
tags: [app.mail_transport]

# Verbose syntax
app.sendmail_transport:
class: \Swift_SendmailTransport
tags:
- { name: app.mail_transport }

Notice that you've added a generic ``alias`` key to the tag. To actually
use this, update the compiler::

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp