From 720e9f7b65d6dd17802e448490e181144e4e0baf Mon Sep 17 00:00:00 2001 From: Bastien Picharles Date: Wed, 12 Oct 2022 16:06:01 +0200 Subject: [PATCH] [DependencyInjection] Typo on how default defaultIndexMethod work --- service_container/tags.rst | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/service_container/tags.rst b/service_container/tags.rst index 94d7d2036b3..9a94006ce8d 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -804,9 +804,21 @@ 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; @@ -814,7 +826,7 @@ array element. For example, to retrieve the ``handler_two`` handler:: class One { // ... - public static function getDefaultIndexName(): string + public static function getDefaultHandlerName(): string { return 'handler_one'; }