@@ -65,8 +65,10 @@ Synthetic Services
65
65
Synthetic services are services that are injected into the container instead
66
66
of being created by the container.
67
67
68
- For instance, the ``request `` service which is injected in the
69
- :method: `HttpKernel::handle() <Symfony\\ Component\\ HttpKernel\\ HttpKernel::handle> `
68
+ For example, if you're using the :doc: `HttpKernel</components/http_kernel/introduction> `
69
+ component with the DependencyInjection component, then the the ``request ``
70
+ service is injected in the
71
+ :method: `ContainerAwareHttpKernel::handle() <Symfony\\ Component\\ HttpKernel\\ DependencyInjection\\ ContainerAwareHttpKernel::handle> `
70
72
method when entering the request :doc: `scope </cookbook/service_container/scopes >`.
71
73
The class does not exist when there is no request, so it can't be included in
72
74
the container configuration. Also, the service should be different for every
@@ -96,11 +98,11 @@ To create a synthetic service, set ``synthetic`` to ``true``:
96
98
->setSynthetic(true);
97
99
98
100
As you see, only the ``synthetic `` option is set. All other options are only used
99
- to configure the container how a service is created by the container. As the
100
- service isn't created by the container, these options are omitted.
101
+ to configure how a service is created by the container. As the service isn't
102
+ created by the container, these options are omitted.
101
103
102
104
Now, you can inject the class by using
103
- :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerBuilder ::set `::
105
+ :method: `Container::set< Symfony\\ Component\\ DependencyInjection\\ Container ::set> `::
104
106
105
107
// ...
106
108
$container->set('request', new MyRequest(...));
0 commit comments