1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Lug package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Lug\Component\Grid\DataSource\Doctrine\ORM; |
13
|
|
|
|
14
|
|
|
use Doctrine\ORM\Query\Expr; |
15
|
|
|
use Lug\Component\Grid\DataSource\ExpressionBuilderInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author GeLo <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class ExpressionBuilder implements ExpressionBuilderInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var Expr |
24
|
|
|
*/ |
25
|
|
|
private $expr; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param Expr $expr |
29
|
|
|
*/ |
30
|
21 |
|
public function __construct(Expr $expr) |
31
|
|
|
{ |
32
|
21 |
|
$this->expr = $expr; |
33
|
21 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* {@inheritdoc} |
37
|
|
|
*/ |
38
|
1 |
|
public function andX(array $expressions) |
39
|
|
|
{ |
40
|
1 |
|
return call_user_func_array([$this->expr, 'andX'], $expressions); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
1 |
|
public function orX(array $expressions) |
47
|
|
|
{ |
48
|
1 |
|
return call_user_func_array([$this->expr, 'orX'], $expressions); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
1 |
|
public function asc($x) |
55
|
|
|
{ |
56
|
1 |
|
return $this->expr->asc($x); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
1 |
|
public function desc($x) |
63
|
|
|
{ |
64
|
1 |
|
return $this->expr->desc($x); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritdoc} |
69
|
|
|
*/ |
70
|
1 |
|
public function eq($x, $y) |
71
|
|
|
{ |
72
|
1 |
|
return $this->expr->eq($x, $y); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
1 |
|
public function neq($x, $y) |
79
|
|
|
{ |
80
|
1 |
|
return $this->expr->neq($x, $y); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
1 |
|
public function lt($x, $y) |
87
|
|
|
{ |
88
|
1 |
|
return $this->expr->lt($x, $y); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* {@inheritdoc} |
93
|
|
|
*/ |
94
|
1 |
|
public function lte($x, $y) |
95
|
|
|
{ |
96
|
1 |
|
return $this->expr->lte($x, $y); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
1 |
|
public function gt($x, $y) |
103
|
|
|
{ |
104
|
1 |
|
return $this->expr->gt($x, $y); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* {@inheritdoc} |
109
|
|
|
*/ |
110
|
1 |
|
public function gte($x, $y) |
111
|
|
|
{ |
112
|
1 |
|
return $this->expr->gte($x, $y); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
*/ |
118
|
1 |
|
public function exists($x) |
119
|
|
|
{ |
120
|
1 |
|
return $this->expr->exists($x); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* {@inheritdoc} |
125
|
|
|
*/ |
126
|
1 |
|
public function in($x, $y) |
127
|
|
|
{ |
128
|
1 |
|
return $this->expr->in($x, $y); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* {@inheritdoc} |
133
|
|
|
*/ |
134
|
1 |
|
public function notIn($x, $y) |
135
|
|
|
{ |
136
|
1 |
|
return $this->expr->notIn($x, $y); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* {@inheritdoc} |
141
|
|
|
*/ |
142
|
1 |
|
public function isNull($x) |
143
|
|
|
{ |
144
|
1 |
|
return $this->expr->isNull($x); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* {@inheritdoc} |
149
|
|
|
*/ |
150
|
1 |
|
public function isNotNull($x) |
151
|
|
|
{ |
152
|
1 |
|
return $this->expr->isNotNull($x); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* {@inheritdoc} |
157
|
|
|
*/ |
158
|
1 |
|
public function like($x, $y) |
159
|
|
|
{ |
160
|
1 |
|
return $this->expr->like($x, $y); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* {@inheritdoc} |
165
|
|
|
*/ |
166
|
1 |
|
public function notLike($x, $y) |
167
|
|
|
{ |
168
|
1 |
|
return $this->expr->notLike($x, $y); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* {@inheritdoc} |
173
|
|
|
*/ |
174
|
2 |
|
public function between($value, $x, $y) |
175
|
|
|
{ |
176
|
2 |
|
return $this->expr->between($value, $x, $y); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* {@inheritdoc} |
181
|
|
|
*/ |
182
|
1 |
|
public function notBetween($value, $x, $y) |
183
|
|
|
{ |
184
|
1 |
|
return $this->expr->not($this->between($value, $x, $y)); |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|