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

Use the new configurator YAML syntax#7203

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

Closed
javiereguiluz wants to merge4 commits intosymfony:3.2fromjaviereguiluz:fix_7176
Closed
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
21 changes: 19 additions & 2 deletionsservice_container/configurators.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -127,12 +127,12 @@ You can configure the service configurator using the ``configurator`` option:
app.newsletter_manager:
class: AppBundle\Mail\NewsletterManager
arguments: ['@mailer']
configurator:['@app.email_configurator',configure]
configurator:'app.email_configurator:configure'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

you actually have to use two colons

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Like this?

configurator: 'app.email_configurator::configure'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@xabbuh that's not true. 2 colons are used when doing a callable referencing a static method (the PHP standard notationClass::staticMethod). The shortcut syntax for service method callables uses a single colon (i.e. something which cannot appear in a valid PHP callable), as done already for the routing configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sorry for the confusion Javier.@stof is indeed right.


app.greeting_card_manager:
class: AppBundle\Mail\GreetingCardManager
arguments: ['@mailer']
configurator:['@app.email_configurator',configure]
configurator:'app.email_configurator:configure'

.. code-block:: xml

Expand DownExpand Up@@ -186,6 +186,23 @@ You can configure the service configurator using the ``configurator`` option:
->setConfigurator(array(new Reference('app.email_configurator'), 'configure'))
;

.. note::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

shouldn't it beversionadded ?


The traditional configurator syntax in YAML files used an array to define
the service id and the method name:

.. code-block:: yaml

app.newsletter_manager:
# new syntax
configurator: 'app.email_configurator:configure'
# old syntax
configurator: ['@app.email_configurator', configure]

.. versionadded:: 3.2
The ``service_id:method_name`` syntax for the YAML configuration format
was introduced in Symfony 3.2.

That's it! When requesting the ``app.newsletter_manager`` or
``app.greeting_card_manager`` service, the created instance will first be
passed to the ``EmailConfigurator::configure()`` method.

[8]ページ先頭

©2009-2025 Movatter.jp