Completed
Push — master ( a54493...36663b )
by Fabien
05:49
created
Classes/Persistence/PagerObjectFactory.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -23,48 +23,48 @@
 block discarded – undo
23 23
 class PagerObjectFactory implements SingletonInterface
24 24
 {
25 25
 
26
-    /**
27
-     * Gets a singleton instance of this class.
28
-     *
29
-     * @return \Fab\Vidi\Persistence\PagerObjectFactory
30
-     */
31
-    static public function getInstance()
32
-    {
33
-        return GeneralUtility::makeInstance('Fab\Vidi\Persistence\PagerObjectFactory');
34
-    }
26
+	/**
27
+	 * Gets a singleton instance of this class.
28
+	 *
29
+	 * @return \Fab\Vidi\Persistence\PagerObjectFactory
30
+	 */
31
+	static public function getInstance()
32
+	{
33
+		return GeneralUtility::makeInstance('Fab\Vidi\Persistence\PagerObjectFactory');
34
+	}
35 35
 
36
-    /**
37
-     * Returns a pager object.
38
-     *
39
-     * @return \Fab\Vidi\Persistence\Pager
40
-     */
41
-    public function getPager()
42
-    {
36
+	/**
37
+	 * Returns a pager object.
38
+	 *
39
+	 * @return \Fab\Vidi\Persistence\Pager
40
+	 */
41
+	public function getPager()
42
+	{
43 43
 
44
-        /** @var $pager \Fab\Vidi\Persistence\Pager */
45
-        $pager = GeneralUtility::makeInstance('Fab\Vidi\Persistence\Pager');
44
+		/** @var $pager \Fab\Vidi\Persistence\Pager */
45
+		$pager = GeneralUtility::makeInstance('Fab\Vidi\Persistence\Pager');
46 46
 
47
-        // Set items per page
48
-        if (GeneralUtility::_GET('length') !== NULL) {
49
-            $limit = (int)GeneralUtility::_GET('length');
50
-            $pager->setLimit($limit);
51
-        }
47
+		// Set items per page
48
+		if (GeneralUtility::_GET('length') !== NULL) {
49
+			$limit = (int)GeneralUtility::_GET('length');
50
+			$pager->setLimit($limit);
51
+		}
52 52
 
53
-        // Set offset
54
-        $offset = 0;
55
-        if (GeneralUtility::_GET('start') !== NULL) {
56
-            $offset = (int)GeneralUtility::_GET('start');
57
-        }
58
-        $pager->setOffset($offset);
53
+		// Set offset
54
+		$offset = 0;
55
+		if (GeneralUtility::_GET('start') !== NULL) {
56
+			$offset = (int)GeneralUtility::_GET('start');
57
+		}
58
+		$pager->setOffset($offset);
59 59
 
60
-        // set page
61
-        $page = 1;
62
-        if ($pager->getLimit() > 0) {
63
-            $page = round($pager->getOffset() / $pager->getLimit());
64
-        }
65
-        $pager->setPage($page);
60
+		// set page
61
+		$page = 1;
62
+		if ($pager->getLimit() > 0) {
63
+			$page = round($pager->getOffset() / $pager->getLimit());
64
+		}
65
+		$pager->setPage($page);
66 66
 
67
-        return $pager;
68
-    }
67
+		return $pager;
68
+	}
69 69
 
70 70
 }
Please login to merge, or discard this patch.
Classes/Persistence/ResultSetStorage.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -22,32 +22,32 @@
 block discarded – undo
22 22
 class ResultSetStorage implements SingletonInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $resultSets = array();
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $resultSets = array();
29 29
 
30
-    /**
31
-     * @param string $querySignature
32
-     * @return array
33
-     */
34
-    public function get($querySignature)
35
-    {
36
-        $resultSet = NULL;
37
-        if (isset($this->resultSets[$querySignature])) {
38
-            $resultSet = $this->resultSets[$querySignature];
39
-        }
40
-        return $resultSet;
41
-    }
30
+	/**
31
+	 * @param string $querySignature
32
+	 * @return array
33
+	 */
34
+	public function get($querySignature)
35
+	{
36
+		$resultSet = NULL;
37
+		if (isset($this->resultSets[$querySignature])) {
38
+			$resultSet = $this->resultSets[$querySignature];
39
+		}
40
+		return $resultSet;
41
+	}
42 42
 
43
-    /**
44
-     * @param $querySignature
45
-     * @param array $resultSet
46
-     * @internal param array $resultSets
47
-     */
48
-    public function set($querySignature, array $resultSet)
49
-    {
50
-        $this->resultSets[$querySignature] = $resultSet;
51
-    }
43
+	/**
44
+	 * @param $querySignature
45
+	 * @param array $resultSet
46
+	 * @internal param array $resultSets
47
+	 */
48
+	public function set($querySignature, array $resultSet)
49
+	{
50
+		$this->resultSets[$querySignature] = $resultSet;
51
+	}
52 52
 
53 53
 }
Please login to merge, or discard this patch.
Classes/Persistence/Order.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -20,45 +20,45 @@
 block discarded – undo
20 20
 class Order
