Skip to content

Commit 1754ff8

Browse files
committed
Minor tweaks to service subscribers article
1 parent 5a80eea commit 1754ff8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

service_container/service_subscribers.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ services.
7979

8080
**Service Subscribers** are intended to solve this problem by giving access to a
8181
set of predefined services while instantiating them only when actually needed
82-
through a service locator.
82+
through a **Service Locator**, a separate lazy-loaded container.
8383

8484
Defining a Service Subscriber
8585
-----------------------------
8686

8787
First, turn ``CommandBus`` into an implementation of :class:`Symfony\\Component\\DependencyInjection\\ServiceSubscriberInterface`.
8888
Use its ``getSubscribedServices`` method to include as many services as needed
89-
in the service locater and change the container to a PSR-11 ``ContainerInterface``::
89+
in the service subscriber and change the type hint of the container to
90+
a PSR-11 ``ContainerInterface``::
9091

9192
// src/AppBundle/CommandBus.php
9293
namespace AppBundle;
@@ -128,7 +129,7 @@ in the service locater and change the container to a PSR-11 ``ContainerInterface
128129
.. tip::
129130

130131
If the container does *not* contain the subscribed services, double-check
131-
that you have :ref:`autoconfigure <services-autoconfigure>` enabled. You
132+
that you have :ref:`autoconfigure <services-autoconfigure>` enabled. You
132133
can also manually add the ``container.service_subscriber`` tag.
133134

134135
The injected service is an instance of :class:`Symfony\\Component\\DependencyInjection\\ServiceLocator`
@@ -173,7 +174,7 @@ Optional services
173174
~~~~~~~~~~~~~~~~~
174175

175176
For optional dependencies, prepend the service type with a ``?`` to prevent
176-
errors if there's no matching service in the service container::
177+
errors if there's no matching service found in the service container::
177178

178179
use Psr\Log\LoggerInterface;
179180

@@ -306,7 +307,7 @@ include as many services as needed in it.
306307
The services defined in the service locator argument must include keys,
307308
which later become their unique identifiers inside the locator.
308309

309-
Now you can use the service locator injecting it in any other service:
310+
Now you can use the service locator by injecting it in any other service:
310311

311312
.. configuration-block::
312313

0 commit comments

Comments
 (0)