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