Closed bitwise-operators closed 1 year ago
You're doing an awesome job! Its quite a few changes, I'll have a better look when I'm back from vacation.
Do I understand it correctly and is this feature the same as the tagged iterator from Symfony?
Most of the changes are in the tests, as usual :-)
If by tagged iterator, you're referring to tagged services, then yes, it's pretty much the same (as far as I can see, not very familiar with Symfony)
Usually, you have to add something like this to the Laravel service container:
$this->app->tag(
[
Implementation1::class,
Implementation2::class,
// repeat
ImplementationX::class,
],
'myTag'
);
Which, especially with classes with lots of implementations, can be tedious and error-prone.
This add-on should make it easier.
Enjoy your vacation!
Ah so it will group the implementations in an array and that one array is then injected?
Exactly.
@Jeroen-G I was wondering if you'd had any time to look at this yet?
Hi there,
This is a 'simple' addition of a new Attribute (and interface) that allows for instant tagging of all implementations of the interface the attribute is added to.
In the included implementation, the fully namespaced interface name is used as the tag name by default, but can be overridden by a string argument to the attribute.
The interface for the attribute specifies passing the
ReflectionClass
of the interface to thegetTag()
method, so that implementations can generate their tags in whatever way they desire.I'm also working on an expansion of the
Configure
functionality to use tags, but once I'm happy with that, I'll submit it as a separate PR.