@@ 21-44 (lines=24) @@ | ||
18 | /** |
|
19 | * Allows pagination of \Elastica\Query. |
|
20 | */ |
|
21 | class HybridPaginatorAdapter extends RawPaginatorAdapter |
|
22 | { |
|
23 | private $transformer; |
|
24 | ||
25 | /** |
|
26 | * @param SearchableInterface $searchable the object to search in |
|
27 | * @param Query $query the query to search |
|
28 | * @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results |
|
29 | */ |
|
30 | public function __construct(SearchableInterface $searchable, Query $query, ElasticaToModelTransformerInterface $transformer) |
|
31 | { |
|
32 | parent::__construct($searchable, $query); |
|
33 | ||
34 | $this->transformer = $transformer; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * {@inheritdoc} |
|
39 | */ |
|
40 | public function getResults($offset, $length) |
|
41 | { |
|
42 | return new HybridPartialResults($this->getElasticaResults($offset, $length), $this->transformer); |
|
43 | } |
|
44 | } |
|
45 |
@@ 21-45 (lines=25) @@ | ||
18 | /** |
|
19 | * Allows pagination of \Elastica\Query. |
|
20 | */ |
|
21 | class TransformedPaginatorAdapter extends RawPaginatorAdapter |
|
22 | { |
|
23 | private $transformer; |
|
24 | ||
25 | /** |
|
26 | * @param SearchableInterface $searchable the object to search in |
|
27 | * @param Query $query the query to search |
|
28 | * @param array $options |
|
29 | * @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results |
|
30 | */ |
|
31 | public function __construct(SearchableInterface $searchable, Query $query, array $options, ElasticaToModelTransformerInterface $transformer) |
|
32 | { |
|
33 | parent::__construct($searchable, $query, $options); |
|
34 | ||
35 | $this->transformer = $transformer; |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * {@inheritdoc} |
|
40 | */ |
|
41 | public function getResults($offset, $length) |
|
42 | { |
|
43 | return new TransformedPartialResults($this->getElasticaResults($offset, $length), $this->transformer); |
|
44 | } |
|
45 | } |
|
46 |