11.. index ::
22 single: DependencyInjection; Service Subscribers
33
4- Service Subscribers
5- ===================
4+ Service Subscribers & Locators
5+ ==============================
66
77Sometimes, a service needs access to several other services without being sure
88that all of them will actually be used. In those cases, you may want the
@@ -85,7 +85,7 @@ Defining a Service Subscriber
8585-----------------------------
8686
8787First, turn ``CommandBus `` into an implementation of :class: `Symfony\\ Component\\ DependencyInjection\\ ServiceSubscriberInterface `.
88- Use its ``getSubscribedServices `` method to include as many services as needed
88+ Use its ``getSubscribedServices() `` method to include as many services as needed
8989in the service subscriber and change the type hint of the container to
9090a PSR-11 ``ContainerInterface ``::
9191
@@ -141,7 +141,7 @@ which implements the PSR-11 ``ContainerInterface``, but it is also a callable::
141141
142142 return $handler->handle($command);
143143
144- Including services
144+ Including Services
145145------------------
146146
147147In order to add a new dependency to the service subscriber, use the
@@ -158,7 +158,7 @@ service locator::
158158 ];
159159 }
160160
161- Service types can also be keyed by a service name for use internally ::
161+ Service types can also be keyed by a service name for internal use ::
162162
163163 use Psr\Log\LoggerInterface;
164164
@@ -170,7 +170,7 @@ Service types can also be keyed by a service name for use internally::
170170 ];
171171 }
172172
173- Optional services
173+ Optional Services
174174~~~~~~~~~~~~~~~~~
175175
176176For optional dependencies, prepend the service type with a ``? `` to prevent
@@ -191,7 +191,7 @@ errors if there's no matching service found in the service container::
191191 Make sure an optional service exists by calling ``has() `` on the service
192192 locator before calling the service itself.
193193
194- Aliased services
194+ Aliased Services
195195~~~~~~~~~~~~~~~~
196196
197197By default, autowiring is used to match a service type to a service from the
0 commit comments