-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSearchAdapter.php
More file actions
36 lines (28 loc) · 950 Bytes
/
SearchAdapter.php
File metadata and controls
36 lines (28 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
namespace Netgen\EzPlatformSearchExtra\Core\Pagination\Pagerfanta;
use eZ\Publish\API\Repository\SearchService;
use eZ\Publish\API\Repository\Values\Content\LocationQuery;
use eZ\Publish\API\Repository\Values\Content\Query;
use eZ\Publish\API\Repository\Values\Content\Search\SearchResult;
class SearchAdapter extends BaseAdapter
{
private $searchService;
public function __construct(Query $query, SearchService $searchService)
{
parent::__construct($query);
$this->searchService = $searchService;
}
/**
* {@inheritDoc}
*
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
*/
protected function executeQuery(Query $query): SearchResult
{
if ($query instanceof LocationQuery) {
return $this->searchService->findLocations($query);
}
return $this->searchService->findContent($query);
}
}