1 | <?php |
||
18 | class CriteriaService implements ServiceInterface |
||
19 | { |
||
20 | /** |
||
21 | * Contains application instance. |
||
22 | * |
||
23 | * @var Application |
||
24 | */ |
||
25 | protected $app; |
||
26 | |||
27 | /** |
||
28 | * Contains repository instance. |
||
29 | * |
||
30 | * @var Repository |
||
31 | */ |
||
32 | protected $repository; |
||
33 | |||
34 | /** |
||
35 | * Contains stack of criterias. |
||
36 | * |
||
37 | * @var Collection |
||
38 | */ |
||
39 | protected $stack; |
||
40 | |||
41 | /** |
||
42 | * Create a new criteria service instance. |
||
43 | * |
||
44 | * @param Application $app |
||
45 | * @param Repository $repository |
||
46 | */ |
||
47 | 120 | public function __construct(Application $app, Repository $repository) |
|
53 | |||
54 | /** |
||
55 | * Add criteria to stack. |
||
56 | * |
||
57 | * @param CriteriaInterface $criteria |
||
58 | * |
||
59 | * @return $this |
||
60 | */ |
||
61 | 6 | public function addCriteria(CriteriaInterface $criteria) |
|
67 | |||
68 | /** |
||
69 | * Determinate if service stack has any criteria. |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | 84 | public function hasCriteria() |
|
77 | |||
78 | /** |
||
79 | * Returns all criteria from stack. |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | 4 | public function getCriterias() |
|
87 | |||
88 | /** |
||
89 | * Remove one or all criteria from stack. |
||
90 | * |
||
91 | * @param string $criteriaName |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | 2 | public function removeCriteria($criteriaName = '') |
|
109 | |||
110 | /** |
||
111 | * Execute an criterias from the stack on given query builder. |
||
112 | * |
||
113 | * @param Builder $query |
||
114 | * |
||
115 | * @return Builder |
||
116 | */ |
||
117 | public function executeOn(Builder $query) |
||
125 | } |
||
126 |