|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the TYPO3 CMS project. |
|
5
|
|
|
* |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
8
|
|
|
* of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please read the |
|
11
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* The TYPO3 project - inspiring people to share! |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace TYPO3\CMS\Extbase\Persistence\Generic\Qom; |
|
17
|
|
|
|
|
18
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
20
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The Query Object Model Factory |
|
24
|
|
|
* @internal only to be used within Extbase, not part of TYPO3 Core API. |
|
25
|
|
|
*/ |
|
26
|
|
|
class QueryObjectModelFactory implements SingletonInterface |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Selects a subset of the nodes in the repository based on node type. |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $nodeTypeName the name of the required node type; non-null |
|
32
|
|
|
* @param string $selectorName the selector name; optional |
|
33
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SelectorInterface the selector |
|
34
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
35
|
|
|
*/ |
|
36
|
|
|
public function selector($nodeTypeName, $selectorName = '') |
|
37
|
|
|
{ |
|
38
|
|
|
if ($selectorName === '') { |
|
39
|
|
|
$selectorName = $nodeTypeName; |
|
40
|
|
|
} |
|
41
|
|
|
return GeneralUtility::makeInstance(Selector::class, $selectorName, $nodeTypeName); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Sets a statement as constraint. This is not part of the JCR 2.0 Specification! |
|
46
|
|
|
* |
|
47
|
|
|
* @param string $statement The statement |
|
48
|
|
|
* @param array $boundVariables An array of variables to bind to the statement |
|
49
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement |
|
50
|
|
|
*/ |
|
51
|
|
|
public function statement($statement, array $boundVariables = []) |
|
52
|
|
|
{ |
|
53
|
|
|
return GeneralUtility::makeInstance(Statement::class, $statement, $boundVariables); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Performs a join between two node-tuple sources. |
|
58
|
|
|
* |
|
59
|
|
|
* @param SourceInterface $left the left node-tuple source; non-null |
|
60
|
|
|
* @param SourceInterface $right the right node-tuple source; non-null |
|
61
|
|
|
* @param string $joinType one of QueryObjectModelConstants.JCR_JOIN_TYPE_* |
|
62
|
|
|
* @param JoinConditionInterface $joinCondition |
|
63
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\JoinInterface the join; non-null |
|
64
|
|
|
*/ |
|
65
|
|
|
public function join(SourceInterface $left, SourceInterface $right, $joinType, JoinConditionInterface $joinCondition) |
|
66
|
|
|
{ |
|
67
|
|
|
return GeneralUtility::makeInstance(Join::class, $left, $right, $joinType, $joinCondition); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Tests whether the value of a property in a first selector is equal to the value of a property in a second selector. |
|
72
|
|
|
* |
|
73
|
|
|
* @param string $selector1Name the name of the first selector; non-null |
|
74
|
|
|
* @param string $property1Name the property name in the first selector; non-null |
|
75
|
|
|
* @param string $selector2Name the name of the second selector; non-null |
|
76
|
|
|
* @param string $property2Name the property name in the second selector; non-null |
|
77
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\EquiJoinConditionInterface the constraint; non-null |
|
78
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
79
|
|
|
*/ |
|
80
|
|
|
public function equiJoinCondition($selector1Name, $property1Name, $selector2Name, $property2Name) |
|
81
|
|
|
{ |
|
82
|
|
|
return GeneralUtility::makeInstance(EquiJoinCondition::class, $selector1Name, $property1Name, $selector2Name, $property2Name); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Performs a logical conjunction of two other constraints. |
|
87
|
|
|
* |
|
88
|
|
|
* @param ConstraintInterface $constraint1 the first constraint; non-null |
|
89
|
|
|
* @param ConstraintInterface $constraint2 the second constraint; non-null |
|
90
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface the And constraint; non-null |
|
91
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
92
|
|
|
*/ |
|
93
|
|
|
public function _and(ConstraintInterface $constraint1, ConstraintInterface $constraint2) |
|
94
|
|
|
{ |
|
95
|
|
|
return GeneralUtility::makeInstance(LogicalAnd::class, $constraint1, $constraint2); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Performs a logical disjunction of two other constraints. |
|
100
|
|
|
* |
|
101
|
|
|
* @param ConstraintInterface $constraint1 the first constraint; non-null |
|
102
|
|
|
* @param ConstraintInterface $constraint2 the second constraint; non-null |
|
103
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface the Or constraint; non-null |
|
104
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
105
|
|
|
*/ |
|
106
|
|
|
public function _or(ConstraintInterface $constraint1, ConstraintInterface $constraint2) |
|
107
|
|
|
{ |
|
108
|
|
|
return GeneralUtility::makeInstance(LogicalOr::class, $constraint1, $constraint2); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Performs a logical negation of another constraint. |
|
113
|
|
|
* |
|
114
|
|
|
* @param ConstraintInterface $constraint the constraint to be negated; non-null |
|
115
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\NotInterface the Not constraint; non-null |
|
116
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
117
|
|
|
*/ |
|
118
|
|
|
public function not(ConstraintInterface $constraint) |
|
119
|
|
|
{ |
|
120
|
|
|
return GeneralUtility::makeInstance(LogicalNot::class, $constraint); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Filters node-tuples based on the outcome of a binary operation. |
|
125
|
|
|
* |
|
126
|
|
|
* @param PropertyValueInterface $operand1 the first operand; non-null |
|
127
|
|
|
* @param string $operator the operator; one of QueryObjectModelConstants.JCR_OPERATOR_* |
|
128
|
|
|
* @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\StaticOperandInterface $operand2 the second operand; non-null |
|
129
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface the constraint; non-null |
|
130
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
131
|
|
|
*/ |
|
132
|
|
|
public function comparison(PropertyValueInterface $operand1, $operator, $operand2) |
|
133
|
|
|
{ |
|
134
|
|
|
return GeneralUtility::makeInstance(Comparison::class, $operand1, $operator, $operand2); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Evaluates to the value (or values, if multi-valued) of a property in the specified or default selector. |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $propertyName the property name; non-null |
|
141
|
|
|
* @param string $selectorName the selector name; non-null |
|
142
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\PropertyValueInterface the operand; non-null |
|
143
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
144
|
|
|
*/ |
|
145
|
|
|
public function propertyValue($propertyName, $selectorName = '') |
|
146
|
|
|
{ |
|
147
|
|
|
return GeneralUtility::makeInstance(PropertyValue::class, $propertyName, $selectorName); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Evaluates to the lower-case string value (or values, if multi-valued) of an operand. |
|
152
|
|
|
* |
|
153
|
|
|
* @param PropertyValueInterface $operand the operand whose value is converted to a lower-case string; non-null |
|
154
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\LowerCaseInterface the operand; non-null |
|
155
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
156
|
|
|
*/ |
|
157
|
|
|
public function lowerCase(PropertyValueInterface $operand) |
|
158
|
|
|
{ |
|
159
|
|
|
return GeneralUtility::makeInstance(LowerCase::class, $operand); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Evaluates to the upper-case string value (or values, if multi-valued) of an operand. |
|
164
|
|
|
* |
|
165
|
|
|
* @param PropertyValueInterface $operand the operand whose value is converted to an upper-case string; non-null |
|
166
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\UpperCaseInterface the operand; non-null |
|
167
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
168
|
|
|
*/ |
|
169
|
|
|
public function upperCase(PropertyValueInterface $operand) |
|
170
|
|
|
{ |
|
171
|
|
|
return GeneralUtility::makeInstance(UpperCase::class, $operand); |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Orders by the value of the specified operand, in ascending order. |
|
176
|
|
|
* |
|
177
|
|
|
* The query is invalid if $operand does not evaluate to a scalar value. |
|
178
|
|
|
* |
|
179
|
|
|
* @param DynamicOperandInterface $operand the operand by which to order; non-null |
|
180
|
|
|
* @return OrderingInterface the ordering |
|
181
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
182
|
|
|
*/ |
|
183
|
|
|
public function ascending(DynamicOperandInterface $operand) |
|
184
|
|
|
{ |
|
185
|
|
|
return GeneralUtility::makeInstance(Ordering::class, $operand, QueryInterface::ORDER_ASCENDING); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* Orders by the value of the specified operand, in descending order. |
|
190
|
|
|
* |
|
191
|
|
|
* The query is invalid if $operand does not evaluate to a scalar value. |
|
192
|
|
|
* |
|
193
|
|
|
* @param DynamicOperandInterface $operand the operand by which to order; non-null |
|
194
|
|
|
* @return OrderingInterface the ordering |
|
195
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
196
|
|
|
*/ |
|
197
|
|
|
public function descending(DynamicOperandInterface $operand) |
|
198
|
|
|
{ |
|
199
|
|
|
return GeneralUtility::makeInstance(Ordering::class, $operand, QueryInterface::ORDER_DESCENDING); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* Evaluates to the value of a bind variable. |
|
204
|
|
|
* |
|
205
|
|
|
* @param string $bindVariableName the bind variable name; non-null |
|
206
|
|
|
* @return BindVariableValueInterface the operand; non-null |
|
207
|
|
|
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails |
|
208
|
|
|
*/ |
|
209
|
|
|
public function bindVariable($bindVariableName) |
|
210
|
|
|
{ |
|
211
|
|
|
return GeneralUtility::makeInstance(BindVariableValue::class, $bindVariableName); |
|
212
|
|
|
} |
|
213
|
|
|
} |
|
214
|
|
|
|