8000 Add example how to turn off strict mode in yaml for ScopeWideningInjectionException · Issue #1707 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Add example how to turn off strict mode in yaml for ScopeWideningInjectionException #1707

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
stloyd opened this issue Sep 14, 2012 · 5 comments
Labels
actionable Clear and specific issues ready for anyone to take them. DependencyInjection good first issue Ideal for your first contribution! (some Symfony experience may be required)

Comments

@stloyd
Copy link
Contributor
stloyd commented Sep 14, 2012

In case of:

services:
    service_name:
        class: Some\Class\Here
        arguments: [@request]

ScopeWideningInjectionException probably will be throw, and as described in this exception message:

(...) In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.

In case of xml or php it's simple, but when it comes to yaml it looks like:

services:
    service_name:
        class: Some\Class\Here
        arguments: [@request=]
@PsySecCorp
Copy link

Goddamn it, the Service Container needs to be burned to the ground if this is considered an acceptable answer.

Thank you for this.

@wouterj
Copy link
Member
wouterj commented Feb 3, 2013

@weaverryan this should get an easy pick label.

@sgalonska
Copy link

Thank you so much for this. Does not make sense at all, but works. Sounds like PHP ;)

@weaverryan
Copy link
Member

Btw, you should now be injecting the request_stack service instead of request - then you won't have any of this nasty scope stuff :)

@ctrl-f5
Copy link
ctrl-f5 commented May 6, 2015

Thank you @weaverryan, injecting @request_stack solved the problem for me. (and it has a getCurrentRequest() function)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. DependencyInjection good first issue Ideal for your first contribution! (some Symfony experience may be required)
Projects
None yet
Development

No branches or pull requests

6 participants
0