| @@ 21-45 (lines=25) @@ | ||
| 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, array $options, ElasticaToModelTransformerInterface $transformer) |
|
| 31 | { |
|
| 32 | parent::__construct($searchable, $query, $options); |
|
| 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 ElasticaToModelTransformerInterface $transformer the transformer for fetching the results |
|
| 29 | */ |
|
| 30 | public function __construct(SearchableInterface $searchable, Query $query, array $options, ElasticaToModelTransformerInterface $transformer) |
|
| 31 | { |
|
| 32 | parent::__construct($searchable, $query, $options); |
|
| 33 | ||
| 34 | $this->transformer = $transformer; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * {@inheritdoc} |
|
| 39 | */ |
|
| 40 | public function getResults($offset, $length) |
|
| 41 | { |
|
| 42 | return new TransformedPartialResults($this->getElasticaResults($offset, $length), $this->transformer); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||