Skip to content

[DependencyInjection] Typo on how default defaultIndexMethod work #17342

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
Jun 15, 2023
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
18 changes: 15 additions & 3 deletions service_container/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -804,17 +804,29 @@ array element. For example, to retrieve the ``handler_two`` handler::

.. tip::

Just like the priority, you can also implement a static
``getDefaultIndexName()`` method in the handlers and omit the
Just like the priority, if you set the attribute (``index_by``) on the :tagged_iterator, you can also implement a static
``getDefault(``index_by``)Name()`` method in the handlers and omit the
index attribute (``key``)::


.. code-block:: yaml

# config/services.yaml
services:
# ...

App\HandlerCollection:
arguments: [!tagged_iterator { tag: 'app.handler', index_by: 'handler' }]

.. code-block:: php

// src/Handler/One.php
namespace App\Handler;

class One
{
// ...
public static function getDefaultIndexName(): string
public static function getDefaultHandlerName(): string
{
return 'handler_one';
}
Expand Down