-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSearchHandlerAdapter.php
36 lines (28 loc) · 1.01 KB
/
SearchHandlerAdapter.php
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\IbexaSearchExtra\Core\Pagination\Pagerfanta;
use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
use Ibexa\Contracts\Core\Search\Handler as SearchHandlerInterface;
class SearchHandlerAdapter extends BaseAdapter
{
private SearchHandlerInterface $searchHandler;
public function __construct(Query $query, SearchHandlerInterface $searchHandler)
{
parent::__construct($query);
$this->searchHandler = $searchHandler;
}
/**
* {@inheritDoc}
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
protected function executeQuery(Query $query): SearchResult
{
if ($query instanceof LocationQuery) {
return $this->searchHandler->findLocations($query);
}
return $this->searchHandler->findContent($query);
}
}