[CLEANUP] Adjust code to coding guidelines
[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 * Copyright notice
6 *
7 * This class is a backport of the corresponding class of TYPO3 Flow.
8 * All credits go to the TYPO3 Flow team.
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * The Query Object Model Factory
32 */
33 class QueryObjectModelFactory implements \TYPO3\CMS\Core\SingletonInterface {
34
35 /**
36 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
37 */
38 protected $objectManager;
39
40 /**
41 * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
42 * @return void
43 */
44 public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager) {
45 $this->objectManager = $objectManager;
46 }
47
48 /**
49 * Selects a subset of the nodes in the repository based on node type.
50 *
51 * @param string $nodeTypeName the name of the required node type; non-null
52 * @param string $selectorName the selector name; optional
53 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SelectorInterface the selector
54 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
55 */
56 public function selector($nodeTypeName, $selectorName = '') {
57 if ($selectorName === '') {
58 $selectorName = $nodeTypeName;
59 }
60 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Selector', $selectorName, $nodeTypeName);
61 }
62
63 /**
64 * Sets a statement as constraint. This is not part of the JCR 2.0 Specification!
65 *
66 * @param string $statement The statement
67 * @param array $boundVariables An array of variables to bind to the statement
68 * @param object|string $language The language of the statement. Must be a supported languanguage defined as \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory::TYPO3_*
69 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
70 */
71 public function statement($statement, array $boundVariables = array(), $language = \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement::TYPO3_SQL_MYSQL) {
72 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Statement', $statement, $boundVariables, $language);
73 }
74
75 /**
76 * Performs a join between two node-tuple sources.
77 *
78 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $left the left node-tuple source; non-null
79 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $right the right node-tuple source; non-null
80 * @param string $joinType one of QueryObjectModelConstants.JCR_JOIN_TYPE_*
81 * @param JoinConditionInterface $joinCondition
82 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\JoinInterface the join; non-null
83 */
84 public function join(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $left, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $right, $joinType, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\JoinConditionInterface $joinCondition) {
85 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Join', $left, $right, $joinType, $joinCondition);
86 }
87
88 /**
89 * Tests whether the value of a property in a first selector is equal to the value of a property in a second selector.
90 *
91 * @param string $selector1Name the name of the first selector; non-null
92 * @param string $property1Name the property name in the first selector; non-null
93 * @param string $selector2Name the name of the second selector; non-null
94 * @param string $property2Name the property name in the second selector; non-null
95 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\EquiJoinConditionInterface the constraint; non-null
96 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
97 */
98 public function equiJoinCondition($selector1Name, $property1Name, $selector2Name, $property2Name) {
99 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\EquiJoinCondition', $selector1Name, $property1Name, $selector2Name, $property2Name);
100 }
101
102 /**
103 * Performs a logical conjunction of two other constraints.
104 *
105 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1 the first constraint; non-null
106 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2 the second constraint; non-null
107 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface the And constraint; non-null
108 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
109 */
110 public function _and(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2) {
111 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LogicalAnd', $constraint1, $constraint2);
112 }
113
114 /**
115 * Performs a logical disjunction of two other constraints.
116 *
117 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1 the first constraint; non-null
118 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2 the second constraint; non-null
119 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface the Or constraint; non-null
120 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
121 */
122 public function _or(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2) {
123 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LogicalOr', $constraint1, $constraint2);
124 }
125
126 /**
127 * Performs a logical negation of another constraint.
128 *
129 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint the constraint to be negated; non-null
130 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\NotInterface the Not constraint; non-null
131 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
132 */
133 public function not(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint) {
134 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LogicalNot', $constraint);
135 }
136
137 /**
138 * Filters node-tuples based on the outcome of a binary operation.
139 *
140 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1 the first operand; non-null
141 * @param string $operator the operator; one of QueryObjectModelConstants.JCR_OPERATOR_*
142 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\StaticOperandInterface $operand2 the second operand; non-null
143 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface the constraint; non-null
144 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
145 */
146 public function comparison(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1, $operator, $operand2) {
147 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Comparison', $operand1, $operator, $operand2);
148 }
149
150 /**
151 * Evaluates to the value (or values, if multi-valued) of a property in the specified or default selector.
152 *
153 * @param string $propertyName the property name; non-null
154 * @param string $selectorName the selector name; non-null
155 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\PropertyValueInterface the operand; non-null
156 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
157 */
158 public function propertyValue($propertyName, $selectorName = '') {
159 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\PropertyValue', $propertyName, $selectorName);
160 }
161
162 /**
163 * Evaluates to the lower-case string value (or values, if multi-valued) of an operand.
164 *
165 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand whose value is converted to a lower-case string; non-null
166 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\LowerCaseInterface the operand; non-null
167 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
168 */
169 public function lowerCase(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
170 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LowerCase', $operand);
171 }
172
173 /**
174 * Evaluates to the upper-case string value (or values, if multi-valued) of an operand.
175 *
176 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand whose value is converted to a upper-case string; non-null
177 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\UpperCaseInterface the operand; non-null
178 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
179 */
180 public function upperCase(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
181 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\UpperCase', $operand);
182 }
183
184 /**
185 * Orders by the value of the specified operand, in ascending order.
186 *
187 * The query is invalid if $operand does not evaluate to a scalar value.
188 *
189 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand by which to order; non-null
190 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrderingInterface the ordering
191 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
192 */
193 public function ascending(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
194 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Ordering', $operand, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface::JCR_ORDER_ASCENDING);
195 }
196
197 /**
198 * Orders by the value of the specified operand, in descending order.
199 *
200 * The query is invalid if $operand does not evaluate to a scalar value.
201 *
202 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand by which to order; non-null
203 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrderingInterface the ordering
204 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
205 */
206 public function descending(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
207 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Ordering', $operand, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface::JCR_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 \TYPO3\CMS\Extbase\Persistence\Generic\Qom\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 return $this->objectManager->create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\BindVariableValue', $bindVariableName);
219 }
220 }
221
222 ?>