-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
||
app.greeting_card_manager: | ||
class: AppBundle\Mail\GreetingCardManager | ||
arguments: ['@mailer'] | ||
configurator: ['@app.email_configurator', configure] | ||
configurator: 'app.email_configurator:configure' | ||
|
||
.. code-block:: xml | ||
|
||
|
@@ -186,6 +186,23 @@ You can configure the service configurator using the ``configurator`` option: | |
->setConfigurator(array(new Reference('app.email_configurator'), 'configure')) | ||
; | ||
|
||
.. note:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't it be |
||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
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 notation
Class::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.There was a problem hiding this comment.
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.