|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de> 00006 * All rights reserved 00007 * 00008 * This class is a backport of the corresponding class of FLOW3. 00009 * All credits go to the v5 team. 00010 * 00011 * This script is part of the TYPO3 project. The TYPO3 project is 00012 * free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * The GNU General Public License can be found at 00018 * http://www.gnu.org/copyleft/gpl.html. 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * The Query Object Model Factory 00030 * 00031 * @package Extbase 00032 * @subpackage Persistence\QOM 00033 * @version $Id: QueryObjectModelFactory.php 1972 2010-03-08 16:59:20Z jocrau $ 00034 * @scope prototype 00035 */ 00036 class Tx_Extbase_Persistence_QOM_QueryObjectModelFactory implements t3lib_Singleton { 00037 00038 /** 00039 * @var Tx_Extbase_Object_ObjectManagerInterface 00040 */ 00041 protected $objectManager; 00042 00043 /** 00044 * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager 00045 * @return void 00046 */ 00047 public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) { 00048 $this->objectManager = $objectManager; 00049 } 00050 00051 /** 00052 * Selects a subset of the nodes in the repository based on node type. 00053 * 00054 * @param string $nodeTypeName the name of the required node type; non-null 00055 * @param string $selectorName the selector name; optional 00056 * @return Tx_Extbase_Persistence_QOM_SelectorInterface the selector 00057 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00058 */ 00059 public function selector($nodeTypeName, $selectorName = '') { 00060 if ($selectorName === '') { 00061 $selectorName = $nodeTypeName; 00062 } 00063 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_Selector', $selectorName, $nodeTypeName); 00064 } 00065 00066 /** 00067 * Sets a statement as constraint. This is not part of the JCR 2.0 Specification! 00068 * 00069 * @param string $statement The statement 00070 * @param array $boundVariables An array of variables to bind to the statement 00071 * @param object $language The language of the statement. Must be a supported languanguage defined as Tx_Extbase_Persistence_QOM_QueryObjectModelFactory::TYPO3_* 00072 * @return Tx_Extbase_Persistence_QOM_StatementInterface 00073 */ 00074 public function statement($statement, array $boundVariables = array(), $language = Tx_Extbase_Persistence_QOM_Statement::TYPO3_SQL_MYSQL) { 00075 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_Statement', $statement, $boundVariables, $language); 00076 } 00077 00078 /** 00079 * Performs a join between two node-tuple sources. 00080 * 00081 * @param Tx_Extbase_Persistence_QOM_SourceInterface $left the left node-tuple source; non-null 00082 * @param Tx_Extbase_Persistence_QOM_SourceInterface $right the right node-tuple source; non-null 00083 * @param string $joinType one of QueryObjectModelConstants.JCR_JOIN_TYPE_* 00084 * @param Tx_Extbase_Persistence_QOM_JoinConditionInterface $join Condition the join condition; non-null 00085 * @return Tx_Extbase_Persistence_QOM_JoinInterface the join; non-null 00086 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00087 */ 00088 public function join(Tx_Extbase_Persistence_QOM_SourceInterface $left, Tx_Extbase_Persistence_QOM_SourceInterface $right, $joinType, Tx_Extbase_Persistence_QOM_JoinConditionInterface $joinCondition) { 00089 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_Join', $left, $right, $joinType, $joinCondition); 00090 } 00091 00092 /** 00093 * Tests whether the value of a property in a first selector is equal to the value of a property in a second selector. 00094 * 00095 * @param string $selector1Name the name of the first selector; non-null 00096 * @param string $property1Name the property name in the first selector; non-null 00097 * @param string $selector2Name the name of the second selector; non-null 00098 * @param string $property2Name the property name in the second selector; non-null 00099 * @return Tx_Extbase_Persistence_QOM_EquiJoinConditionInterface the constraint; non-null 00100 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00101 */ 00102 public function equiJoinCondition($selector1Name, $property1Name, $selector2Name, $property2Name) { 00103 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_EquiJoinCondition', $selector1Name, $property1Name, $selector2Name, $property2Name); 00104 } 00105 00106 /** 00107 * Performs a logical conjunction of two other constraints. 00108 * 00109 * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1 the first constraint; non-null 00110 * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2 the second constraint; non-null 00111 * @return Tx_Extbase_Persistence_QOM_AndInterface the And constraint; non-null 00112 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00113 */ 00114 public function _and(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1, Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2) { 00115 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_LogicalAnd', $constraint1, $constraint2); 00116 } 00117 00118 /** 00119 * Performs a logical disjunction of two other constraints. 00120 * 00121 * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1 the first constraint; non-null 00122 * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2 the second constraint; non-null 00123 * @return Tx_Extbase_Persistence_QOM_OrInterface the Or constraint; non-null 00124 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00125 */ 00126 public function _or(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1, Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2) { 00127 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_LogicalOr', $constraint1, $constraint2); 00128 } 00129 00130 /** 00131 * Performs a logical negation of another constraint. 00132 * 00133 * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint the constraint to be negated; non-null 00134 * @return Tx_Extbase_Persistence_QOM_NotInterface the Not constraint; non-null 00135 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00136 */ 00137 public function not(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint) { 00138 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_LogicalNot', $constraint); 00139 } 00140 00141 /** 00142 * Filters node-tuples based on the outcome of a binary operation. 00143 * 00144 * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1 the first operand; non-null 00145 * @param string $operator the operator; one of QueryObjectModelConstants.JCR_OPERATOR_* 00146 * @param Tx_Extbase_Persistence_QOM_StaticOperandInterface $operand2 the second operand; non-null 00147 * @return Tx_Extbase_Persistence_QOM_ComparisonInterface the constraint; non-null 00148 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00149 */ 00150 public function comparison(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1, $operator, $operand2) { 00151 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_Comparison', $operand1, $operator, $operand2); 00152 } 00153 00154 /** 00155 * Evaluates to the value (or values, if multi-valued) of a property in the specified or default selector. 00156 * 00157 * @param string $propertyName the property name; non-null 00158 * @param string $selectorName the selector name; non-null 00159 * @return Tx_Extbase_Persistence_QOM_PropertyValueInterface the operand; non-null 00160 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00161 */ 00162 public function propertyValue($propertyName, $selectorName = '') { 00163 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_PropertyValue', $propertyName, $selectorName); 00164 } 00165 00166 /** 00167 * Evaluates to the lower-case string value (or values, if multi-valued) of an operand. 00168 * 00169 * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand whose value is converted to a lower-case string; non-null 00170 * @return Tx_Extbase_Persistence_QOM_LowerCaseInterface the operand; non-null 00171 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00172 */ 00173 public function lowerCase(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) { 00174 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_LowerCase', $operand); 00175 } 00176 00177 /** 00178 * Evaluates to the upper-case string value (or values, if multi-valued) of an operand. 00179 * 00180 * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand whose value is converted to a upper-case string; non-null 00181 * @return Tx_Extbase_Persistence_QOM_UpperCaseInterface the operand; non-null 00182 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00183 */ 00184 public function upperCase(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) { 00185 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_UpperCase', $operand); 00186 } 00187 00188 /** 00189 * Orders by the value of the specified operand, in ascending order. 00190 * 00191 * The query is invalid if $operand does not evaluate to a scalar value. 00192 * 00193 * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand by which to order; non-null 00194 * @return Tx_Extbase_Persistence_QOM_OrderingInterface the ordering 00195 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00196 */ 00197 public function ascending(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) { 00198 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_Ordering', $operand, Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_ORDER_ASCENDING); 00199 } 00200 00201 /** 00202 * Orders by the value of the specified operand, in descending order. 00203 * 00204 * The query is invalid if $operand does not evaluate to a scalar value. 00205 * 00206 * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand by which to order; non-null 00207 * @return Tx_Extbase_Persistence_QOM_OrderingInterface the ordering 00208 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00209 */ 00210 public function descending(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) { 00211 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_Ordering', $operand, Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_ORDER_DESCENDING); 00212 } 00213 00214 /** 00215 * Evaluates to the value of a bind variable. 00216 * 00217 * @param string $bindVariableName the bind variable name; non-null 00218 * @return Tx_Extbase_Persistence_QOM_BindVariableValueInterface the operand; non-null 00219 * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails 00220 */ 00221 public function bindVariable($bindVariableName) { 00222 return $this->objectManager->create('Tx_Extbase_Persistence_QOM_BindVariableValue', $bindVariableName); 00223 } 00224 00225 } 00226 ?>
1.8.0