InjectExtension: added support for injecting services by tags#321
Open
rixafy wants to merge 22 commits intonette:v3.3from
Open
InjectExtension: added support for injecting services by tags#321rixafy wants to merge 22 commits intonette:v3.3from
rixafy wants to merge 22 commits intonette:v3.3from
Conversation
5e952c3 to
b83c80a
Compare
…' moved to visitors
…st-class callables
519c44e to
fd32279
Compare
572329e to
7a27fe7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I also added new method getByTypeAndTag (container + autowiring) so $throw can be always as last parameter, otherwise it would be getByType($type, $throw, $tag).
Now it's possible to have multiple services of the same type and inject them by tag with
#[Inject(tag: <tag>), it's also possible to use in constructors.Only rule is that one of those multiple services needs to have tag
default, and that service will be injected if no tag is specified (or if you specifydefault). I have considered also to inject service with least amount of tags or with no tags, but this can lead to unpredictable behavior when more tags are added in the future.This allows to work with interfaces and requiring specific services, some examples: