-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IBX-6906: [DX] Introduced identifier-based view matchers #322
Merged
Conversation
This file contains 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
Defined $relativeNamespace as nullable string
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
alongosz
requested review from
mikadamczyk,
Steveb-p,
webhdx,
ViniTou and
a team
January 23, 2024 15:46
ViniTou
approved these changes
Jan 26, 2024
adamwojs
approved these changes
Jan 28, 2024
konradoboza
approved these changes
Jan 29, 2024
mikadamczyk
approved these changes
Jan 29, 2024
mnocon
approved these changes
Feb 5, 2024
7 tasks
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.
v4.6
+The PR refactors
ViewMatcherRegistry
andServiceAwareMatcherFactory
to rely on identifier-based view matchers. Current behavior for service-name-based and class-name-based matchers is kept. To refer to a custom matcher using its identifier it's enough to addidentifier
attribute to its tag definition.Before:
After:
Roads not taken
Identifier collision is not taken into the consideration as it's a bit of an overkill. That would require keeping the dropped compiler pass, copy prioritized tag sorting logic (that is given OOTB by
tagged_iterator
) and, for it to make sense, actually reverse sorted tag so it's possible to override matcher by using higher priority tagged service (so it's added later thus overriding existing one). We could consider keeping the compiler pass for validation purposes only. Instead, I propose that our matchers are prefixed withIbexa\
.Side changes
ViewMatcherRegistryInterface
sofinal ViewMatcherRegistryInterface
can be mocked forServiceAwareMatcherFactory
test case (the Registry was already covered).ClassNameMatcherFactory
and its childServiceAwareMatcherFactory
$relativeNamespace
constructor argument was changed to be strictly-typed as?string
. Anything else passed there would cause the code to crash, so this change is rather safe.ClassNameMatcherFactory::getMatcher
returned\Ibexa\Core\MVC\Symfony\Matcher\ViewMatcherInterface
while its childServiceAwareMatcherFactory
type-hinted\Ibexa\Core\MVC\Symfony\Matcher\ContentBased\MatcherInterface
. This is clearly incorrect, so now both methods return baseViewMatcherInterface
. It might lead to some 1st party static analysis issues, that would need to be fixed as well.Future
In the future I'd like to completely get rid of
ClassNameMatcherFactory
in favor of identifier-based registered services, as that solution predates Dependency Injection Container, is confusing, and not very flexible. Making PHP FQCN prefix as a part of extension point proved to be not a very good idea, but probably the only sane one prior DIC.QA affected scope
Documentation
View configuration section could be expanded to include specific configuration for the use case with identifier:
The example needs to be replaced with the following one:
Checklist:
$ composer fix-cs
).@ibexa/engineering
).