From eff973345e16f768db23b515fb61d251b9595985 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sun, 29 Nov 2015 23:29:11 -0500 Subject: [PATCH] removing more scope stuff --- book/service_container.rst | 14 -------------- components/dependency_injection/parentservices.rst | 3 +-- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/book/service_container.rst b/book/service_container.rst index a061b68945e..261c32b4183 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -884,20 +884,6 @@ Now, just inject the ``request_stack``, which behaves like any normal service: array(new Reference('request_stack')) )); -.. sidebar:: Why not Inject the ``request`` Service? - - Almost all Symfony2 built-in services behave in the same way: a single - instance is created by the container which it returns whenever you get it or - when it is injected into another service. There is one exception in a standard - Symfony2 application: the ``request`` service. - - If you try to inject the ``request`` into a service, you will probably receive - a - :class:`Symfony\\Component\\DependencyInjection\\Exception\\ScopeWideningInjectionException` - exception. That's because the ``request`` can **change** during the life-time - of a container (when a sub-request is created for instance). - - .. tip:: If you define a controller as a service then you can get the ``Request`` diff --git a/components/dependency_injection/parentservices.rst b/components/dependency_injection/parentservices.rst index 9237e57ac21..968686a0ea5 100644 --- a/components/dependency_injection/parentservices.rst +++ b/components/dependency_injection/parentservices.rst @@ -277,8 +277,7 @@ called when the child services are instantiated. .. caution:: - The ``scope``, ``abstract`` and ``tags`` attributes are always taken - from the child service. + The ``abstract`` and ``tags`` attributes are always taken from the child service. The parent service is abstract as it should not be directly retrieved from the container or passed into another service. It exists merely as a "template"