Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Documented the service locator autoconfiguration #9505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Documented the service locator autoconfiguration
  • Loading branch information
javiereguiluz committed Mar 27, 2018
commit c7ea0cfe14cff4f8c62cb0f41e531db8812cacf4
19 changes: 16 additions & 3 deletions 19 service_container/service_locators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ option to include as many services as needed to it and add the
services:
app.command_handler_locator:
class: Symfony\Component\DependencyInjection\ServiceLocator
tags: ['container.service_locator']
arguments:
-
App\FooCommand: '@app.command_handler.foo'
App\BarCommand: '@app.command_handler.bar'
# if you are not using the default service autoconfiguration,
# add the following tag to the service definition:
# tags: ['container.service_locator']

.. code-block:: xml

Expand All @@ -116,7 +118,11 @@ option to include as many services as needed to it and add the
<argument key="App\FooCommand" type="service" id="app.command_handler.foo" />
<argument key="App\BarCommand" type="service" id="app.command_handler.bar" />
</argument>
<tag name="container.service_locator" />
<!--
if you are not using the default service autoconfiguration,
add the following tag to the service definition:
<tag name="container.service_locator" />
-->
</service>

</services>
Expand All @@ -132,13 +138,20 @@ option to include as many services as needed to it and add the

$container
->register('app.command_handler_locator', ServiceLocator::class)
->addTag('container.service_locator')
->setArguments(array(array(
'App\FooCommand' => new Reference('app.command_handler.foo'),
'App\BarCommand' => new Reference('app.command_handler.bar'),
)))
// if you are not using the default service autoconfiguration,
// add the following tag to the service definition:
// ->addTag('container.service_locator')
;

.. versionadded:: 4.1
The service locator autoconfiguration was introduced in Symfony 4.1. In
previous Symfony versions you always needed to add the
``container.service_locator`` tag explicitly.

.. note::

The services defined in the service locator argument must include keys,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.