-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Description
Symfony version(s) affected: 4.3.8
Description
If "default_index_method" is used and "index_by" is omitted, the tagged services are not indexed.
How to reproduce
- Use _instanceof in your services.yaml to attach a tag to an interface
_instanceof:
App\Test\TagTestInterface:
tags: ['app.list']
- Add a class to your services.yaml and inject the tagged list:
TestTagList:
arguments: [!tagged { tag: app.list } ]
- Use the "default_index_method" as described here (https://symfony.com/doc/current/service_container/service_subscribers_locators.html#indexing-the-collection-of-services)
TestTagList:
arguments: [!tagged { tag: app.list, default_index_method: 'getTest' } ]
- The injected tagged list will not have been indexed.
Possible Solution
You can add
index_by: 'somestring'
in order for "default_index_method" to be working.
TestTagList:
arguments: [!tagged { tag: app.list, index_by: 'somestring', default_index_method: 'getTest' } ]
Maybe this is not a bug but just not clear enough in the docs.