Skip to content
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

Merged
merged 1 commit into from
Nov 26, 2019

Conversation

mikadamczyk
Copy link
Contributor

@mikadamczyk mikadamczyk commented Oct 23, 2019

Question Answer
JIRA issue EZP-31044
Improvement yes
New feature no
Target version master
BC breaks yes
Tests pass yes
Doc needed yes

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 by ChainSiteAccessProvider which implements SiteAccessProviderInterface. 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:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

@mikadamczyk mikadamczyk self-assigned this Oct 23, 2019
@mikadamczyk mikadamczyk changed the title EZP-31044: Site Access Provider EZP-31044: Added multiple sources of available SiteAccesses Oct 23, 2019
Copy link
Member

@alongosz alongosz left a 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

@alongosz alongosz force-pushed the EZP-31044-site-access-provider branch from 6f76950 to 16abcc8 Compare October 29, 2019 10:50
@mikadamczyk mikadamczyk marked this pull request as ready for review November 7, 2019 08:32
@mikadamczyk mikadamczyk force-pushed the EZP-31044-site-access-provider branch from f96803e to 4bfc081 Compare November 7, 2019 12:58
public function getSiteAccesses(): Traversable
{
foreach ($this->siteAccessList as $name) {
yield new SiteAccess($name, SiteAccess::DEFAULT_MATCHING_TYPE, null, self::class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yield $this-> getSiteAccess($name);

Copy link
Contributor Author

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);
Copy link
Contributor

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.

@alongosz alongosz changed the title EZP-31044: Added multiple sources of available SiteAccesses EZP-31044: Implemented SiteAccess providers Nov 15, 2019
Copy link
Member

@alongosz alongosz left a 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:

eZ/Publish/Core/MVC/Symfony/SiteAccess.php Outdated Show resolved Hide resolved
eZ/Publish/Core/MVC/Symfony/SiteAccess/Router.php Outdated Show resolved Hide resolved
public function __construct(
string $name,
string $matchingType = self::DEFAULT_MATCHING_TYPE,
$matcher = null,
Copy link
Member

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.

@mikadamczyk mikadamczyk requested a review from alongosz November 20, 2019 12:56
@mikadamczyk mikadamczyk force-pushed the EZP-31044-site-access-provider branch from 8659f01 to 5bf6970 Compare November 26, 2019 10:19
@adamwojs adamwojs merged commit 50563cf into master Nov 26, 2019
@adamwojs adamwojs deleted the EZP-31044-site-access-provider branch November 26, 2019 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants