Skip to content

Commit

Permalink
Readability improvements in QueryResultsInjector
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertrand Dunogier committed Jan 12, 2021
1 parent ce7cda8 commit 1482904
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/eZ/ContentView/QueryResultsInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@ public function injectQueryResults(FilterViewParametersEvent $event)
private function buildResults(FilterViewParametersEvent $event): iterable
{
$view = $event->getView();
if ($view instanceof LocationValueView) {
$location = $view->getLocation();
}

if ($view instanceof ContentValueView) {
$content = $view->getContent();
}
$location = $view instanceof LocationValueView ? $location = $view->getLocation() : null;
$content = $view instanceof ContentValueView ? $view->getContent() : null;

$viewParameters = $event->getBuilderParameters();
$fieldDefinitionIdentifier = $viewParameters['queryFieldDefinitionIdentifier'];
Expand Down Expand Up @@ -118,7 +113,7 @@ private function buildResults(FilterViewParametersEvent $event): iterable
$pageParam = sprintf('%s_page', $fieldDefinitionIdentifier);
$page = isset($request) ? $request->get($pageParam, 1) : 1;

if (isset($location)) {
if ($location !== null) {
$pager = new Pagerfanta(
new QueryResultsWithLocationPagerFantaAdapter(
$this->queryFieldService, $location, $fieldDefinitionIdentifier
Expand All @@ -137,12 +132,12 @@ private function buildResults(FilterViewParametersEvent $event): iterable

return $pager;
} else {
if ($this->queryFieldService instanceof QueryFieldLocationService && isset($location)) {
if ($this->queryFieldService instanceof QueryFieldLocationService && $location !== null) {
return $this->queryFieldService->loadContentItemsForLocation(
$location,
$fieldDefinitionIdentifier
);
} elseif (isset($content)) {
} elseif ($content !== null) {
return $this->queryFieldService->loadContentItems(
$content,
$fieldDefinitionIdentifier
Expand Down

0 comments on commit 1482904

Please sign in to comment.