21 21
 {
22 22
 
23
-    /**
24
-     * The orderings
25
-     *
26
-     * @var array
27
-     */
28
-    protected $orderings = array();
23
+	/**
24
+	 * The orderings
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected $orderings = array();
29 29
 
30
-    /**
31
-     * Constructs a new Order
32
-     *
33
-     * @para array $orders
34
-     * @param array $orders
35
-     */
36
-    public function __construct($orders = array())
37
-    {
38
-        foreach ($orders as $order => $direction) {
39
-            $this->addOrdering($order, $direction);
40
-        }
41
-    }
30
+	/**
31
+	 * Constructs a new Order
32
+	 *
33
+	 * @para array $orders
34
+	 * @param array $orders
35
+	 */
36
+	public function __construct($orders = array())
37
+	{
38
+		foreach ($orders as $order => $direction) {
39
+			$this->addOrdering($order, $direction);
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * Add ordering
45
-     *
46
-     * @param string $order The order
47
-     * @param string $direction ASC / DESC
48
-     * @return void
49
-     */
50
-    public function addOrdering($order, $direction)
51
-    {
52
-        $this->orderings[$order] = $direction;
53
-    }
43
+	/**
44
+	 * Add ordering
45
+	 *
46
+	 * @param string $order The order
47
+	 * @param string $direction ASC / DESC
48
+	 * @return void
49
+	 */
50
+	public function addOrdering($order, $direction)
51
+	{
52
+		$this->orderings[$order] = $direction;
53
+	}
54 54
 
55
-    /**
56
-     * Returns the order
57
-     *
58
-     * @return array The order
59
-     */
60
-    public function getOrderings()
61
-    {
62
-        return $this->orderings;
63
-    }
55
+	/**
56
+	 * Returns the order
57
+	 *
58
+	 * @return array The order
59
+	 */
60
+	public function getOrderings()
61
+	{
62
+		return $this->orderings;
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Classes/Persistence/QuerySettings.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@
 block discarded – undo
24 24
 class QuerySettings extends Typo3QuerySettings
25 25
 {
26 26
 
27
-    /**
28
-     * Flag if the storage page should be respected for the query.
29
-     *
30
-     * @var boolean
31
-     */
32
-    protected $respectStoragePage = FALSE;
27
+	/**
28
+	 * Flag if the storage page should be respected for the query.
29
+	 *
30
+	 * @var boolean
31
+	 */
32
+	protected $respectStoragePage = FALSE;
33 33
 
34
-    /**
35
-     * As long as we use a feature flag ignoreAllEnableFieldsInBe to determine the default behavior, the
36
-     * initializeObject is responsible for handling that.
37
-     */
38
-    public function initializeObject()
39
-    {
40
-        parent::initializeObject();
41
-    }
34
+	/**
35
+	 * As long as we use a feature flag ignoreAllEnableFieldsInBe to determine the default behavior, the
36
+	 * initializeObject is responsible for handling that.
37
+	 */
38
+	public function initializeObject()
39
+	{
40
+		parent::initializeObject();
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Classes/Persistence/Matcher.php 1 patch
Indentation   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -20,290 +20,290 @@
 block discarded – undo
20 20
 class Matcher
21 21
 {
22 22
 
23
-    /**
24
-     * The logical OR
25
-     */
26
-    const LOGICAL_OR = 'logicalOr';
27
-
28
-    /**
29
-     * The logical AND
30
-     */
31
-    const LOGICAL_AND = 'logicalAnd';
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    protected $dataType = '';
37
-
38
-    /**
39
-     * @var string
40
-     */
41
-    protected $searchTerm = '';
42
-
43
-    /**
44
-     * @var array
45
-     */
46
-    protected $supportedOperators = array('equals', 'in', 'like');
47
-
48
-    /**
49
-     * Associative values used for "equals" operator ($fieldName => $value)
50
-     *
51
-     * @var array
52
-     */
53
-    protected $equalsCriteria = array();
54
-
55
-    /**
56
-     * Associative values used for "in" operator ($fieldName => $value)
57
-     *
58
-     * @var array
59
-     */
60
-    protected $inCriteria = array();
61
-
62
-    /**
63
-     * Associative values used for "like" operator ($fieldName => $value)
64
-     *
65
-     * @var array
66
-     */
67
-    protected $likeCriteria = array();
68
-
69
-    /**
70
-     * Default logical operator for like.
71
-     *
72
-     * @var string
73
-     */
74
-    protected $defaultLogicalSeparator = self::LOGICAL_AND;
75
-
76
-    /**
77
-     * Default logical operator for equals.
78
-     *
79
-     * @var string
80
-     */
81
-    protected $logicalSeparatorForEquals = self::LOGICAL_AND;
82
-
83
-    /**
84
-     * Default logical operator for equals.
85
-     *
86
-     * @var string
87
-     */
88
-    protected $logicalSeparatorForIn = self::LOGICAL_AND;
89
-
90
-    /**
91
-     * Default logical operator for like.
92
-     *
93
-     * @var string
94
-     */
95
-    protected $logicalSeparatorForLike = self::LOGICAL_AND;
96
-
97
-    /**
98
-     * Default logical operator for the search term.
99
-     *
100
-     * @var string
101
-     */
102
-    protected $logicalSeparatorForSearchTerm = self::LOGICAL_OR;
103
-
104
-    /**
105
-     * Constructs a new Matcher
106
-     *
107
-     * @param array $matches associative array($field => $value)
108
-     * @param string $dataType which corresponds to an entry of the TCA (table name).
109
-     * @return \Fab\Vidi\Persistence\Matcher
110
-     */
111
-    public function __construct($matches = array(), $dataType = '')
112
-    {
113
-        $this->dataType = $dataType;
114
-        $this->matches = $matches;
115
-    }
116
-
117
-    /**
118
-     * @param string $searchTerm
119
-     * @return \Fab\Vidi\Persistence\Matcher
120
-     */
121
-    public function setSearchTerm($searchTerm)
122
-    {
123
-        $this->searchTerm = $searchTerm;
124
-        return $this;
125
-    }
126
-
127
-    /**
128
-     * @return string
129
-     */
130
-    public function getSearchTerm()
131
-    {
132
-        return $this->searchTerm;
133
-    }
134
-
135
-    /**
136
-     * @return array
137
-     */
138
-    public function getEqualsCriteria()
139
-    {
140
-        return $this->equalsCriteria;
141
-    }
142
-
143
-    /**
144
-     * @param $fieldNameAndPath
145
-     * @param $operand
146
-     * @return $this
147
-     */
148
-    public function equals($fieldNameAndPath, $operand)
149
-    {
150
-        $this->equalsCriteria[] = array('fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand);
151
-        return $this;
152
-    }
153
-
154
-    /**
155
-     * @return array
156
-     */
157
-    public function getLikeCriteria()
158
-    {
159
-        return $this->likeCriteria;
160
-    }
161
-
162
-    /**
163
-     * @param $fieldNameAndPath
164
-     * @param $operand
165
-     * @return $this
166
-     */
167
-    public function in($fieldNameAndPath, $operand)
168
-    {
169
-        $this->inCriteria[] = array('fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand);
170
-        return $this;
171
-    }
172
-
173
-    /**
174
-     * @return array
175
-     */
176
-    public function getInCriteria()
177
-    {
178
-        return $this->inCriteria;
179
-    }
180
-
181
-    /**
182
-     * @param $fieldNameAndPath
183
-     * @param $operand
184
-     * @param bool $addWildCard
185
-     * @return $this
186
-     */
187
-    public function like($fieldNameAndPath, $operand, $addWildCard = TRUE)
188
-    {
189
-        $wildCardSymbol = $addWildCard ? '%' : '';
190
-        $this->likeCriteria[] = array('fieldNameAndPath' => $fieldNameAndPath, 'operand' => $wildCardSymbol . $operand . $wildCardSymbol);
191
-        return $this;
192
-    }
193
-
194
-    /**
195
-     * @return array
196
-     */
197
-    public function getDefaultLogicalSeparator()
198
-    {
199
-        return $this->defaultLogicalSeparator;
200
-    }
201
-
202
-    /**
203
-     * @param string $defaultLogicalSeparator
204
-     * @return $this
205
-     */
206
-    public function setDefaultLogicalSeparator($defaultLogicalSeparator)
207
-    {
208
-        $this->defaultLogicalSeparator = $defaultLogicalSeparator;
209
-        return $this;
210
-    }
211
-
212
-    /**
213
-     * @return string
214
-     */
215
-    public function getLogicalSeparatorForEquals()
216
-    {
217
-        return $this->logicalSeparatorForEquals;
218
-    }
219
-
220
-    /**
221
-     * @param string $logicalSeparatorForEquals
222
-     * @return $this
223
-     */
224
-    public function setLogicalSeparatorForEquals($logicalSeparatorForEquals)
225
-    {
226
-        $this->logicalSeparatorForEquals = $logicalSeparatorForEquals;
227
-        return $this;
228
-    }
229
-
230
-    /**
231
-     * @return string
232
-     */
233
-    public function getLogicalSeparatorForIn()
234
-    {
235
-        return $this->logicalSeparatorForIn;
236
-    }
237
-
238
-    /**
239
-     * @param string $logicalSeparatorForIn
240
-     * @return $this
241
-     */
242
-    public function setLogicalSeparatorForIn($logicalSeparatorForIn)
243
-    {
244
-        $this->logicalSeparatorForIn = $logicalSeparatorForIn;
245
-        return $this;
246
-    }
247
-
248
-    /**
249
-     * @return string
250
-     */
251
-    public function getLogicalSeparatorForLike()
252
-    {
253
-        return $this->logicalSeparatorForLike;
254
-    }
255
-
256
-    /**
257
-     * @param string $logicalSeparatorForLike
258
-     * @return $this
259
-     */
260
-    public function setLogicalSeparatorForLike($logicalSeparatorForLike)
261
-    {
262
-        $this->logicalSeparatorForLike = $logicalSeparatorForLike;
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * @return string
268
-     */
269
-    public function getLogicalSeparatorForSearchTerm()
270
-    {
271
-        return $this->logicalSeparatorForSearchTerm;
272
-    }
273
-
274
-    /**
275
-     * @param string $logicalSeparatorForSearchTerm
276
-     * @return $this
277
-     */
278
-    public function setLogicalSeparatorForSearchTerm($logicalSeparatorForSearchTerm)
279
-    {
280
-        $this->logicalSeparatorForSearchTerm = $logicalSeparatorForSearchTerm;
281
-        return $this;
282
-    }
283
-
284
-    /**
285
-     * @return array
286
-     */
287
-    public function getSupportedOperators()
288
-    {
289
-        return $this->supportedOperators;
290
-    }
291
-
292
-    /**
293
-     * @return string
294
-     */
295
-    public function getDataType()
296
-    {
297
-        return $this->dataType;
298
-    }
299
-
300
-    /**
301
-     * @param string $dataType
302
-     * @return $this
303
-     */
304
-    public function setDataType($dataType)
305
-    {
306
-        $this->dataType = $dataType;
307
-        return $this;
308
-    }
23
+	/**
24
+	 * The logical OR
25
+	 */
26
+	const LOGICAL_OR = 'logicalOr';
27
+
28
+	/**
29
+	 * The logical AND
30
+	 */
31
+	const LOGICAL_AND = 'logicalAnd';
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	protected $dataType = '';
37
+
38
+	/**
39
+	 * @var string
40
+	 */
41
+	protected $searchTerm = '';
42
+
43
+	/**
44
+	 * @var array
45
+	 */
46
+	protected $supportedOperators = array('equals', 'in', 'like');
47
+
48
+	/**
49
+	 * Associative values used for "equals" operator ($fieldName => $value)
50
+	 *
51
+	 * @var array
52
+	 */
53
+	protected $equalsCriteria = array();
54
+
55
+	/**
56
+	 * Associative values used for "in" operator ($fieldName => $value)
57
+	 *
58
+	 * @var array
59
+	 */
60
+	protected $inCriteria = array();
61
+
62
+	/**
63
+	 * Associative values used for "like" operator ($fieldName => $value)
64
+	 *
65
+	 * @var array
66
+	 */
67
+	protected $likeCriteria = array();
68
+
69
+	/**
70
+	 * Default logical operator for like.
71
+	 *
72
+	 * @var string
73
+	 */
74
+	protected $defaultLogicalSeparator = self::LOGICAL_AND;
75
+
76
+	/**
77
+	 * Default logical operator for equals.
78
+	 *
79
+	 * @var string
80
+	 */
81
+	protected $logicalSeparatorForEquals = self::LOGICAL_AND;
82
+
83
+	/**
84
+	 * Default logical operator for equals.
85
+	 *
86
+	 * @var string
87
+	 */
88
+	protected $logicalSeparatorForIn = self::LOGICAL_AND;
89
+
90
+	/**
91
+	 * Default logical operator for like.
92
+	 *
93
+	 * @var string
94
+	 */
95
+	protected $logicalSeparatorForLike = self::LOGICAL_AND;
96
+
97
+	/**
98
+	 * Default logical operator for the search term.
99
+	 *
100
+	 * @var string
101
+	 */
102
+	protected $logicalSeparatorForSearchTerm = self::LOGICAL_OR;
103
+
104
+	/**
105
+	 * Constructs a new Matcher
106
+	 *
107
+	 * @param array $matches associative array($field => $value)
108
+	 * @param string $dataType which corresponds to an entry of the TCA (table name).
109
+	 * @return \Fab\Vidi\Persistence\Matcher
110
+	 */
111
+	public function __construct($matches = array(), $dataType = '')
112
+	{
113
+		$this->dataType = $dataType;
114
+		$this->matches = $matches;
115
+	}
116
+
117
+	/**
118
+	 * @param string $searchTerm
119
+	 * @return \Fab\Vidi\Persistence\Matcher
120
+	 */
121
+	public function setSearchTerm($searchTerm)
122
+	{
123
+		$this->searchTerm = $searchTerm;
124
+		return $this;
125
+	}
126
+
127
+	/**
128
+	 * @return string
129
+	 */
130
+	public function getSearchTerm()
131
+	{
132
+		return $this->searchTerm;
133
+	}
134
+
135
+	/**
136
+	 * @return array
137
+	 */
138
+	public function getEqualsCriteria()
139
+	{
140
+		return $this->equalsCriteria;
141
+	}
142
+
143
+	/**
144
+	 * @param $fieldNameAndPath
145
+	 * @param $operand
146
+	 * @return $this
147
+	 */
148
+	public function equals($fieldNameAndPath, $operand)
149
+	{
150
+		$this->equalsCriteria[] = array('fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand);
151
+		return $this;
152
+	}
153
+
154
+	/**
155
+	 * @return array
156
+	 */
157
+	public function getLikeCriteria()
158
+	{
159
+		return $this->likeCriteria;
160
+	}
161
+
162
+	/**
163
+	 * @param $fieldNameAndPath
164
+	 * @param $operand
165
+	 * @return $this
166
+	 */
167
+	public function in($fieldNameAndPath, $operand)
168
+	{
169
+		$this->inCriteria[] = array('fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand);
170
+		return $this;
171
+	}
172
+
173
+	/**
174
+	 * @return array
175
+	 */
176
+	public function getInCriteria()
177
+	{
178
+		return $this->inCriteria;
179
+	}
180
+
181
+	/**
182
+	 * @param $fieldNameAndPath
183
+	 * @param $operand
184
+	 * @param bool $addWildCard
185
+	 * @return $this
186
+	 */
187
+	public function like($fieldNameAndPath, $operand, $addWildCard = TRUE)
188
+	{
189
+		$wildCardSymbol = $addWildCard ? '%' : '';
190
+		$this->likeCriteria[] = array('fieldNameAndPath' => $fieldNameAndPath, 'operand' => $wildCardSymbol . $operand . $wildCardSymbol);
191
+		return $this;
192
+	}
193
+
194
+	/**
195
+	 * @return array
196
+	 */
197
+	public function getDefaultLogicalSeparator()
198
+	{
199
+		return $this->defaultLogicalSeparator;
200
+	}
201
+
202
+	/**
203
+	 * @param string $defaultLogicalSeparator
204
+	 * @return $this
205
+	 */
206
+	public function setDefaultLogicalSeparator($defaultLogicalSeparator)
207
+	{
208
+		$this->defaultLogicalSeparator = $defaultLogicalSeparator;
209
+		return $this;
210
+	}
211
+
212
+	/**
213
+	 * @return string
214
+	 */
215
+	public function getLogicalSeparatorForEquals()
216
+	{
217
+		return $this->logicalSeparatorForEquals;
218
+	}
219
+
220
+	/**
221
+	 * @param string $logicalSeparatorForEquals
222
+	 * @return $this
223
+	 */
224
+	public function setLogicalSeparatorForEquals($logicalSeparatorForEquals)
225
+	{
226
+		$this->logicalSeparatorForEquals = $logicalSeparatorForEquals;
227
+		return $this;
228
+	}
229
+
230
+	/**
231
+	 * @return string
232
+	 */
233
+	public function getLogicalSeparatorForIn()
234
+	{
235
+		return $this->logicalSeparatorForIn;
236
+	}
237
+
238
+	/**
239
+	 * @param string $logicalSeparatorForIn
240
+	 * @return $this
241
+	 */
242
+	public function setLogicalSeparatorForIn($logicalSeparatorForIn)
243
+	{
244
+		$this->logicalSeparatorForIn = $logicalSeparatorForIn;
245
+		return $this;
246
+	}
247
+
248
+	/**
249
+	 * @return string
250
+	 */
251
+	public function getLogicalSeparatorForLike()
252
+	{
253
+		return $this->logicalSeparatorForLike;
254
+	}
255
+
256
+	/**
257
+	 * @param string $logicalSeparatorForLike
258
+	 * @return $this
259
+	 */
260
+	public function setLogicalSeparatorForLike($logicalSeparatorForLike)
261
+	{
262
+		$this->logicalSeparatorForLike = $logicalSeparatorForLike;
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * @return string
268
+	 */
269
+	public function getLogicalSeparatorForSearchTerm()
270
+	{
271
+		return $this->logicalSeparatorForSearchTerm;
272
+	}
273
+
274
+	/**
275
+	 * @param string $logicalSeparatorForSearchTerm
276
+	 * @return $this
277
+	 */
278
+	public function setLogicalSeparatorForSearchTerm($logicalSeparatorForSearchTerm)
279
+	{
280
+		$this->logicalSeparatorForSearchTerm = $logicalSeparatorForSearchTerm;
281
+		return $this;
282
+	}
283
+
284
+	/**
285
+	 * @return array
286
+	 */
287
+	public function getSupportedOperators()
288
+	{
289
+		return $this->supportedOperators;
290
+	}
291
+
292
+	/**
293
+	 * @return string
294
+	 */
295
+	public function getDataType()
296
+	{
297
+		return $this->dataType;
298
+	}
299
+
300
+	/**
301
+	 * @param string $dataType
302
+	 * @return $this
303
+	 */
304
+	public function setDataType($dataType)
305
+	{
306
+		$this->dataType = $dataType;
307
+		return $this;
308
+	}
309 309
 }
Please login to merge, or discard this patch.
Classes/Persistence/OrderObjectFactory.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -24,43 +24,43 @@
 block discarded – undo
24 24
 class OrderObjectFactory implements SingletonInterface
25 25
 {
26 26
 
27
-    /**
28
-     * Gets a singleton instance of this class.
29
-     *
30
-     * @return \Fab\Vidi\Persistence\OrderObjectFactory
31
-     */
32
-    static public function getInstance()
33
-    {
34
-        return GeneralUtility::makeInstance('Fab\Vidi\Persistence\OrderObjectFactory');
35
-    }
27
+	/**
28
+	 * Gets a singleton instance of this class.
29
+	 *
30
+	 * @return \Fab\Vidi\Persistence\OrderObjectFactory
31
+	 */
32
+	static public function getInstance()
33
+	{
34
+		return GeneralUtility::makeInstance('Fab\Vidi\Persistence\OrderObjectFactory');
35
+	}
36 36
 
37
-    /**
38
-     * Returns an order object.
39
-     *
40
-     * @param string $dataType
41
-     * @return \Fab\Vidi\Persistence\Order
42
-     */
43
-    public function getOrder($dataType = '')
44
-    {
37
+	/**
38
+	 * Returns an order object.
39
+	 *
40
+	 * @param string $dataType
41
+	 * @return \Fab\Vidi\Persistence\Order
42
+	 */
43
+	public function getOrder($dataType = '')
44
+	{
45 45
 
46
-        // Default ordering
47
-        $order = Tca::table($dataType)->getDefaultOrderings();
46
+		// Default ordering
47
+		$order = Tca::table($dataType)->getDefaultOrderings();
48 48
 
49
-        // Retrieve a possible id of the column from the request
50
-        $orderings = GeneralUtility::_GP('order');
49
+		// Retrieve a possible id of the column from the request
50
+		$orderings = GeneralUtility::_GP('order');
51 51
 
52
-        if (is_array($orderings) && isset($orderings[0])) {
53
-            $columnPosition = $orderings[0]['column'];
54
-            $direction = $orderings[0]['dir'];
52
+		if (is_array($orderings) && isset($orderings[0])) {
53
+			$columnPosition = $orderings[0]['column'];
54
+			$direction = $orderings[0]['dir'];
55 55
 
56
-            if ($columnPosition > 0) {
57
-                $field = Tca::grid()->getFieldNameByPosition($columnPosition);
56
+			if ($columnPosition > 0) {
57
+				$field = Tca::grid()->getFieldNameByPosition($columnPosition);
58 58
 
59
-                $order = array(
60
-                    $field => strtoupper($direction)
61
-                );
62
-            }
63
-        }
64
-        return GeneralUtility::makeInstance('Fab\Vidi\Persistence\Order', $order);
65
-    }
59
+				$order = array(
60
+					$field => strtoupper($direction)
61
+				);
62
+			}
63
+		}
64
+		return GeneralUtility::makeInstance('Fab\Vidi\Persistence\Order', $order);
65
+	}
66 66
 }
Please login to merge, or discard this patch.
Classes/Persistence/Query.php 1 patch
Indentation   +644 added lines, -644 removed lines patch added patch discarded remove patch
@@ -29,649 +29,649 @@
 block discarded – undo
29 29
 class Query implements QueryInterface
30 30
 {
31 31
 
32
-    /**
33
-     * An inner join.
34
-     */
35
-    const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner';
36
-
37
-    /**
38
-     * A left-outer join.
39
-     */
40
-    const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
41
-
42
-    /**
43
-     * A right-outer join.
44
-     */
45
-    const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
46
-
47
-    /**
48
-     * Charset of strings in QOM
49
-     */
50
-    const CHARSET = 'utf-8';
51
-
52
-    /**
53
-     * @var string
54
-     */
55
-    protected $sourceFieldName;
56
-
57
-    /**
58
-     * @var string
59
-     */
60
-    protected $type;
61
-
62
-    /**
63
-     * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
64
-     */
65
-    protected $objectManager;
66
-
67
-    /**
68
-     * @var \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface
69
-     */
70
-    protected $persistenceManager;
71
-
72
-    /**
73
-     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory
74
-     */
75
-    protected $qomFactory;
76
-
77
-    /**
78
-     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface
79
-     */
80
-    protected $source;
81
-
82
-    /**
83
-     * @var ConstraintInterface
84
-     */
85
-    protected $constraint;
86
-
87
-    /**
88
-     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
89
-     */
90
-    protected $statement;
91
-
92
-    /**
93
-     * @var int
94
-     */
95
-    protected $orderings = array();
96
-
97
-    /**
98
-     * @var int
99
-     */
100
-    protected $limit;
101
-
102
-    /**
103
-     * @var int
104
-     */
105
-    protected $offset;
106
-
107
-    /**
108
-     * Apply DISTINCT upon property.
109
-     *
110
-     * @var string
111
-     */
112
-    protected $distinct;
113
-
114
-    /**
115
-     * The query settings.
116
-     *
117
-     * @var \Fab\Vidi\Persistence\QuerySettings
118
-     * @inject
119
-     */
120
-    protected $querySettings;
121
-
122
-    /**
123
-     * Constructs a query object working on the given class name
124
-     *
125
-     * @param string $type
126
-     */
127
-    public function __construct($type)
128
-    {
129
-        $this->type = $type;
130
-    }
131
-
132
-    /**
133
-     * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
134
-     * @return void
135
-     */
136
-    public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
137
-    {
138
-        $this->objectManager = $objectManager;
139
-    }
140
-
141
-    /**
142
-     * Injects the persistence manager, used to fetch the CR session
143
-     *
144
-     * @param \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager
145
-     * @return void
146
-     */
147
-    public function injectPersistenceManager(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager)
148
-    {
149
-        $this->persistenceManager = $persistenceManager;
150
-    }
151
-
152
-    /**
153
-     * Injects the Query Object Model Factory
154
-     *
155
-     * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory $qomFactory
156
-     * @return void
157
-     */
158
-    public function injectQomFactory(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory $qomFactory)
159
-    {
160
-        $this->qomFactory = $qomFactory;
161
-    }
162
-
163
-    /**
164
-     * Sets the Query Settings. These Query settings must match the settings expected by
165
-     * the specific Storage Backend.
166
-     *
167
-     * @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
168
-     * @return void
169
-     * @api This method is not part of FLOW3 API
170
-     */
171
-    public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings)
172
-    {
173
-        $this->querySettings = $querySettings;
174
-    }
175
-
176
-    /**
177
-     * Returns the Query Settings.
178
-     *
179
-     * @throws \Exception
180
-     * @return \Fab\Vidi\Persistence\QuerySettings $querySettings The Query Settings
181
-     * @api This method is not part of FLOW3 API
182
-     */
183
-    public function getQuerySettings()
184
-    {
185
-        if (!$this->querySettings instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface) {
186
-            throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception('Tried to get the query settings without setting them before.', 1248689115);
187
-        }
188
-
189
-        // Apply possible settings to the query.
190
-        if ($this->isBackendMode()) {
191
-            /** @var \TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager $backendConfigurationManager */
192
-            $backendConfigurationManager = $this->objectManager->get('TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager');
193
-            $configuration = $backendConfigurationManager->getTypoScriptSetup();
194
-            $querySettings = array('respectSysLanguage');
195
-            foreach ($querySettings as $setting) {
196
-                if (isset($configuration['config.']['tx_vidi.']['persistence.']['backend.'][$this->type . '.'][$setting])) {
197
-                    $value = (bool)$configuration['config.']['tx_vidi.']['persistence.']['backend.'][$this->type . '.'][$setting];
198
-                    ObjectAccess::setProperty($this->querySettings, $setting, $value);
199
-                }
200
-            }
201
-        }
202
-
203
-        return $this->querySettings;
204
-    }
205
-
206
-    /**
207
-     * Returns the type this query cares for.
208
-     *
209
-     * @return string
210
-     * @api
211
-     */
212
-    public function getType()
213
-    {
214
-        return $this->type;
215
-    }
216
-
217
-    /**
218
-     * Sets the source to fetch the result from
219
-     *
220
-     * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source
221
-     */
222
-    public function setSource(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source)
223
-    {
224
-        $this->source = $source;
225
-    }
226
-
227
-    /**
228
-     * Returns the selectorn name or an empty string, if the source is not a selector
229
-     * TODO This has to be checked at another place
230
-     *
231
-     * @return string The selector name
232
-     */
233
-    protected function getSelectorName()
234
-    {
235
-        if ($this->getSource() instanceof \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SelectorInterface) {
236
-            return $this->source->getSelectorName();
237
-        } else {
238
-            return '';
239
-        }
240
-    }
241
-
242
-    /**
243
-     * Gets the node-tuple source for this query.
244
-     *
245
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface the node-tuple source; non-null
246
-     */
247
-    public function getSource()
248
-    {
249
-        if ($this->source === NULL) {
250
-            $this->source = $this->qomFactory->selector($this->getType());
251
-        }
252
-        return $this->source;
253
-    }
254
-
255
-    /**
256
-     * Executes the query against the database and returns the result
257
-     *
258
-     * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array The query result object or an array if $this->getQuerySettings()->getReturnRawQueryResult() is TRUE
259
-     * @api
260
-     */
261
-    public function execute($returnRawQueryResult = FALSE)
262
-    {
263
-        /** @var \Fab\Vidi\Persistence\Storage\VidiDbBackend $backend */
264
-        $backend = $this->objectManager->get('Fab\Vidi\Persistence\Storage\VidiDbBackend', $this);
265
-        return $backend->fetchResult();
266
-    }
267
-
268
-    /**
269
-     * Sets the property names to order the result by. Expected like this:
270
-     * array(
271
-     * 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
272
-     * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
273
-     * )
274
-     * where 'foo' and 'bar' are property names.
275
-     *
276
-     * @param array $orderings The property names to order by
277
-     * @return QueryInterface
278
-     * @api
279
-     */
280
-    public function setOrderings(array $orderings)
281
-    {
282
-        $this->orderings = $orderings;
283
-        return $this;
284
-    }
285
-
286
-    /**
287
-     * Returns the property names to order the result by. Like this:
288
-     * array(
289
-     * 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
290
-     * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
291
-     * )
292
-     *
293
-     * @return array
294
-     * @api
295
-     */
296
-    public function getOrderings()
297
-    {
298
-        return $this->orderings;
299
-    }
300
-
301
-    /**
302
-     * Sets the maximum size of the result set to limit. Returns $this to allow
303
-     * for chaining (fluid interface)
304
-     *
305
-     * @param integer $limit
306
-     * @throws \InvalidArgumentException
307
-     * @return QueryInterface
308
-     * @api
309
-     */
310
-    public function setLimit($limit)
311
-    {
312
-        if (!is_int($limit) || $limit < 1) {
313
-            throw new \InvalidArgumentException('The limit must be an integer >= 1', 1245071870);
314
-        }
315
-        $this->limit = $limit;
316
-        return $this;
317
-    }
318
-
319
-    /**
320
-     * Resets a previously set maximum size of the result set. Returns $this to allow
321
-     * for chaining (fluid interface)
322
-     *
323
-     * @return QueryInterface
324
-     * @api
325
-     */
326
-    public function unsetLimit()
327
-    {
328
-        unset($this->limit);
329
-        return $this;
330
-    }
331
-
332
-    /**
333
-     * Returns the maximum size of the result set to limit.
334
-     *
335
-     * @return integer
336
-     * @api
337
-     */
338
-    public function getLimit()
339
-    {
340
-        return $this->limit;
341
-    }
342
-
343
-    /**
344
-     * Sets the start offset of the result set to offset. Returns $this to
345
-     * allow for chaining (fluid interface)
346
-     *
347
-     * @param integer $offset
348
-     * @throws \InvalidArgumentException
349
-     * @return QueryInterface
350
-     * @api
351
-     */
352
-    public function setOffset($offset)
353
-    {
354
-        if (!is_int($offset) || $offset < 0) {
355
-            throw new \InvalidArgumentException('The offset must be a positive integer', 1245071872);
356
-        }
357
-        $this->offset = $offset;
358
-        return $this;
359
-    }
360
-
361
-    /**
362
-     * Returns the start offset of the result set.
363
-     *
364
-     * @return integer
365
-     * @api
366
-     */
367
-    public function getOffset()
368
-    {
369
-        return $this->offset;
370
-    }
371
-
372
-    /**
373
-     * The constraint used to limit the result set. Returns $this to allow
374
-     * for chaining (fluid interface)
375
-     *
376
-     * @param ConstraintInterface $constraint
377
-     * @return QueryInterface
378
-     * @api
379
-     */
380
-    public function matching($constraint)
381
-    {
382
-        $this->constraint = $constraint;
383
-        return $this;
384
-    }
385
-
386
-    /**
387
-     * Gets the constraint for this query.
388
-     *
389
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Constraint the constraint, or null if none
390
-     * @api
391
-     */
392
-    public function getConstraint()
393
-    {
394
-        return $this->constraint;
395
-    }
396
-
397
-    /**
398
-     * Performs a logical conjunction of the given constraints. The method takes one or more contraints and concatenates them with a boolean AND.
399
-     * It also scepts a single array of constraints to be concatenated.
400
-     *
401
-     * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
402
-     * @throws InvalidNumberOfConstraintsException
403
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface
404
-     * @api
405
-     */
406
-    public function logicalAnd($constraint1)
407
-    {
408
-        if (is_array($constraint1)) {
409
-            $resultingConstraint = array_shift($constraint1);
410
-            $constraints = $constraint1;
411
-        } else {
412
-            $constraints = func_get_args();
413
-            $resultingConstraint = array_shift($constraints);
414
-        }
415
-        if ($resultingConstraint === NULL) {
416
-            throw new InvalidNumberOfConstraintsException('There must be at least one constraint or a non-empty array of constraints given.', 1401289500);
417
-        }
418
-        foreach ($constraints as $constraint) {
419
-            $resultingConstraint = $this->qomFactory->_and($resultingConstraint, $constraint);
420
-        }
421
-        return $resultingConstraint;
422
-    }
423
-
424
-    /**
425
-     * Performs a logical disjunction of the two given constraints
426
-     *
427
-     * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
428
-     * @throws InvalidNumberOfConstraintsException
429
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface
430
-     * @api
431
-     */
432
-    public function logicalOr($constraint1)
433
-    {
434
-        if (is_array($constraint1)) {
435
-            $resultingConstraint = array_shift($constraint1);
436
-            $constraints = $constraint1;
437
-        } else {
438
-            $constraints = func_get_args();
439
-            $resultingConstraint = array_shift($constraints);
440
-        }
441
-        if ($resultingConstraint === NULL) {
442
-            throw new InvalidNumberOfConstraintsException('There must be at least one constraint or a non-empty array of constraints given.', 1401289501);
443
-        }
444
-        foreach ($constraints as $constraint) {
445
-            $resultingConstraint = $this->qomFactory->_or($resultingConstraint, $constraint);
446
-        }
447
-        return $resultingConstraint;
448
-    }
449
-
450
-    /**
451
-     * Performs a logical negation of the given constraint
452
-     *
453
-     * @param ConstraintInterface $constraint Constraint to negate
454
-     * @throws \RuntimeException
455
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\NotInterface
456
-     * @api
457
-     */
458
-    public function logicalNot(ConstraintInterface $constraint)
459
-    {
460
-        return $this->qomFactory->not($constraint);
461
-    }
462
-
463
-    /**
464
-     * Returns an equals criterion used for matching objects against a query
465
-     *
466
-     * @param string $propertyName The name of the property to compare against
467
-     * @param mixed $operand The value to compare with
468
-     * @param boolean $caseSensitive Whether the equality test should be done case-sensitive
469
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
470
-     * @api
471
-     */
472
-    public function equals($propertyName, $operand, $caseSensitive = TRUE)
473
-    {
474
-        if (is_object($operand) || $caseSensitive) {
475
-            $comparison = $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_EQUAL_TO, $operand);
476
-        } else {
477
-            $comparison = $this->qomFactory->comparison($this->qomFactory->lowerCase($this->qomFactory->propertyValue($propertyName, $this->getSelectorName())), QueryInterface::OPERATOR_EQUAL_TO, \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter')->conv_case(\TYPO3\CMS\Extbase\Persistence\Generic\Query::CHARSET, $operand, 'toLower'));
478
-        }
479
-        return $comparison;
480
-    }
481
-
482
-    /**
483
-     * Returns a like criterion used for matching objects against a query
484
-     *
485
-     * @param string $propertyName The name of the property to compare against
486
-     * @param mixed $operand The value to compare with
487
-     * @param boolean $caseSensitive Whether the matching should be done case-sensitive
488
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
489
-     * @api
490
-     */
491
-    public function like($propertyName, $operand, $caseSensitive = TRUE)
492
-    {
493
-        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LIKE, $operand);
494
-    }
495
-
496
-    /**
497
-     * Returns a "contains" criterion used for matching objects against a query.
498
-     * It matches if the multivalued property contains the given operand.
499
-     *
500
-     * @param string $propertyName The name of the (multivalued) property to compare against
501
-     * @param mixed $operand The value to compare with
502
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
503
-     * @api
504
-     */
505
-    public function contains($propertyName, $operand)
506
-    {
507
-        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_CONTAINS, $operand);
508
-    }
509
-
510
-    /**
511
-     * Returns an "in" criterion used for matching objects against a query. It
512
-     * matches if the property's value is contained in the multivalued operand.
513
-     *
514
-     * @param string $propertyName The name of the property to compare against
515
-     * @param mixed $operand The value to compare with, multivalued
516
-     * @throws UnexpectedTypeException
517
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
518
-     * @api
519
-     */
520
-    public function in($propertyName, $operand)
521
-    {
522
-        if (!is_array($operand) && !$operand instanceof \ArrayAccess && !$operand instanceof \Traversable) {
523
-            throw new UnexpectedTypeException('The "in" operator must be given a mutlivalued operand (array, ArrayAccess, Traversable).', 1264678095);
524
-        }
525
-        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_IN, $operand);
526
-    }
527
-
528
-    /**
529
-     * Returns a less than criterion used for matching objects against a query
530
-     *
531
-     * @param string $propertyName The name of the property to compare against
532
-     * @param mixed $operand The value to compare with
533
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
534
-     * @api
535
-     */
536
-    public function lessThan($propertyName, $operand)
537
-    {
538
-        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LESS_THAN, $operand);
539
-    }
540
-
541
-    /**
542
-     * Returns a less or equal than criterion used for matching objects against a query
543
-     *
544
-     * @param string $propertyName The name of the property to compare against
545
-     * @param mixed $operand The value to compare with
546
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
547
-     * @api
548
-     */
549
-    public function lessThanOrEqual($propertyName, $operand)
550
-    {
551
-        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LESS_THAN_OR_EQUAL_TO, $operand);
552
-    }
553
-
554
-    /**
555
-     * Returns a greater than criterion used for matching objects against a query
556
-     *
557
-     * @param string $propertyName The name of the property to compare against
558
-     * @param mixed $operand The value to compare with
559
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
560
-     * @api
561
-     */
562
-    public function greaterThan($propertyName, $operand)
563
-    {
564
-        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_GREATER_THAN, $operand);
565
-    }
566
-
567
-    /**
568
-     * Returns a greater than or equal criterion used for matching objects against a query
569
-     *
570
-     * @param string $propertyName The name of the property to compare against
571
-     * @param mixed $operand The value to compare with
572
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
573
-     * @api
574
-     */
575
-    public function greaterThanOrEqual($propertyName, $operand)
576
-    {
577
-        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $operand);
578
-    }
579
-
580
-    /**
581
-     * Returns the query result count.
582
-     *
583
-     * @return integer The query result count
584
-     * @api
585
-     */
586
-    public function count()
587
-    {
588
-        /** @var \Fab\Vidi\Persistence\Storage\VidiDbBackend $backend */
589
-        $backend = $this->objectManager->get('Fab\Vidi\Persistence\Storage\VidiDbBackend', $this);
590
-        return $backend->countResult();
591
-    }
592
-
593
-    /**
594
-     * Returns an "isEmpty" criterion used for matching objects against a query.
595
-     * It matches if the multivalued property contains no values or is NULL.
596
-     *
597
-     * @param string $propertyName The name of the multivalued property to compare against
598
-     * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
599
-     * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a single-valued property
600
-     * @api
601
-     */
602
-    public function isEmpty($propertyName)
603
-    {
604
-        throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
605
-    }
606
-
607
-    /**
608
-     * @return string
609
-     */
610
-    public function getDistinct()
611
-    {
612
-        return $this->distinct;
613
-    }
614
-
615
-    /**
616
-     * @param string $distinct
617
-     * @return $this
618
-     */
619
-    public function setDistinct($distinct)
620
-    {
621
-        $this->distinct = $distinct;
622
-        return $this;
623
-    }
624
-
625
-    /**
626
-     * Sets the statement of this query. If you use this, you will lose the abstraction from a concrete storage
627
-     * backend (database).
628
-     *
629
-     * @param string|\TYPO3\CMS\Core\Database\PreparedStatement $statement The statement
630
-     * @param array $parameters An array of parameters. These will be bound to placeholders '?' in the $statement.
631
-     * @return QueryInterface
632
-     */
633
-    public function statement($statement, array $parameters = array())
634
-    {
635
-        $this->statement = $this->qomFactory->statement($statement, $parameters);
636
-        return $this;
637
-    }
638
-
639
-    /**
640
-     * Returns the statement of this query.
641
-     *
642
-     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
643
-     */
644
-    public function getStatement()
645
-    {
646
-        return $this->statement;
647
-    }
648
-
649
-    /**
650
-     * Returns whether the current mode is Backend.
651
-     *
652
-     * @return bool
653
-     */
654
-    protected function isBackendMode()
655
-    {
656
-        return TYPO3_MODE == 'BE';
657
-    }
658
-
659
-    /**
660
-     * @return string
661
-     */
662
-    public function getSourceFieldName()
663
-    {
664
-        return $this->sourceFieldName;
665
-    }
666
-
667
-    /**
668
-     * @param string $sourceFieldName
669
-     * @return $this
670
-     */
671
-    public function setSourceFieldName($sourceFieldName)
672
-    {
673
-        $this->sourceFieldName = $sourceFieldName;
674
-        return $this;
675
-    }
32
+	/**
33
+	 * An inner join.
34
+	 */
35
+	const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner';
36
+
37
+	/**
38
+	 * A left-outer join.
39
+	 */
40
+	const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
41
+
42
+	/**
43
+	 * A right-outer join.
44
+	 */
45
+	const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
46
+
47
+	/**
48
+	 * Charset of strings in QOM
49
+	 */
50
+	const CHARSET = 'utf-8';
51
+
52
+	/**
53
+	 * @var string
54
+	 */
55
+	protected $sourceFieldName;
56
+
57
+	/**
58
+	 * @var string
59
+	 */
60
+	protected $type;
61
+
62
+	/**
63
+	 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
64
+	 */
65
+	protected $objectManager;
66
+
67
+	/**
68
+	 * @var \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface
69
+	 */
70
+	protected $persistenceManager;
71
+
72
+	/**
73
+	 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory
74
+	 */
75
+	protected $qomFactory;
76
+
77
+	/**
78
+	 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface
79
+	 */
80
+	protected $source;
81
+
82
+	/**
83
+	 * @var ConstraintInterface
84
+	 */
85
+	protected $constraint;
86
+
87
+	/**
88
+	 * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
89
+	 */
90
+	protected $statement;
91
+
92
+	/**
93
+	 * @var int
94
+	 */
95
+	protected $orderings = array();
96
+
97
+	/**
98
+	 * @var int
99
+	 */
100
+	protected $limit;
101
+
102
+	/**
103
+	 * @var int
104
+	 */
105
+	protected $offset;
106
+
107
+	/**
108
+	 * Apply DISTINCT upon property.
109
+	 *
110
+	 * @var string
111
+	 */
112
+	protected $distinct;
113
+
114
+	/**
115
+	 * The query settings.
116
+	 *
117
+	 * @var \Fab\Vidi\Persistence\QuerySettings
118
+	 * @inject
119
+	 */
120
+	protected $querySettings;
121
+
122
+	/**
123
+	 * Constructs a query object working on the given class name
124
+	 *
125
+	 * @param string $type
126
+	 */
127
+	public function __construct($type)
128
+	{
129
+		$this->type = $type;
130
+	}
131
+
132
+	/**
133
+	 * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
134
+	 * @return void
135
+	 */
136
+	public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
137
+	{
138
+		$this->objectManager = $objectManager;
139
+	}
140
+
141
+	/**
142
+	 * Injects the persistence manager, used to fetch the CR session
143
+	 *
144
+	 * @param \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager
145
+	 * @return void
146
+	 */
147
+	public function injectPersistenceManager(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager)
148
+	{
149
+		$this->persistenceManager = $persistenceManager;
150
+	}
151
+
152
+	/**
153
+	 * Injects the Query Object Model Factory
154
+	 *
155
+	 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory $qomFactory
156
+	 * @return void
157
+	 */
158
+	public function injectQomFactory(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory $qomFactory)
159
+	{
160
+		$this->qomFactory = $qomFactory;
161
+	}
162
+
163
+	/**
164
+	 * Sets the Query Settings. These Query settings must match the settings expected by
165
+	 * the specific Storage Backend.
166
+	 *
167
+	 * @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
168
+	 * @return void
169
+	 * @api This method is not part of FLOW3 API
170
+	 */
171
+	public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings)
172
+	{
173
+		$this->querySettings = $querySettings;
174
+	}
175
+
176
+	/**
177
+	 * Returns the Query Settings.
178
+	 *
179
+	 * @throws \Exception
180
+	 * @return \Fab\Vidi\Persistence\QuerySettings $querySettings The Query Settings
181
+	 * @api This method is not part of FLOW3 API
182
+	 */
183
+	public function getQuerySettings()
184
+	{
185
+		if (!$this->querySettings instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface) {
186
+			throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception('Tried to get the query settings without setting them before.', 1248689115);
187
+		}
188
+
189
+		// Apply possible settings to the query.
190
+		if ($this->isBackendMode()) {
191
+			/** @var \TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager $backendConfigurationManager */
192
+			$backendConfigurationManager = $this->objectManager->get('TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager');
193
+			$configuration = $backendConfigurationManager->getTypoScriptSetup();
194
+			$querySettings = array('respectSysLanguage');
195
+			foreach ($querySettings as $setting) {
196
+				if (isset($configuration['config.']['tx_vidi.']['persistence.']['backend.'][$this->type . '.'][$setting])) {
197
+					$value = (bool)$configuration['config.']['tx_vidi.']['persistence.']['backend.'][$this->type . '.'][$setting];
198
+					ObjectAccess::setProperty($this->querySettings, $setting, $value);
199
+				}
200
+			}
201
+		}
202
+
203
+		return $this->querySettings;
204
+	}
205
+
206
+	/**
207
+	 * Returns the type this query cares for.
208
+	 *
209
+	 * @return string
210
+	 * @api
211
+	 */
212
+	public function getType()
213
+	{
214
+		return $this->type;
215
+	}
216
+
217
+	/**
218
+	 * Sets the source to fetch the result from
219
+	 *
220
+	 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source
221
+	 */
222
+	public function setSource(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source)
223
+	{
224
+		$this->source = $source;
225
+	}
226
+
227
+	/**
228
+	 * Returns the selectorn name or an empty string, if the source is not a selector
229
+	 * TODO This has to be checked at another place
230
+	 *
231
+	 * @return string The selector name
232
+	 */
233
+	protected function getSelectorName()
234
+	{
235
+		if ($this->getSource() instanceof \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SelectorInterface) {
236
+			return $this->source->getSelectorName();
237
+		} else {
238
+			return '';
239
+		}
240
+	}
241
+
242
+	/**
243
+	 * Gets the node-tuple source for this query.
244
+	 *
245
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface the node-tuple source; non-null
246
+	 */
247
+	public function getSource()
248
+	{
249
+		if ($this->source === NULL) {
250
+			$this->source = $this->qomFactory->selector($this->getType());
251
+		}
252
+		return $this->source;
253
+	}
254
+
255
+	/**
256
+	 * Executes the query against the database and returns the result
257
+	 *
258
+	 * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array The query result object or an array if $this->getQuerySettings()->getReturnRawQueryResult() is TRUE
259
+	 * @api
260
+	 */
261
+	public function execute($returnRawQueryResult = FALSE)
262
+	{
263
+		/** @var \Fab\Vidi\Persistence\Storage\VidiDbBackend $backend */
264
+		$backend = $this->objectManager->get('Fab\Vidi\Persistence\Storage\VidiDbBackend', $this);
265
+		return $backend->fetchResult();
266
+	}
267
+
268
+	/**
269
+	 * Sets the property names to order the result by. Expected like this:
270
+	 * array(
271
+	 * 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
272
+	 * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
273
+	 * )
274
+	 * where 'foo' and 'bar' are property names.
275
+	 *
276
+	 * @param array $orderings The property names to order by
277
+	 * @return QueryInterface
278
+	 * @api
279
+	 */
280
+	public function setOrderings(array $orderings)
281
+	{
282
+		$this->orderings = $orderings;
283
+		return $this;
284
+	}
285
+
286
+	/**
287
+	 * Returns the property names to order the result by. Like this:
288
+	 * array(
289
+	 * 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
290
+	 * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
291
+	 * )
292
+	 *
293
+	 * @return array
294
+	 * @api
295
+	 */
296
+	public function getOrderings()
297
+	{
298
+		return $this->orderings;
299
+	}
300
+
301
+	/**
302
+	 * Sets the maximum size of the result set to limit. Returns $this to allow
303
+	 * for chaining (fluid interface)
304
+	 *
305
+	 * @param integer $limit
306
+	 * @throws \InvalidArgumentException
307
+	 * @return QueryInterface
308
+	 * @api
309
+	 */
310
+	public function setLimit($limit)
311
+	{
312
+		if (!is_int($limit) || $limit < 1) {
313
+			throw new \InvalidArgumentException('The limit must be an integer >= 1', 1245071870);
314
+		}
315
+		$this->limit = $limit;
316
+		return $this;
317
+	}
318
+
319
+	/**
320
+	 * Resets a previously set maximum size of the result set. Returns $this to allow
321
+	 * for chaining (fluid interface)
322
+	 *
323
+	 * @return QueryInterface
324
+	 * @api
325
+	 */
326
+	public function unsetLimit()
327
+	{
328
+		unset($this->limit);
329
+		return $this;
330
+	}
331
+
332
+	/**
333
+	 * Returns the maximum size of the result set to limit.
334
+	 *
335
+	 * @return integer
336
+	 * @api
337
+	 */
338
+	public function getLimit()
339
+	{
340
+		return $this->limit;
341
+	}
342
+
343
+	/**
344
+	 * Sets the start offset of the result set to offset. Returns $this to
345
+	 * allow for chaining (fluid interface)
346
+	 *
347
+	 * @param integer $offset
348
+	 * @throws \InvalidArgumentException
349
+	 * @return QueryInterface
350
+	 * @api
351
+	 */
352
+	public function setOffset($offset)
353
+	{
354
+		if (!is_int($offset) || $offset < 0) {
355
+			throw new \InvalidArgumentException('The offset must be a positive integer', 1245071872);
356
+		}
357
+		$this->offset = $offset;
358
+		return $this;
359
+	}
360
+
361
+	/**
362
+	 * Returns the start offset of the result set.
363
+	 *
364
+	 * @return integer
365
+	 * @api
366
+	 */
367
+	public function getOffset()
368
+	{
369
+		return $this->offset;
370
+	}
371
+
372
+	/**
373
+	 * The constraint used to limit the result set. Returns $this to allow
374
+	 * for chaining (fluid interface)
375
+	 *
376
+	 * @param ConstraintInterface $constraint
377
+	 * @return QueryInterface
378
+	 * @api
379
+	 */
380
+	public function matching($constraint)
381
+	{
382
+		$this->constraint = $constraint;
383
+		return $this;
384
+	}
385
+
386
+	/**
387
+	 * Gets the constraint for this query.
388
+	 *
389
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Constraint the constraint, or null if none
390
+	 * @api
391
+	 */
392
+	public function getConstraint()
393
+	{
394
+		return $this->constraint;
395
+	}
396
+
397
+	/**
398
+	 * Performs a logical conjunction of the given constraints. The method takes one or more contraints and concatenates them with a boolean AND.
399
+	 * It also scepts a single array of constraints to be concatenated.
400
+	 *
401
+	 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
402
+	 * @throws InvalidNumberOfConstraintsException
403
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface
404
+	 * @api
405
+	 */
406
+	public function logicalAnd($constraint1)
407
+	{
408
+		if (is_array($constraint1)) {
409
+			$resultingConstraint = array_shift($constraint1);
410
+			$constraints = $constraint1;
411
+		} else {
412
+			$constraints = func_get_args();
413
+			$resultingConstraint = array_shift($constraints);
414
+		}
415
+		if ($resultingConstraint === NULL) {
416
+			throw new InvalidNumberOfConstraintsException('There must be at least one constraint or a non-empty array of constraints given.', 1401289500);
417
+		}
418
+		foreach ($constraints as $constraint) {
419
+			$resultingConstraint = $this->qomFactory->_and($resultingConstraint, $constraint);
420
+		}
421
+		return $resultingConstraint;
422
+	}
423
+
424
+	/**
425
+	 * Performs a logical disjunction of the two given constraints
426
+	 *
427
+	 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
428
+	 * @throws InvalidNumberOfConstraintsException
429
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface
430
+	 * @api
431
+	 */
432
+	public function logicalOr($constraint1)
433
+	{
434
+		if (is_array($constraint1)) {
435
+			$resultingConstraint = array_shift($constraint1);
436
+			$constraints = $constraint1;
437
+		} else {
438
+			$constraints = func_get_args();
439
+			$resultingConstraint = array_shift($constraints);
440
+		}
441
+		if ($resultingConstraint === NULL) {
442
+			throw new InvalidNumberOfConstraintsException('There must be at least one constraint or a non-empty array of constraints given.', 1401289501);
443
+		}
444
+		foreach ($constraints as $constraint) {
445
+			$resultingConstraint = $this->qomFactory->_or($resultingConstraint, $constraint);
446
+		}
447
+		return $resultingConstraint;
448
+	}
449
+
450
+	/**
451
+	 * Performs a logical negation of the given constraint
452
+	 *
453
+	 * @param ConstraintInterface $constraint Constraint to negate
454
+	 * @throws \RuntimeException
455
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\NotInterface
456
+	 * @api
457
+	 */
458
+	public function logicalNot(ConstraintInterface $constraint)
459
+	{
460
+		return $this->qomFactory->not($constraint);
461
+	}
462
+
463
+	/**
464
+	 * Returns an equals criterion used for matching objects against a query
465
+	 *
466
+	 * @param string $propertyName The name of the property to compare against
467
+	 * @param mixed $operand The value to compare with
468
+	 * @param boolean $caseSensitive Whether the equality test should be done case-sensitive
469
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
470
+	 * @api
471
+	 */
472
+	public function equals($propertyName, $operand, $caseSensitive = TRUE)
473
+	{
474
+		if (is_object($operand) || $caseSensitive) {
475
+			$comparison = $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_EQUAL_TO, $operand);
476
+		} else {
477
+			$comparison = $this->qomFactory->comparison($this->qomFactory->lowerCase($this->qomFactory->propertyValue($propertyName, $this->getSelectorName())), QueryInterface::OPERATOR_EQUAL_TO, \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter')->conv_case(\TYPO3\CMS\Extbase\Persistence\Generic\Query::CHARSET, $operand, 'toLower'));
478
+		}
479
+		return $comparison;
480
+	}
481
+
482
+	/**
483
+	 * Returns a like criterion used for matching objects against a query
484
+	 *
485
+	 * @param string $propertyName The name of the property to compare against
486
+	 * @param mixed $operand The value to compare with
487
+	 * @param boolean $caseSensitive Whether the matching should be done case-sensitive
488
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
489
+	 * @api
490
+	 */
491
+	public function like($propertyName, $operand, $caseSensitive = TRUE)
492
+	{
493
+		return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LIKE, $operand);
494
+	}
495
+
496
+	/**
497
+	 * Returns a "contains" criterion used for matching objects against a query.
498
+	 * It matches if the multivalued property contains the given operand.
499
+	 *
500
+	 * @param string $propertyName The name of the (multivalued) property to compare against
501
+	 * @param mixed $operand The value to compare with
502
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
503
+	 * @api
504
+	 */
505
+	public function contains($propertyName, $operand)
506
+	{
507
+		return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_CONTAINS, $operand);
508
+	}
509
+
510
+	/**
511
+	 * Returns an "in" criterion used for matching objects against a query. It
512
+	 * matches if the property's value is contained in the multivalued operand.
513
+	 *
514
+	 * @param string $propertyName The name of the property to compare against
515
+	 * @param mixed $operand The value to compare with, multivalued
516
+	 * @throws UnexpectedTypeException
517
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
518
+	 * @api
519
+	 */
520
+	public function in($propertyName, $operand)
521
+	{
522
+		if (!is_array($operand) && !$operand instanceof \ArrayAccess && !$operand instanceof \Traversable) {
523
+			throw new UnexpectedTypeException('The "in" operator must be given a mutlivalued operand (array, ArrayAccess, Traversable).', 1264678095);
524
+		}
525
+		return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_IN, $operand);
526
+	}
527
+
528
+	/**
529
+	 * Returns a less than criterion used for matching objects against a query
530
+	 *
531
+	 * @param string $propertyName The name of the property to compare against
532
+	 * @param mixed $operand The value to compare with
533
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
534
+	 * @api
535
+	 */
536
+	public function lessThan($propertyName, $operand)
537
+	{
538
+		return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LESS_THAN, $operand);
539
+	}
540
+
541
+	/**
542
+	 * Returns a less or equal than criterion used for matching objects against a query
543
+	 *
544
+	 * @param string $propertyName The name of the property to compare against
545
+	 * @param mixed $operand The value to compare with
546
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
547
+	 * @api
548
+	 */
549
+	public function lessThanOrEqual($propertyName, $operand)
550
+	{
551
+		return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LESS_THAN_OR_EQUAL_TO, $operand);
552
+	}
553
+
554
+	/**
555
+	 * Returns a greater than criterion used for matching objects against a query
556
+	 *
557
+	 * @param string $propertyName The name of the property to compare against
558
+	 * @param mixed $operand The value to compare with
559
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
560
+	 * @api
561
+	 */
562
+	public function greaterThan($propertyName, $operand)
563
+	{
564
+		return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_GREATER_THAN, $operand);
565
+	}
566
+
567
+	/**
568
+	 * Returns a greater than or equal criterion used for matching objects against a query
569
+	 *
570
+	 * @param string $propertyName The name of the property to compare against
571
+	 * @param mixed $operand The value to compare with
572
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
573
+	 * @api
574
+	 */
575
+	public function greaterThanOrEqual($propertyName, $operand)
576
+	{
577
+		return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $operand);
578
+	}
579
+
580
+	/**
581
+	 * Returns the query result count.
582
+	 *
583
+	 * @return integer The query result count
584
+	 * @api
585
+	 */
586
+	public function count()
587
+	{
588
+		/** @var \Fab\Vidi\Persistence\Storage\VidiDbBackend $backend */
589
+		$backend = $this->objectManager->get('Fab\Vidi\Persistence\Storage\VidiDbBackend', $this);
590
+		return $backend->countResult();
591
+	}
592
+
593
+	/**
594
+	 * Returns an "isEmpty" criterion used for matching objects against a query.
595
+	 * It matches if the multivalued property contains no values or is NULL.
596
+	 *
597
+	 * @param string $propertyName The name of the multivalued property to compare against
598
+	 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
599
+	 * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a single-valued property
600
+	 * @api
601
+	 */
602
+	public function isEmpty($propertyName)
603
+	{
604
+		throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
605
+	}
606
+
607
+	/**
608
+	 * @return string
609
+	 */
610
+	public function getDistinct()
611
+	{
612
+		return $this->distinct;
613
+	}
614
+
615
+	/**
616
+	 * @param string $distinct
617
+	 * @return $this
618
+	 */
619
+	public function setDistinct($distinct)
620
+	{
621
+		$this->distinct = $distinct;
622
+		return $this;
623
+	}
624
+
625
+	/**
626
+	 * Sets the statement of this query. If you use this, you will lose the abstraction from a concrete storage
627
+	 * backend (database).
628
+	 *
629
+	 * @param string|\TYPO3\CMS\Core\Database\PreparedStatement $statement The statement
630
+	 * @param array $parameters An array of parameters. These will be bound to placeholders '?' in the $statement.
631
+	 * @return QueryInterface
632
+	 */
633
+	public function statement($statement, array $parameters = array())
634
+	{
635
+		$this->statement = $this->qomFactory->statement($statement, $parameters);
636
+		return $this;
637
+	}
638
+
639
+	/**
640
+	 * Returns the statement of this query.
641
+	 *
642
+	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
643
+	 */
644
+	public function getStatement()
645
+	{
646
+		return $this->statement;
647
+	}
648
+
649
+	/**
650
+	 * Returns whether the current mode is Backend.
651
+	 *
652
+	 * @return bool
653
+	 */
654
+	protected function isBackendMode()
655
+	{
656
+		return TYPO3_MODE == 'BE';
657
+	}
658
+
659
+	/**
660
+	 * @return string
661
+	 */
662
+	public function getSourceFieldName()
663
+	{
664
+		return $this->sourceFieldName;
665
+	}
666
+
667
+	/**
668
+	 * @param string $sourceFieldName
669
+	 * @return $this
670
+	 */
671
+	public function setSourceFieldName($sourceFieldName)
672
+	{
673
+		$this->sourceFieldName = $sourceFieldName;
674
+		return $this;
675
+	}
676 676
 
677 677
 }
Please login to merge, or discard this patch.
Classes/Persistence/Pager.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -22,168 +22,168 @@
 block discarded – undo
22 22
 class Pager
23 23
 {
24 24
 
25
-    /**
26
-     * Total amount of entries
27
-     *
28
-     * @var integer
29
-     */
30
-    protected $count;
31
-
32
-    /**
33
-     * Current offset
34
-     *
35
-     * @var integer
36
-     */
37
-    protected $offset;
38
-
39
-    /**
40
-     * Current page index
41
-     *
42
-     * @var integer
43
-     */
44
-    protected $page;
45
-
46
-    /**
47
-     * Number of items per page
48
-     *
49
-     * @var integer
50
-     */
51
-    protected $limit = 10;
52
-
53
-    /**
54
-     * Constructs a new Pager
55
-     */
56
-    public function __construct()
57
-    {
58
-        $this->page = 1;
59
-    }
60
-
61
-    /**
62
-     * Returns the total amount of entries
63
-     *
64
-     * @return int
65
-     */
66
-    public function getCount()
67
-    {
68
-        return $this->count;
69
-    }
70
-
71
-    /**
72
-     * Sets the total amount of entries
73
-     *
74
-     * @param int $count
75
-     */
76
-    public function setCount($count)
77
-    {
78
-        $this->count = $count;
79
-    }
80
-
81
-    /**
82
-     * Returns the current page index
83
-     *
84
-     * @return int
85
-     */
86
-    public function getPage()
87
-    {
88
-        return $this->page;
89
-    }
90
-
91
-    /**
92
-     * Sets the current page index
93
-     *
94
-     * @param int $page
95
-     */
96
-    public function setPage($page)
97
-    {
98
-        $this->page = $page;
99
-    }
100
-
101
-    /**
102
-     * Returns the current limit index
103
-     *
104
-     * @return int
105
-     */
106
-    public function getLimit()
107
-    {
108
-        return $this->limit;
109
-    }
110
-
111
-    /**
112
-     * Sets the current limit index
113
-     *
114
-     * @param int $limit
115
-     */
116
-    public function setLimit($limit)
117
-    {
118
-        $this->limit = $limit;
119
-    }
120
-
121
-    /**
122
-     * @return Array Items to display
123
-     */
124
-    public function getDisplayItems()
125
-    {
126
-        $last = $this->getLastPage();
127
-        if ($last == 1) {
128
-            return null;
129
-        }
130
-        $values = Array();
131
-        for ($i = 1; $i <= $last; $i++) {
132
-            $values[] = Array('key' => $i, 'value' => $i);
133
-        }
134
-        return $values;
135
-    }
136
-
137
-    /**
138
-     * @return int The last page index
139
-     */
140
-    public function getLastPage()
141
-    {
142
-        $last = intval($this->count / $this->limit);
143
-        if ($this->count % $this->limit > 0) {
144
-            $last++;
145
-        }
146
-        return $last;
147
-    }
148
-
149
-    /**
150
-     * @return int The previous page index. Minimum value is 1
151
-     */
152
-    public function getPreviousPage()
153
-    {
154
-        $prev = $this->page - 1;
155
-        if ($prev < 1) {
156
-            $prev = 1;
157
-        }
158
-        return $prev;
159
-    }
160
-
161
-    /**
162
-     * @return int The next page index. Maximum valus is the last page
163
-     */
164
-    public function getNextPage()
165
-    {
166
-        $next = $this->page + 1;
167
-        $last = $this->getLastPage();
168
-        if ($next > $last) {
169
-            $next = $last;
170
-        }
171
-        return $next;
172
-    }
173
-
174
-    /**
175
-     * @return int
176
-     */
177
-    public function getOffset()
178
-    {
179
-        return $this->offset;
180
-    }
181
-
182
-    /**
183
-     * @param int $offset
184
-     */
185
-    public function setOffset($offset)
186
-    {
187
-        $this->offset = $offset;
188
-    }
25
+	/**
26
+	 * Total amount of entries
27
+	 *
28
+	 * @var integer
29
+	 */
30
+	protected $count;
31
+
32
+	/**
33
+	 * Current offset
34
+	 *
35
+	 * @var integer
36
+	 */
37
+	protected $offset;
38
+
39
+	/**
40
+	 * Current page index
41
+	 *
42
+	 * @var integer
43
+	 */
44
+	protected $page;
45
+
46
+	/**
47
+	 * Number of items per page
48
+	 *
49
+	 * @var integer
50
+	 */
51
+	protected $limit = 10;
52
+
53
+	/**
54
+	 * Constructs a new Pager
55
+	 */
56
+	public function __construct()
57
+	{
58
+		$this->page = 1;
59
+	}
60
+
61
+	/**
62
+	 * Returns the total amount of entries
63
+	 *
64
+	 * @return int
65
+	 */
66
+	public function getCount()
67
+	{
68
+		return $this->count;
69
+	}
70
+
71
+	/**
72
+	 * Sets the total amount of entries
73
+	 *
74
+	 * @param int $count
75
+	 */
76
+	public function setCount($count)
77
+	{
78
+		$this->count = $count;
79
+	}
80
+
81
+	/**
82
+	 * Returns the current page index
83
+	 *
84
+	 * @return int
85
+	 */
86
+	public function getPage()
87
+	{
88
+		return $this->page;
89
+	}
90
+
91
+	/**
92
+	 * Sets the current page index
93
+	 *
94
+	 * @param int $page
95
+	 */
96
+	public function setPage($page)
97
+	{
98
+		$this->page = $page;
99
+	}
100
+
101
+	/**
102
+	 * Returns the current limit index
103
+	 *
104
+	 * @return int
105
+	 */
106
+	public function getLimit()
107
+	{
108
+		return $this->limit;
109
+	}
110
+
111
+	/**
112
+	 * Sets the current limit index
113
+	 *
114
+	 * @param int $limit
115
+	 */
116
+	public function setLimit($limit)
117
+	{
118
+		$this->limit = $limit;
119
+	}
120
+
121
+	/**
122
+	 * @return Array Items to display
123
+	 */
124
+	public function getDisplayItems()
125
+	{
126
+		$last = $this->getLastPage();
127
+		if ($last == 1) {
128
+			return null;
129
+		}
130
+		$values = Array();
131
+		for ($i = 1; $i <= $last; $i++) {
132
+			$values[] = Array('key' => $i, 'value' => $i);
133
+		}
134
+		return $values;
135
+	}
136
+
137
+	/**
138
+	 * @return int The last page index
139
+	 */
140
+	public function getLastPage()
141
+	{
142
+		$last = intval($this->count / $this->limit);
143
+		if ($this->count % $this->limit > 0) {
144
+			$last++;
145
+		}
146
+		return $last;
147
+	}
148
+
149
+	/**
150
+	 * @return int The previous page index. Minimum value is 1
151
+	 */
152
+	public function getPreviousPage()
153
+	{
154
+		$prev = $this->page - 1;
155
+		if ($prev < 1) {
156
+			$prev = 1;
157
+		}
158
+		return $prev;
159
+	}
160
+
161
+	/**
162
+	 * @return int The next page index. Maximum valus is the last page
163
+	 */
164
+	public function getNextPage()
165
+	{
166
+		$next = $this->page + 1;
167
+		$last = $this->getLastPage();
168
+		if ($next > $last) {
169
+			$next = $last;
170
+		}
171
+		return $next;
172
+	}
173
+
174
+	/**
175
+	 * @return int
176
+	 */
177
+	public function getOffset()
178
+	{
179
+		return $this->offset;
180
+	}
181
+
182
+	/**
183
+	 * @param int $offset
184
+	 */
185
+	public function setOffset($offset)
186
+	{
187
+		$this->offset = $offset;
188
+	}
189 189
 }
