Skip to content

Update service_subscribers_locators.rst #13099

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
Feb 19, 2020
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
9 changes: 6 additions & 3 deletions service_container/service_subscribers_locators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ attribute to the locator service defining the name of this custom method:
# ...

App\HandlerCollection:
arguments: [!tagged_locator { tag: 'app.handler', default_index_method: 'myOwnMethodName' }]
arguments: [!tagged_locator { tag: 'app.handler', index_by: 'key', default_index_method: 'myOwnMethodName' }]

.. code-block:: xml

Expand All @@ -542,7 +542,7 @@ attribute to the locator service defining the name of this custom method:
<!-- ... -->

<service id="App\HandlerCollection">
<argument type="tagged_locator" tag="app.handler" default-index-method="myOwnMethodName"/>
<argument type="tagged_locator" tag="app.handler" index-by="key" default-index-method="myOwnMethodName"/>
</service>
</services>
</container>
Expand All @@ -555,9 +555,12 @@ attribute to the locator service defining the name of this custom method:
return function(ContainerConfigurator $configurator) {
$configurator->services()
->set(App\HandlerCollection::class)
->args([tagged_locator('app.handler', null, 'myOwnMethodName')])
->args([tagged_locator('app.handler', 'key', 'myOwnMethodName')])
;
};

Note since code should not be the place that decides how the locators are going to be used, a configuration key (`key` in the example above) must be set in order this to work. So the custom method may be called as a fallback.


Service Subscriber Trait
------------------------
Expand Down