What I'm trying to achieve is the following: Some of the services in my application contain a special annotation. Later, during the build process, a special team should find all the files with this annotation.
My approach is to download all packages first:
$container = $this->getContainer();
foreach ($container->getParameter('kernel.bundles') as $alias => $namespace)
$bundle = $container->get('kernel')->getBundle($alias);
I am stuck at this point. How do I get a copy $bundle
to tell me its services?
Note. I would also be pleased with a solution that is not related to the package, that is, one that downloads all available service definitions. ContainerBuilder
got getDefinitions
one that looks promising, although I don't know how to access it from the team.
I need to get a list with service identifiers and their classes - especially classes, because these are the ones I need to load into the annotation reader.
Obviously, I don't want to parse myself services.yml
, and Id would also like to avoid loading an instance of each service from $container->getServiceIds()
.
(Btw, tagged services do not help, I need annotations. And I want to automatically detect annotated services because tagging them will require an additional step that is unnecessary and error prone.)
source
share