Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:masterfromjaviereguiluz:fix_9374
Mar 28, 2018
Merged
Changes fromall 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
19 changes: 16 additions & 3 deletionsservice_container/service_locators.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp