How to inject the @request into a service?

后端 未结 9 2244
Happy的楠姐
Happy的楠姐 2020-12-01 05:53

When I try to inject the @request into any of my services, I get this exception:

ScopeWideningInjectionException: Scope Widening Injection detected:

9条回答
  •  攒了一身酷
    2020-12-01 06:50

    another way to inject currentRequest directly:

    setter injection:

    calls:
         - ['setRequest', ['@=service("request_stack").getCurrentRequest()']]
    

    or constrauctor injection:

    arguments:
         $request: '@=service("request_stack").getCurrentRequest()'
    

提交回复
热议问题