-
Notifications
You must be signed in to change notification settings - Fork 203
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
EZP-31044: Implemented SiteAccess providers #2838
Conversation
eZ/Bundle/EzPublishCoreBundle/EventListener/ConsoleCommandListener.php
Outdated
Show resolved
Hide resolved
eZ/Publish/Core/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProvider.php
Outdated
Show resolved
Hide resolved
eZ/Publish/Core/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very difficult to review:
Please split commits into at least:
- class structure for SiteAccess providers
- refactoring which hooks SiteAccess providers into the Repository (or replaces SiteAccess list, depending how you see it),
- adds test coverage
- aligns existing tests (can be one commit for tests ^)
and use fixups to address code review issues (if they pop up)
Please use "providers" keyword for the PR title as well, since this is what you've actually implemented.
e.g.
EZP-31044: Implemented SiteAccess providers.
would be fine
eZ/Publish/Core/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php
Show resolved
Hide resolved
6f76950
to
16abcc8
Compare
eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/ConsoleCommandListenerTest.php
Outdated
Show resolved
Hide resolved
f96803e
to
4bfc081
Compare
eZ/Publish/Core/MVC/Symfony/SiteAccess/Tests/RouterBaseTest.php
Outdated
Show resolved
Hide resolved
public function getSiteAccesses(): Traversable | ||
{ | ||
foreach ($this->siteAccessList as $name) { | ||
yield new SiteAccess($name, SiteAccess::DEFAULT_MATCHING_TYPE, null, self::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yield $this-> getSiteAccess($name);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We iterate over $this->siteAccessList
and getSiteAccess
method will perform again isDefined
check which has no sense. I think it is better to return the object here.
public function getSiteAccess(string $name): SiteAccess | ||
{ | ||
if ($this->isDefined($name)) { | ||
return new SiteAccess($name, SiteAccess::DEFAULT_MATCHING_TYPE, null, self::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider caching siteAccesses instead of creating a new object every time function is fired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, just 2 remarks:
public function __construct( | ||
string $name, | ||
string $matchingType = self::DEFAULT_MATCHING_TYPE, | ||
$matcher = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up: create common marker interface for URILexer
and Matcher
.
8659f01
to
5bf6970
Compare
master
This PR adds the possibility of having more than one source of available SiteAccesses.
By default, we have
StaticSiteAccessProvider
which contains SiteAccesses fetched from configuration files. Provides are gathered byChainSiteAccessProvider
which implementsSiteAccessProviderInterface
. The chain is used instead of Strategy because the order of loaded SiteAccesses is important. Those coming from configuration files should be matched first.This will allows us to add another provider that will fetch another SiteAccesses from the database. This is required to introduce Site Factory.
TODO:
$ composer fix-cs
).