add note on service parameters regarding ScopeWideningInjectionException #2424

Merged
merged 4 commits into from Apr 4, 2013

Conversation

Projects
None yet
4 participants
Contributor

joelclermont commented Mar 30, 2013

Q A
Doc fix? yes
New docs? yes
Applies to all
Fixed tickets #1707

Based on our discussion in IRC, instead of describing how to use strict=false, I linked to the cookbook article on Scopes for the recommended solutions.

@wouterj wouterj commented on an outdated diff Mar 30, 2013

book/service_container.rst
@@ -231,6 +231,15 @@ looks up the value of each parameter and uses it in the service definition.
<argument type="string">http://symfony.com/?foo=%%s&bar=%%d</argument>
+.. note::
+
+ It can be useful to pass other services in as arguments to your custom service.
+ For example, you may want to pass in the `request` service as an argument.
+ In these cases, you may receive a `ScopeWideningInjectionException`.
@wouterj

wouterj Mar 30, 2013

Member

you must use double backticks to indicate an inline code block

Contributor

joelclermont commented Mar 30, 2013

Oops, so hard to shake my Markdown brain. Fixed.

@Sgoettschkes Sgoettschkes commented on an outdated diff Mar 30, 2013

book/service_container.rst
@@ -231,6 +231,15 @@ looks up the value of each parameter and uses it in the service definition.
<argument type="string">http://symfony.com/?foo=%%s&bar=%%d</argument>
+.. note::
+
+ It can be useful to pass other services in as arguments to your custom service.
+ For example, you may want to pass in the ``request`` service as an argument.
+ In these cases, you may receive a ``ScopeWideningInjectionException``.
+ To understand this problem better and learn how to solve it, refer to
+ the cookbook article :doc:`/cookbook/service_container/scopes` for a
+ few solutions.
@Sgoettschkes

Sgoettschkes Mar 30, 2013

Contributor

I would delete "for a few solutions".

@wouterj wouterj commented on an outdated diff Apr 2, 2013

book/service_container.rst
@@ -231,6 +231,14 @@ looks up the value of each parameter and uses it in the service definition.
<argument type="string">http://symfony.com/?foo=%%s&bar=%%d</argument>
+.. note::
@wouterj

wouterj Apr 2, 2013

Member

I think it should be a .. caution:: block

@wouterj wouterj commented on an outdated diff Apr 2, 2013

book/service_container.rst
@@ -231,6 +231,14 @@ looks up the value of each parameter and uses it in the service definition.
<argument type="string">http://symfony.com/?foo=%%s&bar=%%d</argument>
+.. note::
+
+ It can be useful to pass other services in as arguments to your custom service.
@wouterj

wouterj Apr 2, 2013

Member

this sentence is not needed, as this article is telling about it. Because it's a caution block, I prefer to have something like:

You may receive a :class:`Symfony\\....\\ScopeWideningInjectionException` when
passing the ``request`` service as an argument. To understand this problem better
and leran how to solve it, refer to the ":doc:`/cookbook/service_container/scope`"

(please note that the api link for the exception class is not correct right now)

weaverryan merged commit 7b0bfac into symfony:2.0 Apr 4, 2013

Member

weaverryan commented Apr 4, 2013

Hey Joel!

Nice work here - and good use of existing documentation.

Thanks!

joelclermont deleted the joelclermont:issue_1707 branch Apr 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment