If the interface class is in a bundle, the classes that implement it aren't being tagged. The services themselves are public (since they're in the app), but do I need to do something special to have the tag added?
I have a bunch of import services and a import bundle. The handler happens in the bundle, currently by dispatching events which the services listen for (and check for a code). I've refactored the services as describe here, but they're not being injected, probably because it's missing the tag.
In the app:
namespace App\Service\Handler;
use Survos\PixieBundle\Meta\HandlerInterface; // <- the bundle
use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;
#[AsTaggedItem('larco')]
class LarcoHandler implements HandlerInterface
{
I guess I can inject the services from the Bundle definition, is there a way to get the attributes do that instead?
2 Comments
If the interface class is in a bundle, the classes that implement it aren't being tagged. The services themselves are public (since they're in the app), but do I need to do something special to have the tag added?
I have a bunch of import services and a import bundle. The handler happens in the bundle, currently by dispatching events which the services listen for
(and check for a code). I've refactored the services as describe here, but they're not being injected, probably because it's missing the tag.
In the app:
I guess I can inject the services from the Bundle definition, is there a way to get the attributes do that instead?
Hey @Tac-Tacelosky!
You're right, you'd need to add a tag to these interfaces. I believe you could do this by adding the following to your
src/Kernel.php:Then, in a service where you need them all, you can now do the following:
Be aware that the services from the bundle would be keyed by their FQCN but your implementations could add
AsTaggedItemto customize the key.I hope that helps!
Kevin
"Houston: no signs of life"
Start the conversation!