Is there an easy (supported) way to programatically get all services in Drupal 8 that are tagged with a specific tag?
For example getting all services that are tagged with "breadcrumb_builder" tag
Example for a service tag from book module:
services:
book.breadcrumb:
class: Drupal\book\BookBreadcrumbBuilder
arguments: ['@entity_type.manager', '@current_user']
tags:
- { name: breadcrumb_builder, priority: 701 }
Now if i want to get all services from all (enabled) *.services.yml files that are tagged with "breadcrumb_builder"?
I have seen and read this: https://symfony.com/doc/3.4/service_container/tags.html
But this seems to be really hard work and I am not sure if its even possible that way without touching Drupal core.
The Reference Tagged Services method looked very promising at first, but seems not to be supported from Drupal by default.
$container->findTaggedServiceIds('tag_name');
?service_collector
service in the container which collects the tagged services at compile time. It's unclear what this question is about, but if you want to use the collected services for something this would be the way to go.