Skip to content

Commit 720e9f7

Browse files
Kleinastjaviereguiluz
authored andcommitted
[DependencyInjection] Typo on how default defaultIndexMethod work
1 parent be6992c commit 720e9f7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

service_container/tags.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,17 +804,29 @@ array element. For example, to retrieve the ``handler_two`` handler::
804804

805805
.. tip::
806806

807-
Just like the priority, you can also implement a static
808-
``getDefaultIndexName()`` method in the handlers and omit the
807+
Just like the priority, if you set the attribute (``index_by``) on the :tagged_iterator, you can also implement a static
808+
``getDefault(``index_by``)Name()`` method in the handlers and omit the
809809
index attribute (``key``)::
810+
811+
812+
.. code-block:: yaml
813+
814+
# config/services.yaml
815+
services:
816+
# ...
817+
818+
App\HandlerCollection:
819+
arguments: [!tagged_iterator { tag: 'app.handler', index_by: 'handler' }]
820+
821+
.. code-block:: php
810822
811823
// src/Handler/One.php
812824
namespace App\Handler;
813825
814826
class One
815827
{
816828
// ...
817-
public static function getDefaultIndexName(): string
829+
public static function getDefaultHandlerName(): string
818830
{
819831
return 'handler_one';
820832
}

0 commit comments

Comments
 (0)