forked from FriendsOfSymfony/FOSElasticaBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransformedPaginatorAdapter.php
36 lines (30 loc) · 1.12 KB
/
TransformedPaginatorAdapter.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
namespace FOS\ElasticaBundle\Paginator;
use FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface;
use Elastica\SearchableInterface;
use Elastica\Query;
/**
* Allows pagination of \Elastica\Query.
*/
class TransformedPaginatorAdapter extends RawPaginatorAdapter
{
private $transformer;
/**
* @param SearchableInterface $searchable the object to search in
* @param Query $query the query to search
* @param array $options
* @param ElasticaToModelTransformerInterface $transformer the transformer for fetching the results
*/
public function __construct(SearchableInterface $searchable, Query $query, array $options = array(), ElasticaToModelTransformerInterface $transformer)
{
parent::__construct($searchable, $query, $options);
$this->transformer = $transformer;
}
/**
* {@inheritDoc}
*/
public function getResults($offset, $length)
{
return new TransformedPartialResults($this->getElasticaResults($offset, $length), $this->transformer);
}
}