Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

javiereguiluz
Copy link
Member

This fixes #7176.

@@ -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
Member Author

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 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.

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.

@xabbuh
Copy link
Member

xabbuh commented Dec 1, 2016

I think we should then document this notation for factories too.

@@ -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.

@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.

@@ -186,6 +186,20 @@ 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 be versionadded ?

@javiereguiluz
Copy link
Member Author

@xabbuh let's do the factories change in another PR: #7208

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

.. versionadded:: 3.2
Copy link
Member

Choose a reason for hiding this comment

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

The versionadded directive nested in the note block doesn't look very nice. What about instead transforming the note into a versionadded instead as @stof suggested.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@xabbuh
Copy link
Member

xabbuh commented Apr 15, 2017

Thank you Javier.

xabbuh added a commit that referenced this pull request Apr 15, 2017
This PR was squashed before being merged into the 3.2 branch (closes #7203).

Discussion
----------

Use the new configurator YAML syntax

This fixes #7176.

Commits
-------

88e30b0 Use the new configurator YAML syntax
xabbuh added a commit that referenced this pull request Apr 15, 2017
@xabbuh xabbuh closed this Apr 15, 2017
weaverryan added a commit that referenced this pull request Apr 15, 2017
* 3.2: (71 commits)
  Rewriting the service container docs
  Minor reword
  Adding a tip for validation in forms without class
  [#7217] add versionadded directives
  [#7203] merge note and versionadded directive
  Use the new configurator YAML syntax
  Added a note about the .htaccess files included by Symfony apps
  Made unmapped field example in forms chapter more descriptive
  [#7507] fix namespace
  [#7507] fix component name
  [#7490] minor typo fix
  Added a note about redirections to absolute URLs in tests
  [#7204] link to API doc
  Added docs for JsonResponse::fromJsonString
  Added the changes suggested by reviewers
  [#7620] use generate() in PHP templates before 2.8
  Fixed the RST syntax
  Improve example context
  Minor formatting changes
  [#7519] some minor tweaks
  ...
@javiereguiluz javiereguiluz deleted the fix_7176 branch May 24, 2018 16:05
javiereguiluz added a commit that referenced this pull request May 29, 2019
…rekas)

This PR was merged into the 4.2 branch.

Discussion
----------

Remove short factories/configurators examples

This PR reverts #7203, as short factories are more confusing than useful.
I'm proposing to deprecate them in symfony/symfony#31543
Note that some of this patch can (should) be adapted to 3.4 also.

Commits
-------

e8cfa6e Remove short factories/configurators examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants