1 | <?php |
||
16 | class ElasticSearchAdapter implements FinderAdapterInterface |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * |
||
21 | * @var QueryBuilder |
||
22 | */ |
||
23 | private $qb = null; |
||
24 | private $models = []; |
||
25 | |||
26 | 30 | public function __construct($models) |
|
32 | |||
33 | 5 | public function count(CriteriaInterface $criteria) |
|
38 | |||
39 | 22 | public function findMany(CriteriaInterface $criteria, $fields = array()) |
|
44 | |||
45 | 5 | public function findOne(CriteriaInterface $criteria, $fields = array()) |
|
46 | { |
||
47 | 5 | $this->prepare($criteria, $fields); |
|
48 | 5 | $data = (new ElasticSearchCursor($this->qb))->current(); |
|
49 | 5 | if (false === $data) |
|
50 | { |
||
51 | return null; |
||
52 | } |
||
53 | 5 | return $data; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * |
||
58 | * @internal Used for debugging purposes, should not be used for any manipulations! |
||
59 | * @return QueryBuilder |
||
60 | */ |
||
61 | 1 | public function getQueryBuilder() |
|
65 | |||
66 | 27 | private function prepare(CriteriaInterface $criteria, $fields) |
|
82 | |||
83 | 30 | private function ensure(&$criteria) |
|
91 | |||
92 | } |
||
93 |