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; |
13
|
|
|
|
14
|
|
|
use FOS\ElasticaBundle\Finder\PaginatedFinderInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Richard Miller <[email protected]> |
18
|
|
|
* |
19
|
|
|
* Basic repository to be extended to hold custom queries to be run |
20
|
|
|
* in the finder |
21
|
|
|
*/ |
22
|
|
|
class Repository |
23
|
|
|
{ |
24
|
|
|
/** @var PaginatedFinderInterface */ |
25
|
|
|
protected $finder; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param PaginatedFinderInterface $finder |
29
|
|
|
*/ |
30
|
10 |
|
public function __construct(PaginatedFinderInterface $finder) |
31
|
|
|
{ |
32
|
10 |
|
$this->finder = $finder; |
33
|
10 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param mixed $query |
37
|
|
|
* @param int $limit |
38
|
|
|
* @param array $options |
39
|
|
|
* |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
2 |
|
public function find($query, $limit = null, $options = []) |
43
|
|
|
{ |
44
|
2 |
|
return $this->finder->find($query, $limit, $options); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param mixed $query |
49
|
|
|
* @param int $limit |
50
|
|
|
* @param array $options |
51
|
|
|
* |
52
|
|
|
* @return mixed |
53
|
|
|
*/ |
54
|
1 |
|
public function findHybrid($query, $limit = null, $options = []) |
55
|
|
|
{ |
56
|
1 |
|
return $this->finder->findHybrid($query, $limit, $options); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param mixed $query |
61
|
|
|
* @param array $options |
62
|
|
|
* |
63
|
|
|
* @return \Pagerfanta\Pagerfanta |
64
|
|
|
*/ |
65
|
1 |
|
public function findPaginated($query, $options = []) |
66
|
|
|
{ |
67
|
1 |
|
return $this->finder->findPaginated($query, $options); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param string $query |
72
|
|
|
* @param array $options |
73
|
|
|
* |
74
|
|
|
* @return Paginator\PaginatorAdapterInterface |
75
|
|
|
*/ |
76
|
1 |
|
public function createPaginatorAdapter($query, $options = []) |
77
|
|
|
{ |
78
|
1 |
|
return $this->finder->createPaginatorAdapter($query, $options); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param mixed $query |
83
|
|
|
* |
84
|
|
|
* @return Paginator\HybridPaginatorAdapter |
85
|
|
|
*/ |
86
|
1 |
|
public function createHybridPaginatorAdapter($query) |
87
|
|
|
{ |
88
|
1 |
|
return $this->finder->createHybridPaginatorAdapter($query); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|