Skip to content

Commit

Permalink
EZP-31415: Impl. Sibling Criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Feb 27, 2020
1 parent 4fb3b00 commit ce46385
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 3 deletions.
8 changes: 8 additions & 0 deletions eZ/Publish/API/Repository/Tests/SearchServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,14 @@ public function getContentQuerySearches()
],
$fixtureDir . 'Visibility.php',
],
[
[
'query' => new Criterion\Sibling(58, 1),
'sortClauses' => [new SortClause\ContentId()],
'limit' => 50,
],
$fixtureDir . 'Sibling.php',
],
];
}

Expand Down
59 changes: 59 additions & 0 deletions eZ/Publish/API/Repository/Tests/_fixtures/Legacy/Sibling.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

return eZ\Publish\API\Repository\Values\Content\Search\SearchResult::__set_state(array(
'facets' =>
array(
),
'searchHits' =>
array(
0 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 4,
'title' => 'Users',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
1 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 41,
'title' => 'Media',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
2 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 45,
'title' => 'Setup',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
3 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 57,
'title' => 'Home',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
),
'spellSuggestion' => null,
'time' => 1,
'timedOut' => null,
'maxScore' => null,
'totalCount' => 4,
));
59 changes: 59 additions & 0 deletions eZ/Publish/API/Repository/Tests/_fixtures/Solr/Sibling.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

return eZ\Publish\API\Repository\Values\Content\Search\SearchResult::__set_state(array(
'facets' =>
array(
),
'searchHits' =>
array(
0 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 4,
'title' => 'Users',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
1 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 41,
'title' => 'Media',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
2 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 45,
'title' => 'Setup',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
3 =>
eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state(array(
'valueObject' =>
array(
'id' => 57,
'title' => 'Home',
),
'score' => null,
'index' => null,
'highlight' => null,
)),
),
'spellSuggestion' => null,
'time' => 1,
'timedOut' => null,
'maxScore' => null,
'totalCount' => 4,
));
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@
*/
class Sibling extends AggregateCriterion
{
public function __construct(Location $location)
public function __construct(int $id, int $parentLocationId)
{
$criteria = new LogicalAnd([
new ParentLocationId($location->parentLocationId),
new ParentLocationId($parentLocationId),
new LogicalNot(
new LocationId($location->id)
new LocationId($id)
),
]);

parent::__construct($criteria);
}

public static function fromLocation(Location $location): self
{
return new self($location->id, $location->parentLocationId);
}
}

0 comments on commit ce46385

Please sign in to comment.