Skip to main content

Bundle Helpers 2.4: Indexing Tagged Services

· One min read
Jannik Zschiesche
Tech Lead Web

Symfony 8.1 deprecated the defaultIndexMethod option of tagged locators and iterators. Bundle Helpers 2.4 adds the TagIndexFromStaticMethodPass as replacement: it sets the index as tag attribute from the existing static method of your services, so you can switch your locators to indexAttribute.

The pass validates strictly: all tagged services must have the expected type and an explicitly set index must match the value of the static method.

In your services, you can now also define the index via #[AsTaggedItem]. In the long run, this makes the static method obsolete.

Bundle Helpers 2.4 requires Symfony 8.1+ and PHP 8.5+.