1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FOSElasticaBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FOS\ElasticaBundle\Paginator; |
13
|
|
|
|
14
|
|
|
use Pagerfanta\Adapter\AdapterInterface; |
15
|
|
|
|
16
|
|
|
class FantaPaginatorAdapter implements AdapterInterface |
17
|
|
|
{ |
18
|
|
|
private $adapter; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param \FOS\ElasticaBundle\Paginator\PaginatorAdapterInterface $adapter |
22
|
|
|
*/ |
23
|
6 |
|
public function __construct(PaginatorAdapterInterface $adapter) |
24
|
|
|
{ |
25
|
6 |
|
$this->adapter = $adapter; |
26
|
6 |
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Returns the number of results. |
30
|
|
|
* |
31
|
|
|
* @return int The number of results |
32
|
|
|
*/ |
33
|
1 |
|
public function getNbResults() |
34
|
|
|
{ |
35
|
1 |
|
return $this->adapter->getTotalHits(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Returns Aggregations. |
40
|
|
|
* |
41
|
|
|
* @return mixed |
42
|
|
|
* |
43
|
|
|
* @api |
44
|
|
|
*/ |
45
|
1 |
|
public function getAggregations() |
46
|
|
|
{ |
47
|
1 |
|
return $this->adapter->getAggregations(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Returns Suggestions. |
52
|
|
|
* |
53
|
|
|
* @return mixed |
54
|
|
|
* |
55
|
|
|
* @api |
56
|
|
|
*/ |
57
|
1 |
|
public function getSuggests() |
58
|
|
|
{ |
59
|
1 |
|
return $this->adapter->getSuggests(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns a slice of the results. |
64
|
|
|
* |
65
|
|
|
* @param int $offset The offset |
66
|
|
|
* @param int $length The length |
67
|
|
|
* |
68
|
|
|
* @return array|\Traversable The slice |
69
|
|
|
*/ |
70
|
1 |
|
public function getSlice($offset, $length) |
71
|
|
|
{ |
72
|
1 |
|
return $this->adapter->getResults($offset, $length)->toArray(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
1 |
|
public function getMaxScore() |
79
|
|
|
{ |
80
|
1 |
|
return $this->adapter->getMaxScore(); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|