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

Support for getting the results for a location #38

Merged
merged 9 commits into from
Jan 13, 2021

Conversation

bdunogier
Copy link
Member

@bdunogier bdunogier commented May 28, 2020

Question Answer
JIRA issue EZP-31659
Type improvement
Target eZ Platform version v2.x, v3.x
BC breaks no
Tests pass yes/no
Doc needed yes

Introduces a new QueryFieldLocationService that allow to get results / results slices / count results based on a location. With the previous methods, only mainLocation was available as a variable, since it was inferred from the content.

Now both can be available, and location will be set to the "current" location. In the context of a content view, it will be the requested location's. For REST and GraphQL, parameters will be added to specify which location should be used.

TODO

  • Implement PagerFantaAdapter
  • Implement in QueryResultsInjector
  • Implement in the REST controller
  • Implement in GraphQL

Checklist

  • PR description is updated.
  • Tests are implemented.
  • Added code follows Coding Standards (use $ composer fix-cs).
  • PR is ready for a review.

@bdunogier bdunogier self-assigned this May 28, 2020
src/API/QueryFieldLocationService.php Outdated Show resolved Hide resolved
src/API/QueryFieldLocationService.php Outdated Show resolved Hide resolved
src/API/QueryFieldService.php Outdated Show resolved Hide resolved
src/API/QueryFieldService.php Outdated Show resolved Hide resolved
src/API/QueryFieldService.php Outdated Show resolved Hide resolved
src/API/QueryFieldServiceInterface.php Outdated Show resolved Hide resolved
src/API/QueryFieldServiceInterface.php Outdated Show resolved Hide resolved
src/API/QueryFieldServiceInterface.php Outdated Show resolved Hide resolved
src/API/QueryFieldServiceInterface.php Outdated Show resolved Hide resolved
src/API/QueryFieldService.php Outdated Show resolved Hide resolved
@bdunogier bdunogier force-pushed the ezp31659-results_for_location branch 2 times, most recently from b86885e to abd1f4f Compare June 2, 2020 18:09
@bdunogier bdunogier force-pushed the ezp31659-results_for_location branch 2 times, most recently from d7f318f to cb336e4 Compare December 21, 2020 14:40
@bdunogier bdunogier marked this pull request as ready for review December 21, 2020 14:43
src/Controller/QueryFieldRestController.php Outdated Show resolved Hide resolved
$items = $this->queryFieldService->loadContentItemsSlice($content, $fieldDefinitionIdentifier, $offset, $limit);
$location = null;
$content = $this->contentService->loadContent($contentId, null, $versionNumber);
if ($limit === -1 || !method_exists($this->queryFieldService, 'loadContentItemsSlice')) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if ($limit === -1 || !method_exists($this->queryFieldService, 'loadContentItemsSlice')) {
if ($limit === -1) {

It's guaranteed that loadContentItemsSlicea exists as you expect an \EzSystems\EzPlatformQueryFieldType\API\QueryFieldService (final class) as QueryFieldRestController construct arg.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, indeed (it was a backward compatibility check when pagination was introduced).

But that change is not part of that pull-request, it is just moved around :)

src/API/QueryFieldService.php Outdated Show resolved Hide resolved
src/API/QueryFieldService.php Show resolved Hide resolved
src/API/QueryFieldServiceInterface.php Outdated Show resolved Hide resolved
src/eZ/ContentView/QueryResultsInjector.php Outdated Show resolved Hide resolved
Copy link
Member Author

@bdunogier bdunogier left a comment

Choose a reason for hiding this comment

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

I'm done fixing your comments. I'll push the code tomorrow morning, as I worked on the v3 sub-branch for the feature... :)

src/Controller/QueryFieldRestController.php Outdated Show resolved Hide resolved
$items = $this->queryFieldService->loadContentItemsSlice($content, $fieldDefinitionIdentifier, $offset, $limit);
$location = null;
$content = $this->contentService->loadContent($contentId, null, $versionNumber);
if ($limit === -1 || !method_exists($this->queryFieldService, 'loadContentItemsSlice')) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Well, indeed (it was a backward compatibility check when pagination was introduced).

But that change is not part of that pull-request, it is just moved around :)

src/API/QueryFieldServiceInterface.php Outdated Show resolved Hide resolved
@bdunogier
Copy link
Member Author

I think that's it, as long as Travis agrees.

@bdunogier
Copy link
Member Author

Ping @ezsystems/php-dev-team.

@bdunogier bdunogier force-pushed the ezp31659-results_for_location branch from c194b75 to 7e0aa71 Compare January 11, 2021 08:43
@bdunogier
Copy link
Member Author

All review comments have been fixed, can we move on with this ?

src/API/QueryFieldService.php Outdated Show resolved Hide resolved
src/API/QueryFieldServiceInterface.php Outdated Show resolved Hide resolved
src/Controller/QueryFieldRestController.php Outdated Show resolved Hide resolved
src/eZ/ContentView/QueryResultsInjector.php Outdated Show resolved Hide resolved
@bdunogier bdunogier force-pushed the ezp31659-results_for_location branch from 7e0aa71 to 1482904 Compare January 12, 2021 10:48
@bdunogier
Copy link
Member Author

All fixed @Steveb-p (rebased into the correct commits).

Copy link
Contributor

@Steveb-p Steveb-p left a comment

Choose a reason for hiding this comment

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

Apart from one minor comment, LGTM ;)

Comment on lines 16 to 28
/**
* Returns the query results for the given location.
*/
public function loadContentItemsForLocation(Location $location, string $fieldDefinitionIdentifier): iterable;

/**
* Returns a slice of the query results for the given location.
*/
public function loadContentItemsSliceForLocation(Location $location, string $fieldDefinitionIdentifier, int $offset, int $limit): iterable;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could those methods receive @return notes? I've seen them in concrete implementation, and I think they're even more important to be added here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Bertrand Dunogier added 5 commits January 12, 2021 17:24
…ation with REST

An extra 'location' query parameter can be provided with a location href. If provided, that particular location will be used instead of the main one.
@bdunogier bdunogier force-pushed the ezp31659-results_for_location branch from 1482904 to 9bcdc32 Compare January 12, 2021 16:24
@bdunogier
Copy link
Member Author

Updated again, and CS warning fixed.

@lserwatka lserwatka merged commit e3de453 into master Jan 13, 2021
@lserwatka lserwatka deleted the ezp31659-results_for_location branch January 13, 2021 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants