Completed
Push — master ( 9e3b6d...6d03f6 )
by Fabien
06:07 queued 02:59
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/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/Mvc/JsonResult.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -20,121 +20,121 @@
 block discarded – undo
20 20
 class JsonResult
21 21
 {
22 22
 
23
-    /**
24
-     * @var int
25
-     */
26
-    protected $numberOfObjects = 0;
27
-
28
-    /**
29
-     * @var int
30
-     */
31
-    protected $numberOfProcessedObjects = 0;
32
-
33
-    /**
34
-     * @var array
35
-     */
36
-    protected $errorMessages = array();
37
-
38
-    /**
39
-     * @var array
40
-     */
41
-    protected $processedObject = array();
42
-
43
-    /**
44
-     * @var array
45
-     */
46
-    protected $row = NULL;
47
-
48
-    /**
49
-     * @return $this
50
-     */
51
-    public function incrementNumberOfProcessedObjects()
52
-    {
53
-        $this->numberOfProcessedObjects++;
54
-    }
55
-
56
-    /**
57
-     * @param string $errorMessages
58
-     * @return $this
59
-     */
60
-    public function addErrorMessages($errorMessages)
61
-    {
62
-        if (!empty($errorMessages)) {
63
-            $this->errorMessages[] = $errorMessages;
64
-        } else {
65
-            $this->incrementNumberOfProcessedObjects();
66
-        }
67
-        return $this;
68
-    }
69
-
70
-    /**
71
-     * @param array $errorMessages
72
-     * @return $this
73
-     */
74
-    public function setErrorMessages($errorMessages)
75
-    {
76
-        $this->errorMessages = $errorMessages;
77
-        return $this;
78
-    }
79
-
80
-    /**
81
-     * @param array $processedObject
82
-     * @return $this
83
-     */
84
-    public function setProcessedObject($processedObject)
85
-    {
86
-        $this->processedObject = $processedObject;
87
-        return $this;
88
-    }
89
-
90
-    /**
91
-     * @return $this
92
-     */
93
-    public function hasErrors()
94
-    {
95
-        return !empty($this->errorMessages);
96
-    }
97
-
98
-    /**
99
-     * @param mixed $numberOfObjects
100
-     * @return $this
101
-     */
102
-    public function setNumberOfObjects($numberOfObjects)
103
-    {
104
-        $this->numberOfObjects = $numberOfObjects;
105
-        return $this;
106
-    }
107
-
108
-    /**
109
-     * @param mixed $row
110
-     * @return $this
111
-     */
112
-    public function setRow(array $row)
113
-    {
114
-        $this->row = $row;
115
-        return $this;
116
-    }
117
-
118
-    /**
119
-     * Convert $this to array
120
-     *
121
-     * @return array
122
-     */
123
-    public function toArray()
124
-    {
125
-        $arrayValues = array(
126
-            'numberOfObjects' => $this->numberOfObjects,
127
-            'numberOfProcessedObjects' => $this->numberOfProcessedObjects,
128
-            'hasErrors' => $this->hasErrors(),
129
-            'errorMessages' => $this->errorMessages,
130
-            'row' => $this->row,
131
-        );
132
-
133
-        // Only feed key processedObject if it has values.
134
-        if (!empty($this->processedObject)) {
135
-            $arrayValues['processedObject'] = $this->processedObject;
136
-        }
137
-
138
-        return $arrayValues;
139
-    }
23
+	/**
24
+	 * @var int
25
+	 */
26
+	protected $numberOfObjects = 0;
27
+
28
+	/**
29
+	 * @var int
30
+	 */
31
+	protected $numberOfProcessedObjects = 0;
32
+
33
+	/**
34
+	 * @var array
35
+	 */
36
+	protected $errorMessages = array();
37
+
38
+	/**
39
+	 * @var array
40
+	 */
41
+	protected $processedObject = array();
42
+
43
+	/**
44
+	 * @var array
45
+	 */
46
+	protected $row = NULL;
47
+
48
+	/**
49
+	 * @return $this
50
+	 */
51
+	public function incrementNumberOfProcessedObjects()
52
+	{
53
+		$this->numberOfProcessedObjects++;
54
+	}
55
+
56
+	/**
57
+	 * @param string $errorMessages
58
+	 * @return $this
59
+	 */
60
+	public function addErrorMessages($errorMessages)
61
+	{
62
+		if (!empty($errorMessages)) {
63
+			$this->errorMessages[] = $errorMessages;
64
+		} else {
65
+			$this->incrementNumberOfProcessedObjects();
66
+		}
67
+		return $this;
68
+	}
69
+
70
+	/**
71
+	 * @param array $errorMessages
72
+	 * @return $this
73
+	 */
74
+	public function setErrorMessages($errorMessages)
75
+	{
76
+		$this->errorMessages = $errorMessages;
77
+		return $this;
78
+	}
79
+
80
+	/**
81
+	 * @param array $processedObject
82
+	 * @return $this
83
+	 */
84
+	public function setProcessedObject($processedObject)
85
+	{
86
+		$this->processedObject = $processedObject;
87
+		return $this;
88
+	}
89
+
90
+	/**
91
+	 * @return $this
92
+	 */
93
+	public function hasErrors()
94
+	{
95
+		return !empty($this->errorMessages);
96
+	}
97
+
98
+	/**
99
+	 * @param mixed $numberOfObjects
100
+	 * @return $this
101
+	 */
102
+	public function setNumberOfObjects($numberOfObjects)
103
+	{
104
+		$this->numberOfObjects = $numberOfObjects;
105
+		return $this;
106
+	}
107
+
108
+	/**
109
+	 * @param mixed $row
110
+	 * @return $this
111
+	 */
112
+	public function setRow(array $row)
113
+	{
114
+		$this->row = $row;
115
+		return $this;
116
+	}
117
+
118
+	/**
119
+	 * Convert $this to array
120
+	 *
121
+	 * @return array
122
+	 */
123
+	public function toArray()
124
+	{
125
+		$arrayValues = array(
126
+			'numberOfObjects' => $this->numberOfObjects,
127
+			'numberOfProcessedObjects' => $this->numberOfProcessedObjects,
128
+			'hasErrors' => $this->hasErrors(),
129
+			'errorMessages' => $this->errorMessages,
130
+			'row' => $this->row,
131
+		);
132
+
133
+		// Only feed key processedObject if it has values.
134
+		if (!empty($this->processedObject)) {
135
+			$arrayValues['processedObject'] = $this->processedObject;
136
+		}
137
+
138
+		return $arrayValues;
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
Classes/Language/LanguageService.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -25,178 +25,178 @@
 block discarded – undo
25 25
 class LanguageService implements SingletonInterface
26 26
 {
27 27
 
28
-    /**
29
-     * @var array
30
-     */
31
-    protected $languages;
32
-
33
-    /**
34
-     * @var array
35
-     */
36
-    protected $defaultIcon;
37
-
38
-    /**
39
-     * Store the localized records to boost up performance.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $localizedRecordStorage;
44
-
45
-    /**
46
-     * Returns available language records.
47
-     * The method stores the records in the property to speed up the process as the method can be often called.
48
-     *
49
-     * @return array
50
-     */
51
-    public function getLanguages()
52
-    {
53
-        if (is_null($this->languages)) {
54
-
55
-            $tableName = 'sys_language';
56
-
57
-            $clause = '1 = 1';
58
-            $clause .= BackendUtility::deleteClause($tableName);
59
-            $clause .= BackendUtility::BEenableFields($tableName);
60
-            $this->languages = $this->getDatabaseConnection()->exec_SELECTgetRows('*', $tableName, $clause);
61
-        }
62
-        return $this->languages;
63
-    }
64
-
65
-    /**
66
-     * Returns a localized record according to a Content object and a language identifier.
67
-     * Notice! This method does not overlay anything but simply returns the raw localized record.
68
-     *
69
-     * @param Content $object
70
-     * @param int $language
71
-     * @return Content
72
-     */
73
-    public function getLocalizedContent(Content $object, $language)
74
-    {
75
-
76
-        // We want to cache data per Content object. Retrieve the Object hash.
77
-        $objectHash = spl_object_hash($object);
78
-
79
-        // Initialize the storage
80
-        if (empty($this->localizedRecordStorage[$objectHash])) {
81
-            $this->localizedRecordStorage[$objectHash] = array();
82
-        }
83
-
84
-        if (empty($this->localizedRecordStorage[$objectHash][$language])) {
85
-
86
-            $clause = sprintf('%s = %s AND %s = %s',
87
-                Tca::table($object)->getLanguageParentField(), // e.g. l10n_parent
88
-                $object->getUid(),
89
-                Tca::table($object)->getLanguageField(), // e.g. sys_language_uid
90
-                $language
91
-            );
92
-
93
-            $clause .= BackendUtility::deleteClause($object->getDataType());
94
-            $localizedRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', $object->getDataType(), $clause);
95
-
96
-            if ($localizedRecord) {
97
-                $localizedContent = GeneralUtility::makeInstance('Fab\Vidi\Domain\Model\Content', $object->getDataType(), $localizedRecord);
98
-                $this->localizedRecordStorage[$objectHash][$language] = $localizedContent;
99
-            } else {
100
-                $this->localizedRecordStorage[$objectHash][$language] = array(); // We want an array at least, even if empty.
101
-            }
102
-        }
103
-
104
-        return $this->localizedRecordStorage[$objectHash][$language];
105
-    }
106
-
107
-    /**
108
-     * Tell whether the given Content object has a localization.
109
-     *
110
-     * @param Content $object
111
-     * @param int $language
112
-     * @return string
113
-     */
114
-    public function hasLocalization(Content $object, $language)
115
-    {
116
-        $localizedRecord = $this->getLocalizedContent($object, $language);
117
-        return !empty($localizedRecord);
118
-    }
119
-
120
-    /**
121
-     * Returns a localized field according to a Content object and a language identifier.
122
-     * Notice! If there is not translation, simply returns an empty string.
123
-     *
124
-     * @param Content $object
125
-     * @param int $language
126
-     * @param string $fieldName
127
-     * @return string
128
-     */
129
-    public function getLocalizedFieldName(Content $object, $language, $fieldName)
130
-    {
131
-        $localizedRecord = $this->getLocalizedContent($object, $language);
132
-        return empty($localizedRecord) ? '' : $localizedRecord[$fieldName];
133
-    }
134
-
135
-    /**
136
-     * Returns the default language configured by TSConfig.
137
-     *
138
-     * @return array
139
-     */
140
-    public function getDefaultFlag()
141
-    {
142
-
143
-        if (is_null($this->defaultIcon)) {
144
-
145
-            $defaultFlag = ''; // default value
146
-
147
-            $tsConfig = BackendUtility::getModTSconfig(0, 'mod.SHARED');
148
-
149
-            // Fallback non sprite-configuration
150
-            if (($pos = strrpos($tsConfig['properties']['defaultLanguageFlag'], '.')) !== FALSE) {
151
-                $defaultFlag = substr($tsConfig['properties']['defaultLanguageFlag'], 0, $pos);
152
-            }
153
-
154
-            $this->defaultIcon = $defaultFlag;
155
-        }
156
-
157
-        return $this->defaultIcon;
158
-    }
159
-
160
-    /**
161
-     * Returns whether the system includes language records.
162
-     *
163
-     * @return bool
164
-     */
165
-    public function hasLanguages()
166
-    {
167
-        $languages = $this->getLanguages();
168
-        return !empty($languages);
169
-    }
170
-
171
-    /**
172
-     * Tell whether the given language exists.
173
-     *
174
-     * @param int $language
175
-     * @return bool
176
-     */
177
-    public function languageExists($language)
178
-    {
179
-        $languages = $this->getLanguages();
180
-
181
-        $LanguageExists = FALSE;
182
-        foreach ($languages as $_language) {
183
-            if ((int)$_language['uid'] === (int)$language) {
184
-                $LanguageExists = TRUE;
185
-                break;
186
-            }
187
-        }
188
-
189
-        return $LanguageExists;
190
-    }
191
-
192
-    /**
193
-     * Returns a pointer to the database.
194
-     *
195
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
196
-     */
197
-    protected function getDatabaseConnection()
198
-    {
199
-        return $GLOBALS['TYPO3_DB'];
200
-    }
28
+	/**
29
+	 * @var array
30
+	 */
31
+	protected $languages;
32
+
33
+	/**
34
+	 * @var array
35
+	 */
36
+	protected $defaultIcon;
37
+
38
+	/**
39
+	 * Store the localized records to boost up performance.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $localizedRecordStorage;
44
+
45
+	/**
46
+	 * Returns available language records.
47
+	 * The method stores the records in the property to speed up the process as the method can be often called.
48
+	 *
49
+	 * @return array
50
+	 */
51
+	public function getLanguages()
52
+	{
53
+		if (is_null($this->languages)) {
54
+
55
+			$tableName = 'sys_language';
56
+
57
+			$clause = '1 = 1';
58
+			$clause .= BackendUtility::deleteClause($tableName);
59
+			$clause .= BackendUtility::BEenableFields($tableName);
60
+			$this->languages = $this->getDatabaseConnection()->exec_SELECTgetRows('*', $tableName, $clause);
61
+		}
62
+		return $this->languages;
63
+	}
64
+
65
+	/**
66
+	 * Returns a localized record according to a Content object and a language identifier.
67
+	 * Notice! This method does not overlay anything but simply returns the raw localized record.
68
+	 *
69
+	 * @param Content $object
70
+	 * @param int $language
71
+	 * @return Content
72
+	 */
73
+	public function getLocalizedContent(Content $object, $language)
74
+	{
75
+
76
+		// We want to cache data per Content object. Retrieve the Object hash.
77
+		$objectHash = spl_object_hash($object);
78
+
79
+		// Initialize the storage
80
+		if (empty($this->localizedRecordStorage[$objectHash])) {
81
+			$this->localizedRecordStorage[$objectHash] = array();
82
+		}
83
+
84
+		if (empty($this->localizedRecordStorage[$objectHash][$language])) {
85
+
86
+			$clause = sprintf('%s = %s AND %s = %s',
87
+				Tca::table($object)->getLanguageParentField(), // e.g. l10n_parent
88
+				$object->getUid(),
89
+				Tca::table($object)->getLanguageField(), // e.g. sys_language_uid
90
+				$language
91
+			);
92
+
93
+			$clause .= BackendUtility::deleteClause($object->getDataType());
94
+			$localizedRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', $object->getDataType(), $clause);
95
+
96
+			if ($localizedRecord) {
97
+				$localizedContent = GeneralUtility::makeInstance('Fab\Vidi\Domain\Model\Content', $object->getDataType(), $localizedRecord);
98
+				$this->localizedRecordStorage[$objectHash][$language] = $localizedContent;
99
+			} else {
100
+				$this->localizedRecordStorage[$objectHash][$language] = array(); // We want an array at least, even if empty.
101
+			}
102
+		}
103
+
104
+		return $this->localizedRecordStorage[$objectHash][$language];
105
+	}
106
+
107
+	/**
108
+	 * Tell whether the given Content object has a localization.
109
+	 *
110
+	 * @param Content $object
111
+	 * @param int $language
112
+	 * @return string
113
+	 */
114
+	public function hasLocalization(Content $object, $language)
115
+	{
116
+		$localizedRecord = $this->getLocalizedContent($object, $language);
117
+		return !empty($localizedRecord);
118
+	}
119
+
120
+	/**
121
+	 * Returns a localized field according to a Content object and a language identifier.
122
+	 * Notice! If there is not translation, simply returns an empty string.
123
+	 *
124
+	 * @param Content $object
125
+	 * @param int $language
126
+	 * @param string $fieldName
127
+	 * @return string
128
+	 */
129
+	public function getLocalizedFieldName(Content $object, $language, $fieldName)
130
+	{
131
+		$localizedRecord = $this->getLocalizedContent($object, $language);
132
+		return empty($localizedRecord) ? '' : $localizedRecord[$fieldName];
133
+	}
134
+
135
+	/**
136
+	 * Returns the default language configured by TSConfig.
137
+	 *
138
+	 * @return array
139
+	 */
140
+	public function getDefaultFlag()
141
+	{
142
+
143
+		if (is_null($this->defaultIcon)) {
144
+
145
+			$defaultFlag = ''; // default value
146
+
147
+			$tsConfig = BackendUtility::getModTSconfig(0, 'mod.SHARED');
148
+
149
+			// Fallback non sprite-configuration
150
+			if (($pos = strrpos($tsConfig['properties']['defaultLanguageFlag'], '.')) !== FALSE) {
151
+				$defaultFlag = substr($tsConfig['properties']['defaultLanguageFlag'], 0, $pos);
152
+			}
153
+
154
+			$this->defaultIcon = $defaultFlag;
155
+		}
156
+
157
+		return $this->defaultIcon;
158
+	}
159
+
160
+	/**
161
+	 * Returns whether the system includes language records.
162
+	 *
163
+	 * @return bool
164
+	 */
165
+	public function hasLanguages()
166
+	{
167
+		$languages = $this->getLanguages();
168
+		return !empty($languages);
169
+	}
170
+
171
+	/**
172
+	 * Tell whether the given language exists.
173
+	 *
174
+	 * @param int $language
175
+	 * @return bool
176
+	 */
177
+	public function languageExists($language)
178
+	{
179
+		$languages = $this->getLanguages();
180
+
181
+		$LanguageExists = FALSE;
182
+		foreach ($languages as $_language) {
183
+			if ((int)$_language['uid'] === (int)$language) {
184
+				$LanguageExists = TRUE;
185
+				break;
186
+			}
187
+		}
188
+
189
+		return $LanguageExists;
190
+	}
191
+
192
+	/**
193
+	 * Returns a pointer to the database.
194
+	 *
195
+	 * @return \TYPO3\CMS\Core\Database\DatabaseConnection
196
+	 */
197
+	protected function getDatabaseConnection()
198
+	{
199
+		return $GLOBALS['TYPO3_DB'];
200
+	}
201 201
 
202 202
 }
Please login to merge, or discard this patch.
Classes/Language/LocalizationStatus.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@
 block discarded – undo
22 22
 class LocalizationStatus extends Enumeration
23 23
 {
24 24
 
25
-    const LOCALIZED = 'localized';
26
-    const NOT_YET_LOCALIZED = 'notYetLocalized';
27
-    const EMPTY_VALUE = 'emptyValue';
25
+	const LOCALIZED = 'localized';
26
+	const NOT_YET_LOCALIZED = 'notYetLocalized';
27
+	const EMPTY_VALUE = 'emptyValue';
28 28
 
29 29
 }
Please login to merge, or discard this patch.