-
-
Couldn't load subscription status.
- Fork 9.7k
Description
Right now, using the asset twig function results in the following error:
[
Symfony\Component\DependencyInjection\Exception\ScopeWideningInjectionException]Scope Widening Injection detected: The definition "
templating.asset.default_package" references the service "request" which belongs to a narrower scope. Generally, it is safer to either move "templating.asset.default_package" to scope "request" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "request" each time it is needed. In rare, special cases however that might not be necessary, then you can set the reference tostrict=falseto get rid of this error.
As one may want to rely on the asset helper to generate URIs outside from a request (i.e., in a command-line, for sending e-mails), it should not depend on the request service, but rather on request_stack, in order to be available in a wider scope.
This would also allow the simplification of Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension, by removing calls to the setScope() methods, once support for scopes is dropped for 3.0.