Please login to merge, or discard this patch.
Classes/Persistence/MatcherObjectFactory.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -27,223 +27,223 @@
 block discarded – undo
27 27
 class MatcherObjectFactory implements SingletonInterface
28 28
 {
29 29
 
30
-    /**
31
-     * Gets a singleton instance of this class.
32
-     *
33
-     * @return \Fab\Vidi\Persistence\MatcherObjectFactory
34
-     */
35
-    static public function getInstance()
36
-    {
37
-        return GeneralUtility::makeInstance('Fab\Vidi\Persistence\MatcherObjectFactory');
38
-    }
39
-
40
-    /**
41
-     * Returns a matcher object.
42
-     *
43
-     * @param array $matches
44
-     * @param string $dataType
45
-     * @return Matcher
46
-     */
47
-    public function getMatcher(array $matches = array(), $dataType = '')
48
-    {
49
-
50
-        if (empty($dataType)) {
51
-            $dataType = $this->getModuleLoader()->getDataType();
52
-        }
53
-
54
-        /** @var $matcher Matcher */
55
-        $matcher = GeneralUtility::makeInstance('Fab\Vidi\Persistence\Matcher', array(), $dataType);
56
-
57
-        $matcher = $this->applyCriteriaFromDataTables($matcher, $dataType);
58
-        $matcher = $this->applyCriteriaFromMatchesArgument($matcher, $matches);
59
-
60
-        if ($this->isBackendMode()) {
61
-            $matcher = $this->applyCriteriaFromUrl($matcher);
62
-        }
63
-
64
-        // Trigger signal for post processing Matcher Object.
65
-        $this->emitPostProcessMatcherObjectSignal($matcher);
66
-
67
-        return $matcher;
68
-    }
69
-
70
-    /**
71
-     * Get a possible id from the URL and apply as filter criteria.
72
-     * Except if the main module belongs to the File. The id would be a combined identifier
73
-     * including the storage and a mount point.
74
-     *
75
-     * @param Matcher $matcher
76
-     * @return Matcher $matcher
77
-     */
78
-    protected function applyCriteriaFromUrl(Matcher $matcher)
79
-    {
80
-
81
-        if (GeneralUtility::_GP('id') && $this->getModuleLoader()->getMainModule() !== ModuleName::FILE) {
82
-            $matcher->equals('pid', GeneralUtility::_GP('id'));
83
-        }
84
-
85
-        return $matcher;
86
-    }
87
-
88
-    /**
89
-     * Apply criteria specific to jQuery plugin Datatable.
90
-     *
91
-     * @param Matcher $matcher
92
-     * @param array $matches
93
-     * @return Matcher $matcher
94
-     */
95
-    protected function applyCriteriaFromMatchesArgument(Matcher $matcher, $matches)
96
-    {
97
-
98
-        foreach ($matches as $fieldNameAndPath => $value) {
99
-            // CSV values should be considered as "in" operator in Query, otherwise "equals".
100
-            $explodedValues = GeneralUtility::trimExplode(',', $value, TRUE);
101
-            if (count($explodedValues) > 1) {
102
-                $matcher->in($fieldNameAndPath, $explodedValues);
103
-            } else {
104
-                $matcher->equals($fieldNameAndPath, $explodedValues[0]);
105
-            }
106
-        }
107
-
108
-        return $matcher;
109
-    }
110
-
111
-    /**
112
-     * Apply criteria specific to jQuery plugin DataTable.
113
-     *
114
-     * @param Matcher $matcher
115
-     * @param string $dataType
116
-     * @return Matcher $matcher
117
-     */
118
-    protected function applyCriteriaFromDataTables(Matcher $matcher, $dataType)
119
-    {
120
-
121
-        // Special case for Grid in the BE using jQuery DataTables plugin.
122
-        // Retrieve a possible search term from GP.
123
-        $query = GeneralUtility::_GP('search');
124
-        if (is_array($query)) {
125
-            if (!empty($query['value'])) {
126
-                $query = $query['value'];
127
-            } else {
128
-                $query = '';
129
-            }
130
-        }
131
-
132
-        if (strlen($query) > 0) {
133
-
134
-            // Parse the json query coming from the Visual Search.
135
-            $query = rawurldecode($query);
136
-            $queryParts = json_decode($query, TRUE);
137
-
138
-            if (is_array($queryParts)) {
139
-                foreach ($queryParts as $term) {
140
-                    $fieldNameAndPath = key($term);
141
-
142
-                    $resolvedDataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType);
143
-                    $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType);
144
-
145
-                    // Retrieve the value.
146
-                    $value = current($term);
147
-
148
-                    if (Tca::grid($resolvedDataType)->hasFacet($fieldName) && Tca::grid($resolvedDataType)->facet($fieldName)->canModifyMatcher()) {
149
-                        $matcher = Tca::grid($resolvedDataType)->facet($fieldName)->modifyMatcher($matcher, $value);
150
-                    } elseif (Tca::table($resolvedDataType)->hasField($fieldName)) {
151
-                        // Check whether the field exists and set it as "equal" or "like".
152
-                        if ($this->isOperatorEquals($fieldNameAndPath, $dataType, $value)) {
153
-                            $matcher->equals($fieldNameAndPath, $value);
154
-                        } else {
155
-                            $matcher->like($fieldNameAndPath, $value);
156
-                        }
157
-                    } elseif ($fieldNameAndPath === 'text') {
158
-                        // Special case if field is "text" which is a pseudo field in this case.
159
-                        // Set the search term which means Vidi will
160
-                        // search in various fields with operator "like". The fields come from key "searchFields" in the TCA.
161
-                        $matcher->setSearchTerm($value);
162
-                    }
163
-                }
164
-            } else {
165
-                $matcher->setSearchTerm($query);
166
-            }
167
-        }
168
-        return $matcher;
169
-    }
170
-
171
-    /**
172
-     * Tell whether the operator should be equals instead of like for a search, e.g. if the value is numerical.
173
-     *
174
-     * @param string $fieldName
175
-     * @param string $dataType
176
-     * @param string $value
177
-     * @return bool
178
-     */
179
-    protected function isOperatorEquals($fieldName, $dataType, $value)
180
-    {
181
-        return (Tca::table($dataType)->field($fieldName)->hasRelation() && MathUtility::canBeInterpretedAsInteger($value))
182
-        || Tca::table($dataType)->field($fieldName)->isNumerical();
183
-    }
184
-
185
-    /**
186
-     * Signal that is called for post-processing a matcher object.
187
-     *
188
-     * @param Matcher $matcher
189
-     * @signal
190
-     */
191
-    protected function emitPostProcessMatcherObjectSignal(Matcher $matcher)
192
-    {
193
-
194
-        if (strlen($matcher->getDataType()) <= 0) {
195
-
196
-            /** @var ModuleLoader $moduleLoader */
197
-            $moduleLoader = $this->getObjectManager()->get('Fab\Vidi\Module\ModuleLoader');
198
-            $matcher->setDataType($moduleLoader->getDataType());
199
-        }
200
-
201
-        $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\Controller\Backend\ContentController', 'postProcessMatcherObject', array($matcher, $matcher->getDataType()));
202
-    }
203
-
204
-    /**
205
-     * Get the SignalSlot dispatcher
206
-     *
207
-     * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
208
-     */
209
-    protected function getSignalSlotDispatcher()
210
-    {
211
-        return $this->getObjectManager()->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
212
-    }
213
-
214
-    /**
215
-     * @return \TYPO3\CMS\Extbase\Object\ObjectManager
216
-     */
217
-    protected function getObjectManager()
218
-    {
219
-        return GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
220
-    }
221
-
222
-    /**
223
-     * Get the Vidi Module Loader.
224
-     *
225
-     * @return \Fab\Vidi\Module\ModuleLoader
226
-     */
227
-    protected function getModuleLoader()
228
-    {
229
-        return GeneralUtility::makeInstance('Fab\Vidi\Module\ModuleLoader');
230
-    }
231
-
232
-    /**
233
-     * @return \Fab\Vidi\Resolver\FieldPathResolver
234
-     */
235
-    protected function getFieldPathResolver()
236
-    {
237
-        return GeneralUtility::makeInstance('Fab\Vidi\Resolver\FieldPathResolver');
238
-    }
239
-
240
-    /**
241
-     * Returns whether the current mode is Backend
242
-     *
243
-     * @return bool
244
-     */
245
-    protected function isBackendMode()
246
-    {
247
-        return TYPO3_MODE == 'BE';
248
-    }
30
+	/**
31
+	 * Gets a singleton instance of this class.
32
+	 *
33
+	 * @return \Fab\Vidi\Persistence\MatcherObjectFactory
34
+	 */
35
+	static public function getInstance()
36
+	{
37
+		return GeneralUtility::makeInstance('Fab\Vidi\Persistence\MatcherObjectFactory');
38
+	}
39
+
40
+	/**
41
+	 * Returns a matcher object.
42
+	 *
43
+	 * @param array $matches
44
+	 * @param string $dataType
45
+	 * @return Matcher
46
+	 */
47
+	public function getMatcher(array $matches = array(), $dataType = '')
48
+	{
49
+
50
+		if (empty($dataType)) {
51
+			$dataType = $this->getModuleLoader()->getDataType();
52
+		}
53
+
54
+		/** @var $matcher Matcher */
55
+		$matcher = GeneralUtility::makeInstance('Fab\Vidi\Persistence\Matcher', array(), $dataType);
56
+
57
+		$matcher = $this->applyCriteriaFromDataTables($matcher, $dataType);
58
+		$matcher = $this->applyCriteriaFromMatchesArgument($matcher, $matches);
59
+
60
+		if ($this->isBackendMode()) {
61
+			$matcher = $this->applyCriteriaFromUrl($matcher);
62
+		}
63
+
64
+		// Trigger signal for post processing Matcher Object.
65
+		$this->emitPostProcessMatcherObjectSignal($matcher);
66
+
67
+		return $matcher;
68
+	}
69
+
70
+	/**
71
+	 * Get a possible id from the URL and apply as filter criteria.
72
+	 * Except if the main module belongs to the File. The id would be a combined identifier
73
+	 * including the storage and a mount point.
74
+	 *
75
+	 * @param Matcher $matcher
76
+	 * @return Matcher $matcher
77
+	 */
78
+	protected function applyCriteriaFromUrl(Matcher $matcher)
79
+	{
80
+
81
+		if (GeneralUtility::_GP('id') && $this->getModuleLoader()->getMainModule() !== ModuleName::FILE) {
82
+			$matcher->equals('pid', GeneralUtility::_GP('id'));
83
+		}
84
+
85
+		return $matcher;
86
+	}
87
+
88
+	/**
89
+	 * Apply criteria specific to jQuery plugin Datatable.
90
+	 *
91
+	 * @param Matcher $matcher
92
+	 * @param array $matches
93
+	 * @return Matcher $matcher
94
+	 */
95
+	protected function applyCriteriaFromMatchesArgument(Matcher $matcher, $matches)
96
+	{
97
+
98
+		foreach ($matches as $fieldNameAndPath => $value) {
99
+			// CSV values should be considered as "in" operator in Query, otherwise "equals".
100
+			$explodedValues = GeneralUtility::trimExplode(',', $value, TRUE);
101
+			if (count($explodedValues) > 1) {
102
+				$matcher->in($fieldNameAndPath, $explodedValues);
103
+			} else {
104
+				$matcher->equals($fieldNameAndPath, $explodedValues[0]);
105
+			}
106
+		}
107
+
108
+		return $matcher;
109
+	}
110
+
111
+	/**
112
+	 * Apply criteria specific to jQuery plugin DataTable.
113
+	 *
114
+	 * @param Matcher $matcher
115
+	 * @param string $dataType
116
+	 * @return Matcher $matcher
117
+	 */
118
+	protected function applyCriteriaFromDataTables(Matcher $matcher, $dataType)
119
+	{
120
+
121
+		// Special case for Grid in the BE using jQuery DataTables plugin.
122
+		// Retrieve a possible search term from GP.
123
+		$query = GeneralUtility::_GP('search');
124
+		if (is_array($query)) {
125
+			if (!empty($query['value'])) {
126
+				$query = $query['value'];
127
+			} else {
128
+				$query = '';
129
+			}
130
+		}
131
+
132
+		if (strlen($query) > 0) {
133
+
134
+			// Parse the json query coming from the Visual Search.
135
+			$query = rawurldecode($query);
136
+			$queryParts = json_decode($query, TRUE);
137
+
138
+			if (is_array($queryParts)) {
139
+				foreach ($queryParts as $term) {
140
+					$fieldNameAndPath = key($term);
141
+
142
+					$resolvedDataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType);
143
+					$fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType);
144
+
145
+					// Retrieve the value.
146
+					$value = current($term);
147
+
148
+					if (Tca::grid($resolvedDataType)->hasFacet($fieldName) && Tca::grid($resolvedDataType)->facet($fieldName)->canModifyMatcher()) {
149
+						$matcher = Tca::grid($resolvedDataType)->facet($fieldName)->modifyMatcher($matcher, $value);
150
+					} elseif (Tca::table($resolvedDataType)->hasField($fieldName)) {
151
+						// Check whether the field exists and set it as "equal" or "like".
152
+						if ($this->isOperatorEquals($fieldNameAndPath, $dataType, $value)) {
153
+							$matcher->equals($fieldNameAndPath, $value);
154
+						} else {
155
+							$matcher->like($fieldNameAndPath, $value);
156
+						}
157
+					} elseif ($fieldNameAndPath === 'text') {
158
+						// Special case if field is "text" which is a pseudo field in this case.
159
+						// Set the search term which means Vidi will
160
+						// search in various fields with operator "like". The fields come from key "searchFields" in the TCA.
161
+						$matcher->setSearchTerm($value);
162
+					}
163
+				}
164
+			} else {
165
+				$matcher->setSearchTerm($query);
166
+			}
167
+		}
168
+		return $matcher;
169
+	}
170
+
171
+	/**
172
+	 * Tell whether the operator should be equals instead of like for a search, e.g. if the value is numerical.
173
+	 *
174
+	 * @param string $fieldName
175
+	 * @param string $dataType
176
+	 * @param string $value
177
+	 * @return bool
178
+	 */
179
+	protected function isOperatorEquals($fieldName, $dataType, $value)
180
+	{
181
+		return (Tca::table($dataType)->field($fieldName)->hasRelation() && MathUtility::canBeInterpretedAsInteger($value))
182
+		|| Tca::table($dataType)->field($fieldName)->isNumerical();
183
+	}
184
+
185
+	/**
186
+	 * Signal that is called for post-processing a matcher object.
187
+	 *
188
+	 * @param Matcher $matcher
189
+	 * @signal
190
+	 */
191
+	protected function emitPostProcessMatcherObjectSignal(Matcher $matcher)
192
+	{
193
+
194
+		if (strlen($matcher->getDataType()) <= 0) {
195
+
196
+			/** @var ModuleLoader $moduleLoader */
197
+			$moduleLoader = $this->getObjectManager()->get('Fab\Vidi\Module\ModuleLoader');
198
+			$matcher->setDataType($moduleLoader->getDataType());
199
+		}
200
+
201
+		$this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\Controller\Backend\ContentController', 'postProcessMatcherObject', array($matcher, $matcher->getDataType()));
202
+	}
203
+
204
+	/**
205
+	 * Get the SignalSlot dispatcher
206
+	 *
207
+	 * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
208
+	 */
209
+	protected function getSignalSlotDispatcher()
210
+	{
211
+		return $this->getObjectManager()->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
212
+	}
213
+
214
+	/**
215
+	 * @return \TYPO3\CMS\Extbase\Object\ObjectManager
216
+	 */
217
+	protected function getObjectManager()
218
+	{
219
+		return GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
220
+	}
221
+
222
+	/**
223
+	 * Get the Vidi Module Loader.
224
+	 *
225
+	 * @return \Fab\Vidi\Module\ModuleLoader
226
+	 */
227
+	protected function getModuleLoader()
228
+	{
229
+		return GeneralUtility::makeInstance('Fab\Vidi\Module\ModuleLoader');
230
+	}
231
+
232
+	/**
233
+	 * @return \Fab\Vidi\Resolver\FieldPathResolver
234
+	 */
235
+	protected function getFieldPathResolver()
236
+	{
237
+		return GeneralUtility::makeInstance('Fab\Vidi\Resolver\FieldPathResolver');
238
+	}
239
+
240
+	/**
241
+	 * Returns whether the current mode is Backend
242
+	 *
243
+	 * @return bool
244
+	 */
245
+	protected function isBackendMode()
246
+	{
247
+		return TYPO3_MODE == 'BE';
248
+	}
249 249
 }
Please login to merge, or discard this patch.