1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* @copyright 2014 Mautic Contributors. All rights reserved |
5
|
|
|
* @author Mautic |
6
|
|
|
* |
7
|
|
|
* @link http://mautic.org |
8
|
|
|
* |
9
|
|
|
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Mautic\LeadBundle\Event; |
13
|
|
|
|
14
|
|
|
use Doctrine\DBAL\Query\QueryBuilder; |
15
|
|
|
use Mautic\CoreBundle\Event\CommonEvent; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class LeadBuildSearchEvent. |
19
|
|
|
*/ |
20
|
|
|
class LeadBuildSearchEvent extends CommonEvent |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $string; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var QueryBuilder |
29
|
|
|
*/ |
30
|
|
|
protected $queryBuilder; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $alias; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $command; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $subQuery; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var bool |
49
|
|
|
*/ |
50
|
|
|
protected $negate; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var bool |
54
|
|
|
*/ |
55
|
|
|
protected $isSearchDone; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var bool |
59
|
|
|
*/ |
60
|
|
|
protected $returnParameters; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var bool |
64
|
|
|
*/ |
65
|
|
|
protected $strict; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var array |
69
|
|
|
*/ |
70
|
|
|
protected $parameters; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $string |
74
|
|
|
* @param string $command |
75
|
|
|
* @param string $alias |
76
|
|
|
* @param string $negate |
77
|
|
|
*/ |
78
|
|
|
public function __construct($string, $command, $alias, $negate, QueryBuilder $queryBuilder) |
79
|
|
|
{ |
80
|
|
|
$this->string = $string; |
81
|
|
|
$this->command = $command; |
82
|
|
|
$this->alias = $alias; |
83
|
|
|
$this->negate = $negate; |
|
|
|
|
84
|
|
|
$this->queryBuilder = $queryBuilder; |
85
|
|
|
$this->subQuery = ''; |
86
|
|
|
$this->isSearchDone = false; |
87
|
|
|
$this->strict = false; |
88
|
|
|
$this->returnParameters = false; |
89
|
|
|
$this->parameters = []; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function getString() |
96
|
|
|
{ |
97
|
|
|
return $this->string; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return string |
102
|
|
|
*/ |
103
|
|
|
public function getCommand() |
104
|
|
|
{ |
105
|
|
|
return $this->command; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getAlias() |
112
|
|
|
{ |
113
|
|
|
return $this->alias; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return bool |
118
|
|
|
*/ |
119
|
|
|
public function isNegation() |
120
|
|
|
{ |
121
|
|
|
return $this->negate; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return QueryBuilder |
126
|
|
|
*/ |
127
|
|
|
public function getQueryBuilder() |
128
|
|
|
{ |
129
|
|
|
return $this->queryBuilder; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param bool $status |
134
|
|
|
*/ |
135
|
|
|
public function setSearchStatus($status) |
136
|
|
|
{ |
137
|
|
|
$this->isSearchDone = $status; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param string $query |
142
|
|
|
*/ |
143
|
|
|
public function setSubQuery($query) |
144
|
|
|
{ |
145
|
|
|
$this->subQuery = $query; |
146
|
|
|
|
147
|
|
|
$this->setSearchStatus(true); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return bool |
152
|
|
|
*/ |
153
|
|
|
public function isSearchDone() |
154
|
|
|
{ |
155
|
|
|
return $this->isSearchDone; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return string |
160
|
|
|
*/ |
161
|
|
|
public function getSubQuery() |
162
|
|
|
{ |
163
|
|
|
return $this->subQuery; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @param array $string |
168
|
|
|
*/ |
169
|
|
|
public function setString($string) |
170
|
|
|
{ |
171
|
|
|
$this->string = $string; |
|
|
|
|
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return bool |
176
|
|
|
*/ |
177
|
|
|
public function getStrict() |
178
|
|
|
{ |
179
|
|
|
return $this->strict; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param bool $val |
184
|
|
|
*/ |
185
|
|
|
public function setStrict($val) |
186
|
|
|
{ |
187
|
|
|
$this->strict = $val; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return bool |
192
|
|
|
*/ |
193
|
|
|
public function getReturnParameters() |
194
|
|
|
{ |
195
|
|
|
return $this->returnParameters; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param bool $val |
200
|
|
|
*/ |
201
|
|
|
public function setReturnParameters($val) |
202
|
|
|
{ |
203
|
|
|
$this->returnParameters = $val; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return array |
208
|
|
|
*/ |
209
|
|
|
public function getParameters() |
210
|
|
|
{ |
211
|
|
|
return $this->parameters; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @param array $val |
216
|
|
|
*/ |
217
|
|
|
public function setParameters($val) |
218
|
|
|
{ |
219
|
|
|
$this->parameters = $val; |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.