8000 Added docs about ArgumentValueResolvers by linaori · Pull Request #6438 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Added docs about ArgumentValueResolvers #6438

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
Closed
Prev Previous commit
Next Next commit
Fixed a wrong tag name
  • Loading branch information
Iltar van der Berg committed Apr 29, 2016
commit 7d00d8ced8a0d80bc2418e6244c541f23fa56865
6 changes: 3 additions & 3 deletions cookbook/controller/argument_value_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ can be done by tagging the service with ``kernel.argument_resolver`` and adding
arguments:
- '@security.token_storage'
Copy link
Contributor

Choose a reason for hiding this comment

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

" instead of ' ?

Copy link
Member

Choose a reason for hiding this comment

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

Using single quotes is better in Yaml

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be curious for the reason: not that I don't agree with it but I always thought there was absolutely not difference. Besides it's quite inconsistent (or at least used to be I didn't check for a while now) in Symfony/Symfony docs.

Copy link
Member

Choose a reason for hiding this comment

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

Here you can find more details about single/double quotes: http://symfony.com/doc/current/components/yaml/yaml_format.html

Copy link
Contributor

Choose a reason for hiding this comment

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

@javiereguiluz my comment was maybe a bit misleading: I'm aware of the differences, I was only talking for when both were giving the same result as why to pick simple quotes over double ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

@theofidry the link actually says:

Strings containing any of the following characters must be quoted. Although you can use double quotes, for these characters it is more convenient to use single quotes, which avoids having to escape any backslash \

Copy link
Member

Choose a reason for hiding this comment

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

@theofidry we recently updated most double quotes in Yaml to single quotes (for consistency).

Using double quotes (or advocating using them) leads to problems with certain strings that are valid in PHP double quotes. For instance, "AppBundle\Controller\StaticController" is a valid PHP value, but it would result in a parser error in Yaml as \C and \S are not valid character sequences.

tags:
- { name: kernel.argument_resolver, priority: 50 }
- { name: controller_argument.value_resolver, priority: 50 }

.. code-block:: xml

Expand All @@ -172,7 +172,7 @@ can be done by tagging the service with ``kernel.argument_resolver`` and adding
<services>
<service id="app.value_resolver.user" class="AppBundle\ArgumentValueResolver\UserValueResolver">
<argument type="service" id="security.token_storage">
<tag name="kernel.argument_resolver" priority="50" />
<tag name="controller_argument.value_resolver" priority="50" />
</service>
</services>

Expand All @@ -187,7 +187,7 @@ can be done by tagging the service with ``kernel.argument_resolver`` and adding
'AppBundle\ArgumentValueResolver\UserValueResolver',
array(new Reference('security.token_storage'))
);
$definition->addTag('kernel.argument_resolver', array('priority' => 50));
$definition->addTag('controller_argument.value_resolver', array('priority' => 50));
$container->setDefinition('app.value_resolver.user', $definition);

.. _`yield`: http://php.net/manual/en/language.generators.syntax.php
0