[!!!][~API] Extbase (Persistence): Marked Query::withUid() as deprecated. Will be removed with Extbase 3.0.
[+TASK] Extbase (MVC): Fixed missing exception class. Resolves #6732.
[+FEATURE] Extbase (Persistence): Implemented Query::implodeAnd(array) and Query::implodeOr(array). Please give Feedback on this Feature. This is not yet part of the API! Related to #6735.
[+FEATURE] Extbase (Persistence): Query::logicalAnd() and Query::logicalOr() allow 2 or more Constraints as argument, now. This is not yet part of the API! Please give Feedback on this Feature. Related to #6735.
[~TASK] Extbase (Pesistence): Some more code cleaqn-up and improved PHP doc.
$persistenceBackend->injectReflectionService(self::$reflectionService);
$persistenceBackend->injectQueryFactory(t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory'));
$persistenceBackend->injectQomFactory($qomFactory);
- $persistenceBackend->injectValueFactory(t3lib_div::makeInstance('Tx_Extbase_Persistence_ValueFactory'));
$objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_Manager'); // singleton
}
if (!($transformedValue instanceof $this->dataType)) {
- throw new Tx_Extbase_MVC_Exception_InvalidArgumentValueException('The value must be of type "' . $this->dataType . '", but was of type "' . (is_object($transformedValue) ? get_class($transformedValue) : gettype($transformedValue)) . '".', 1251730701);
+ throw new Tx_Extbase_MVC_Exception_InvalidArgumentValue('The value must be of type "' . $this->dataType . '", but was of type "' . (is_object($transformedValue) ? get_class($transformedValue) : gettype($transformedValue)) . '".', 1251730701);
}
return $transformedValue;
}
*/
protected $qomFactory;
- /**
- * @var Tx_Extbase_Persistence_ValueFactoryInterface
- */
- protected $valueFactory;
-
/**
* @var Tx_Extbase_Persistence_Storage_BackendInterface
*/
public function getQomFactory() {
return $this->qomFactory;
}
-
- /**
- * Returns the current value factory
- *
- * @return Tx_Extbase_Persistence_ValueFactoryInterface
- */
- public function getValueFactory() {
- return $this->valueFactory;
- }
-
+
/**
* Returns the current identityMap
*
--- /dev/null
+<?php
+/***************************************************************
+* Copyright notice
+*
+* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+* All rights reserved
+*
+* This class is a backport of the corresponding class of FLOW3.
+* All credits go to the v5 team.
+*
+* This script is part of the TYPO3 project. The TYPO3 project is
+* free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * An "Invalid Number of Constraints" exception.
+ *
+ * @package Extbase
+ * @subpackage Persistence\Exception
+ * @version $ID:$
+ */
+class Tx_Extbase_Persistence_Exception_InvalidNumberOfConstraints extends Tx_Extbase_Persistence_Exception {
+}
+
+?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Exception thrown when an attempt is made to assign a value to a property
- * that has an invalid format, given the type of the property. Also thrown
- * if an attempt is made to read the value of a property using a type-specific
- * read method of a type into which it is not convertible.
- *
- * @package Extbase
- * @subpackage Persistence\Exception
- * @version $Id$
- */
-class Tx_Extbase_Persistence_Exception_ValueFormatException extends Tx_Extbase_Persistence_Exception {
-}
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * An Iterator interface
- *
- * The methods next(), hasNext() and remove() as in java.util.Iterator
- * append() is something we thought would be nice...
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_IteratorInterface extends Iterator {
-
- /**
- * Returns the next element. Commented as PHP dows not allow overriding methods from extended interfaces...
- *
- * @return mixed
- * @throws OutOfBoundsException if no next element exists
- */
- //public function next();
-
- /**
- * Returns true if the iteration has more elements.
- *
- * This is an alias of valid().
- *
- * @return boolean
- */
- public function hasNext();
-
- /**
- * Removes from the underlying collection the last element returned by the iterator.
- * This method can be called only once per call to next. The behavior of an iterator
- * is unspecified if the underlying collection is modified while the iteration is in
- * progress in any way other than by calling this method.
- *
- * @return void
- * @throws IllegalStateException if the next method has not yet been called, or the remove method has already been called after the last call to the next method.
- */
- public function remove();
-
- /**
- * Append a new element to the iteration
- *
- * @param mixed $element
- * @return void
- */
- public function append($element);
-}
-?>
\ No newline at end of file
}
/**
- * Maps the (aggregate root) rows and registers them as reconstituted
- * with the session.
+ * Maps the given rows on objects of the given class
*
- * @param Tx_Extbase_Persistence_RowIteratorInterface $rows
- * @return array
+ * @param string $className The name of the target class
+ * @param array $rows An array of arrays with field_name => value pairs
+ * @return array An array of objects of the given class
*/
- public function map($className, ARRAY $rows) {
+ public function map($className, array $rows) {
$objects = array();
foreach ($rows as $row) {
$objects[] = $this->mapSingleRow($className, $row);
}
/**
- * Maps a single node into the object it represents
+ * Maps a single row on an object of the given class
*
- * @param Tx_Extbase_Persistence_RowInterface $node
- * @return object
+ * @param string $className The name of the target class
+ * @param array $row A single array with field_name => value pairs
+ * @return object An object of the given class
*/
protected function mapSingleRow($className, array $row) {
if ($this->identityMap->hasIdentifier($row['uid'], $className)) {
* @api
* @scope prototype
*/
-class Constraint {}
+class Tx_Extbase_Persistence_QOM_Constraint {
+
+}
?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A query in the JCR query object model.
- *
- * The JCR query object model describes the queries that can be evaluated by a JCR
- * repository independent of any particular query language, such as SQL.
- *
- * A query consists of:
- *
- * a source. When the query is evaluated, the source evaluates its selectors and
- * the joins between them to produce a (possibly empty) set of node-tuples. This
- * is a set of 1-tuples if the query has one selector (and therefore no joins), a
- * set of 2-tuples if the query has two selectors (and therefore one join), a set
- * of 3-tuples if the query has three selectors (two joins), and so forth.
- * an optional constraint. When the query is evaluated, the constraint filters the
- * set of node-tuples.
- * a list of zero or more orderings. The orderings specify the order in which the
- * node-tuples appear in the query results. The relative order of two node-tuples
- * is determined by evaluating the specified orderings, in list order, until
- * encountering an ordering for which one node-tuple precedes the other. If no
- * orderings are specified, or if for none of the specified orderings does one
- * node-tuple precede the other, then the relative order of the node-tuples is
- * implementation determined (and may be arbitrary).
- * a list of zero or more columns to include in the tabular view of the query
- * results. If no columns are specified, the columns available in the tabular view
- * are implementation determined, but minimally include, for each selector, a column
- * for each single-valued non-residual property of the selector's node type.
- *
- * The query object model representation of a query is created by factory methods in the QueryObjectModelFactory.
- *
- * @package Extbase
- * @subpackage Persistence\QOM
- * @version $Id$
- * @scope prototype
- */
-class Tx_Extbase_Persistence_QOM_QueryObjectModel implements Tx_Extbase_Persistence_QOM_QueryObjectModelInterface {
-
- /**
- * @var Tx_Extbase_Persistence_QOM_SourceInterface
- */
- protected $source;
-
- /**
- * @var Tx_Extbase_Persistence_QOM_ConstraintInterface
- */
- protected $constraint;
-
- /**
- * @var array
- */
- protected $orderings;
-
- /**
- * @var array
- */
- protected $columns;
-
- /**
- * @var Tx_Extbase_Persistence_Storage_BackendInterface
- */
- protected $storageBackend;
-
- /**
- * var integer
- */
- protected $limit;
-
- /**
- * integer
- */
- protected $offset;
-
- /**
- * @var array
- */
- protected $boundVariables = array();
-
- /**
- * The query settings
- * @var Tx_Extbase_Persistence_QuerySettingsInterface
- */
- protected $querySettings;
-
- /**
- * Constructs this QueryObjectModel instance
- *
- * @param Tx_Extbase_Persistence_QOM_SourceInterface $selectorOrSource
- * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint (null if none)
- * @param array $orderings
- * @param array $columns
- */
- public function __construct(Tx_Extbase_Persistence_QOM_SourceInterface $selectorOrSource, $constraint, array $orderings = array(), array $columns = array()) {
- $this->source = $selectorOrSource;
- $this->constraint = $constraint;
- $this->orderings = $orderings;
- $this->columns = $columns;
-
- if ($this->constraint !== NULL) {
- $this->constraint->collectBoundVariableNames($this->boundVariables);
- }
- }
-
- /**
- * Injects the StorageBackend
- *
- * @param Tx_Extbase_Persistence_Storage_BackendInterface $storageBackend
- * @return void
- */
- public function injectStorageBackend(Tx_Extbase_Persistence_Storage_BackendInterface $storageBackend) {
- $this->storageBackend = $storageBackend;
- }
-
- /**
- * Sets the Query Settings. These Query settings must match the settings expected by
- * the specific Storage Backend.
- *
- * @param Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
- * @return void
- */
- public function setQuerySettings(Tx_Extbase_Persistence_QuerySettingsInterface $querySettings) {
- $this->querySettings = $querySettings;
- }
-
- /**
- * Returns the Query Settings.
- *
- * @return Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
- */
- public function getQuerySettings() {
- if (!($this->querySettings instanceof Tx_Extbase_Persistence_QuerySettingsInterface)) throw new Tx_Extbase_Persistence_Exception('Tried to get the query settings without seting them before.', 1248689115);
- return $this->querySettings;
- }
-
- /**
- * Sets the maximum size of the result set to limit.
- *
- * @param integer $limit
- * @return void
- */
- public function setLimit($limit) {
- if ($limit < 1 || !is_int($limit)) {
- throw new InvalidArgumentException('setLimit() accepts only integers greater than 0.', 1217244746);
- }
- $this->limit = $limit;
- }
-
- /**
- * Returns the maximum size of the result set.
- *
- * @return integer
- */
- public function getLimit() {
- return $this->limit;
- }
-
- /**
- * Sets the start offset of the result set to offset.
- *
- * @param integer $offset
- * @return void
- */
- public function setOffset($offset) {
- if ($offset < 0 || !is_int($offset)) {
- throw new InvalidArgumentException('setOffset() accepts only integers greater than or equal to 0.', 1217245454);
- }
- $this->offset = $offset;
- }
-
- /**
- * Returns the start offset of the result set.
- *
- * @return integer
- */
- public function getOffset() {
- return $this->offset;
- }
-
- /**
- * Returns the class name the query handles
- *
- * @return string The class name
- */
- public function getSelectorName() {
- $this->source->getSelectorName();
- }
-
- /**
- * Gets the node-tuple source for this query.
- *
- * @return Tx_Extbase_Persistence_QOM_SourceInterface the node-tuple source; non-null
- */
- public function getSource() {
- return $this->source;
- }
-
- /**
- * Gets the constraint for this query.
- *
- * @return Tx_Extbase_Persistence_QOM_ConstraintInterface the constraint, or null if none
- */
- public function getConstraint() {
- return $this->constraint;
- }
-
- /**
- * Gets the orderings for this query.
- *
- * @return array an array of zero or more Tx_Extbase_Persistence_QOM_OrderingInterface; non-null
- */
- public function getOrderings() {
- return $this->orderings;
- }
-
- /**
- * Gets the columns for this query.
- *
- * @return array an array of zero or more Tx_Extbase_Persistence_QOM_ColumnInterface; non-null
- */
- public function getColumns() {
- return $this->columns;
- }
-
- /**
- * Binds the given value to the variable named $varName.
- *
- * @param string $varName name of variable in query
- * @param Tx_Extbase_Persistence_ValueInterface $value value to bind
- * @return void
- * @throws InvalidArgumentException if $varName is not a valid variable in this query.
- * @throws RepositoryException if an error occurs.
- */
- public function bindValue($varName, Tx_Extbase_Persistence_ValueInterface $value) {
- if (array_key_exists($varName, $this->boundVariables) === FALSE) {
- throw new InvalidArgumentException('Invalid variable name "' . $varName . '" given to bindValue.', 1217241834);
- }
- $this->boundVariables[$varName] = $value->getString();
- }
-
- /**
- * Returns the values of all bound variables.
- *
- * @return array()
- */
- public function getBoundVariableValues() {
- return $this->boundVariables;
- }
-
- /**
- * Executes this query and returns a QueryResult object.
- *
- * @return Tx_Extbase_Persistence_QueryResultInterface A QueryResult object
- */
- public function execute() {
- return t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryResult', $this->storageBackend->getRows($this));
- }
-
- /**
- * Executes this query and returns the number of tuples matching the query.
- *
- * @return int The number of tuples matching the query
- */
- public function count() {
- return $this->storageBackend->countRows($this);
- }
-
- /**
- * Returns the statement defined for this query.
- * If the language of this query is string-based (like JCR-SQL2), this method
- * will return the statement that was used to create this query.
- *
- * If the language of this query is JCR-JQOM, this method will return the
- * JCR-SQL2 equivalent of the JCR-JQOM object tree.
- *
- * This is the standard serialization of JCR-JQOM and is also the string stored
- * in the jcr:statement property if the query is persisted. See storeAsNode($absPath).
- *
- * @return string the query statement.
- */
- public function getStatement() {
- $this->storageBackend->getStatement($this);
- }
-
-}
-?>
\ No newline at end of file
* @param string $nodeTypeName the name of the required node type; non-null
* @param string $selectorName the selector name; optional
* @return Tx_Extbase_Persistence_QOM_SelectorInterface the selector
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function selector($nodeTypeName, $selectorName = '') {
* @param string $joinType one of QueryObjectModelConstants.JCR_JOIN_TYPE_*
* @param Tx_Extbase_Persistence_QOM_JoinConditionInterface $join Condition the join condition; non-null
* @return Tx_Extbase_Persistence_QOM_JoinInterface the join; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function join(Tx_Extbase_Persistence_QOM_SourceInterface $left, Tx_Extbase_Persistence_QOM_SourceInterface $right, $joinType, Tx_Extbase_Persistence_QOM_JoinConditionInterface $joinCondition) {
* @param string $selector2Name the name of the second selector; non-null
* @param string $property2Name the property name in the second selector; non-null
* @return Tx_Extbase_Persistence_QOM_EquiJoinConditionInterface the constraint; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function equiJoinCondition($selector1Name, $property1Name, $selector2Name, $property2Name) {
* @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1 the first constraint; non-null
* @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2 the second constraint; non-null
* @return Tx_Extbase_Persistence_QOM_AndInterface the And constraint; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function _and(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1, Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2) {
* @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1 the first constraint; non-null
* @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2 the second constraint; non-null
* @return Tx_Extbase_Persistence_QOM_OrInterface the Or constraint; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function _or(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1, Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2) {
*
* @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint the constraint to be negated; non-null
* @return Tx_Extbase_Persistence_QOM_NotInterface the Not constraint; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function not(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint) {
* @param string $operator the operator; one of QueryObjectModelConstants.JCR_OPERATOR_*
* @param Tx_Extbase_Persistence_QOM_StaticOperandInterface $operand2 the second operand; non-null
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface the constraint; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function comparison(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1, $operator, $operand2) {
* @param string $propertyName the property name; non-null
* @param string $selectorName the selector name; non-null
* @return Tx_Extbase_Persistence_QOM_PropertyValueInterface the operand; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function propertyValue($propertyName, $selectorName = '') {
*
* @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand whose value is converted to a lower-case string; non-null
* @return Tx_Extbase_Persistence_QOM_LowerCaseInterface the operand; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function lowerCase(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) {
*
* @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand whose value is converted to a upper-case string; non-null
* @return Tx_Extbase_Persistence_QOM_UpperCaseInterface the operand; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function upperCase(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) {
*
* @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand by which to order; non-null
* @return Tx_Extbase_Persistence_QOM_OrderingInterface the ordering
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function ascending(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) {
*
* @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand by which to order; non-null
* @return Tx_Extbase_Persistence_QOM_OrderingInterface the ordering
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function descending(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) {
*
* @param string $bindVariableName the bind variable name; non-null
* @return Tx_Extbase_Persistence_QOM_BindVariableValueInterface the operand; non-null
- * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
* @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
*/
public function bindVariable($bindVariableName) {
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A query in the JCR query object model.
- *
- * The JCR query object model describes the queries that can be evaluated by a JCR
- * repository independent of any particular query language, such as SQL.
- *
- * A query consists of:
- *
- * a source. When the query is evaluated, the source evaluates its selectors and
- * the joins between them to produce a (possibly empty) set of node-tuples. This
- * is a set of 1-tuples if the query has one selector (and therefore no joins), a
- * set of 2-tuples if the query has two selectors (and therefore one join), a set
- * of 3-tuples if the query has three selectors (two joins), and so forth.
- * an optional constraint. When the query is evaluated, the constraint filters the
- * set of node-tuples.
- * a list of zero or more orderings. The orderings specify the order in which the
- * node-tuples appear in the query results. The relative order of two node-tuples
- * is determined by evaluating the specified orderings, in list order, until
- * encountering an ordering for which one node-tuple precedes the other. If no
- * orderings are specified, or if for none of the specified orderings does one
- * node-tuple precede the other, then the relative order of the node-tuples is
- * implementation determined (and may be arbitrary).
- * a list of zero or more columns to include in the tabular view of the query
- * results. If no columns are specified, the columns available in the tabular view
- * are implementation determined, but minimally include, for each selector, a column
- * for each single-valued non-residual property of the selector's node type.
- *
- * The query object model representation of a query is created by factory methods in the QueryObjectModelFactory.
- *
- * @package Extbase
- * @subpackage Persistence\QOM
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_QOM_QueryObjectModelInterface {
-
- /**
- * Flags determining the language of the query
- */
- const JCR_JQOM = 'JCR-JQOM';
- const TYPO3_SQL_MYSQL = 'TYPO3-SQL-MYSQL';
-
- /**
- * Gets the node-tuple source for this query.
- *
- * @return Tx_Extbase_Persistence_QOM_SourceInterface the node-tuple source; non-null
- */
- public function getSource();
-
- /**
- * Gets the constraint for this query.
- *
- * @return Tx_Extbase_Persistence_QOM_ConstraintInterface the constraint, or null if none
- */
- public function getConstraint();
-
- /**
- * Gets the orderings for this query.
- *
- * @return array an array of zero or more Tx_Extbase_Persistence_QOM_OrderingInterface; non-null
- */
- public function getOrderings();
-
- /**
- * Gets the columns for this query.
- *
- * @return array an array of zero or more Tx_Extbase_Persistence_QOM_ColumnInterface; non-null
- */
- public function getColumns();
-
- /**
- * Backend specific query settings
- *
- * @return Tx_Extbase_Persistence_Storage_QuerySettingsInterface Backend specific query settings
- */
- public function getQuerySettings();
-
- /**
- * Binds the given value to the variable named $varName.
- *
- * @param string $varName name of variable in query
- * @param Tx_Extbase_Persistence_ValueInterface $value value to bind
- * @return void
- * @throws InvalidArgumentException if $varName is not a valid variable in this query.
- * @throws RepositoryException if an error occurs.
- */
- public function bindValue($varName, Tx_Extbase_Persistence_ValueInterface $value);
-
-}
-
-?>
\ No newline at end of file
* @scope prototype
* @api
*/
-class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterface, Tx_Extbase_Persistence_QuerySettingsInterface {
+class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterface {
/**
* @var string
*/
- protected $className;
+ protected $type;
/**
* @var Tx_Extbase_Persistence_DataMapper
*/
protected $qomFactory;
- /**
- * @var Tx_Extbase_Persistence_ValueFactoryInterface
- */
- protected $valueFactory;
-
/**
* @var Tx_Extbase_Persistence_QOM_SourceInterface
*/
*/
protected $constraint;
- /**
- * An array of named variables and their values from the operators
- * @var array
- */
- protected $operands = array();
-
/**
* @var int
*/
protected $orderings = array();
- /**
- * @var int
- */
- protected $columns = array();
-
/**
* @var int
*/
/**
* Constructs a query object working on the given class name
*
- * @param string $className
+ * @param string $type
*/
- public function __construct($className) {
- $this->className = $className;
+ public function __construct($type) {
+ $this->type = $type;
}
/**
public function injectPersistenceManager(Tx_Extbase_Persistence_ManagerInterface $persistenceManager) {
$this->persistenceManager = $persistenceManager;
$this->qomFactory = $this->persistenceManager->getBackend()->getQomFactory();
- $this->valueFactory = $this->persistenceManager->getBackend()->getValueFactory();
}
/**
*
* @param Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
* @return void
+ * @api This method is not part of FLOW3 API
*/
public function setQuerySettings(Tx_Extbase_Persistence_QuerySettingsInterface $querySettings) {
$this->querySettings = $querySettings;
* Returns the Query Settings.
*
* @return Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
+ * @api This method is not part of FLOW3 API
*/
public function getQuerySettings() {
if (!($this->querySettings instanceof Tx_Extbase_Persistence_QuerySettingsInterface)) throw new Tx_Extbase_Persistence_Exception('Tried to get the query settings without seting them before.', 1248689115);
}
/**
- * Returns the class name the query handles
+ * Returns the type this query cares for.
*
- * @return string The class name
+ * @return string
+ * @api
*/
- public function getClassName() {
- return $this->className;
+ public function getType() {
+ return $this->type;
}
/**
*/
public function getSource() {
if ($this->source === NULL) {
- $this->source = $this->qomFactory->selector($this->className, $this->dataMapper->convertClassNameToTableName($this->className));
+ $this->source = $this->qomFactory->selector($this->getType(), $this->dataMapper->convertClassNameToTableName($this->getType()));
}
return $this->source;
}
if ($this->getQuerySettings()->getReturnRawQueryResult() === TRUE) {
return $rows;
} else {
- return $this->dataMapper->map($this->className, $rows);
+ return $this->dataMapper->map($this->getType(), $rows);
}
}
return $this->persistenceManager->getObjectCountByQuery($this);
}
- /**
- * Prepares and returns a Query Object Model
- *
- * @return Tx_Extbase_Persistence_QOM_QueryObjectModelInterface The prepared query object
- */
- protected function getPreparedQueryObjectModel() {
- if ($this->source === NULL) {
- $this->source = $this->qomFactory->selector($this->className, $this->dataMapper->convertClassNameToTableName($this->className));
- }
- if ($this->constraint instanceof Tx_Extbase_Persistence_QOM_StatementInterface) {
- $query = $this->qomFactory->createQuery(
- $this->source,
- $this->constraint,
- array(),
- array()
- );
- } else {
- $query = $this->qomFactory->createQuery(
- $this->source,
- $this->constraint,
- $this->orderings,
- $this->columns // TODO implement selection of columns
- );
-
- if ($this->limit !== NULL) {
- $query->setLimit($this->limit);
- }
- if ($this->offset !== NULL) {
- $query->setOffset($this->offset);
- }
-
- }
-
- foreach ($this->operands as $name => $value) {
- if (is_array($value)) {
- $newValue = array();
- foreach ($value as $valueItem) {
- $newValue[] = $this->valueFactory->createValue($valueItem);
- }
- $query->bindValue($name, $this->valueFactory->createValue($newValue));
- } else {
- $query->bindValue($name, $this->valueFactory->createValue($value));
- }
- }
- $query->setQuerySettings($this->getQuerySettings());
- return $query;
- }
-
/**
* Sets the property names to order the result by. Expected like this:
* array(
}
/**
- * Performs a logical conjunction of the two given constraints.
+ * Performs a logical conjunction of the given constraints.
*
* @param object $constraint1 First constraint
* @param object $constraint2 Second constraint
* @return Tx_Extbase_Persistence_QOM_AndInterface
- * @api
+ * @api Passing more than two constraints as arguments is currently not yet conform to the api of FLOW3
*/
public function logicalAnd($constraint1, $constraint2) {
- return $this->qomFactory->_and(
- $constraint1,
- $constraint2
- );
+ $constraints = func_get_args();
+ $numberOfConstraints = func_num_args();
+ if (func_num_args() > 1) {
+ $resultingConstraint = array_shift($constraints);
+ foreach ($constraints as $constraint) {
+ $resultingConstraint = $this->qomFactory->_and(
+ $resultingConstraint,
+ $constraint
+ );
+ }
+ } else {
+ throw new Tx_Extbase_Persistence_Exception_InvalidNumberOfConstraints('There must be at least two constraints. Got only ' . func_num_args() . '.', 1268056288);
+ }
+ return $resultingConstraint;
+ }
+
+ /**
+ * Performs a logical conjunction of the given constraints.
+ *
+ * @param array $constraints An array of constraints
+ * @return Tx_Extbase_Persistence_QOM_AndInterface
+ */
+ public function implodeAnd(array $constraints) {
+ $numberOfConstraints = count($constraints);
+ $resultingConstraint = NULL;
+ if ($numberOfConstraints === 1) {
+ return array_shift($constraints);
+ } elseif ($numberOfConstraints > 1) {
+ $resultingConstraint = array_shift($constraints);
+ foreach ($constraints as $constraint) {
+ $resultingConstraint = $this->qomFactory->_and(
+ $resultingConstraint,
+ $constraint
+ );
+ }
+ }
+ return $resultingConstraint;
}
/**
* @param object $constraint1 First constraint
* @param object $constraint2 Second constraint
* @return Tx_Extbase_Persistence_QOM_OrInterface
- * @api
+ * @api Passing more than two constraints as arguments is currently not yet conform to the api of FLOW3
*/
public function logicalOr($constraint1, $constraint2) {
- return $this->qomFactory->_or(
- $constraint1,
- $constraint2
- );
+ $constraints = func_get_args();
+ $numberOfConstraints = func_num_args();
+ if (func_num_args() > 1) {
+ $resultingConstraint = array_shift($constraints);
+ foreach ($constraints as $constraint) {
+ $resultingConstraint = $this->qomFactory->_or(
+ $resultingConstraint,
+ $constraint
+ );
+ }
+ } else {
+ throw new Tx_Extbase_Persistence_Exception_InvalidNumberOfConstraints('There must be at least two constraints. Got only ' . func_num_args() . '.', 1268056288);
+ }
+ return $resultingConstraint;
+ }
+
+ /**
+ * Performs a logical conjunction of the given constraints.
+ *
+ * @param array $constraints An array of constraints
+ * @return Tx_Extbase_Persistence_QOM_AndInterface
+ */
+ public function implodeOr(array $constraints) {
+ $numberOfConstraints = count($constraints);
+ $resultingConstraint = NULL;
+ if ($numberOfConstraints === 1) {
+ return array_shift($constraints);
+ } elseif ($numberOfConstraints > 1) {
+ $resultingConstraint = array_shift($constraints);
+ foreach ($constraints as $constraint) {
+ $resultingConstraint = $this->qomFactory->_or(
+ $resultingConstraint,
+ $constraint
+ );
+ }
+ }
+ return $resultingConstraint;
}
/**
*
* @param int $uid The uid to match against
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
- * @api
+ * @deprecated since Extbase 2.0; was removed in FLOW3; will be removed in Extbase 3.0; use equals() Ãnstead
*/
public function withUid($operand) {
+ t3lib_div::logDeprecatedFunction();
return $this->qomFactory->comparison(
$this->qomFactory->propertyValue('uid', $this->getSelectorName()),
Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO,
* @param mixed $operand The value to compare with
* @param boolean $caseSensitive Whether the equality test should be done case-sensitive
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
+ * @api
*/
public function equals($propertyName, $operand, $caseSensitive = TRUE) {
if (is_object($operand) || $caseSensitive) {
* @param string $propertyName The name of the property to compare against
* @param mixed $operand The value to compare with
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
+ * @api
*/
public function like($propertyName, $operand) {
return $this->qomFactory->comparison(
* @param string $propertyName The name of the property to compare against
* @param mixed $operand The value to compare with
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
+ * @api
*/
public function lessThan($propertyName, $operand) {
return $this->qomFactory->comparison(
* @param string $propertyName The name of the property to compare against
* @param mixed $operand The value to compare with
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
+ * @api
*/
public function lessThanOrEqual($propertyName, $operand) {
return $this->qomFactory->comparison(
* @param string $propertyName The name of the property to compare against
* @param mixed $operand The value to compare with
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
+ * @api
*/
public function greaterThan($propertyName, $operand) {
return $this->qomFactory->comparison(
* @param string $propertyName The name of the property to compare against
* @param mixed $operand The value to compare with
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
+ * @api
*/
public function greaterThanOrEqual($propertyName, $operand) {
return $this->qomFactory->comparison(
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A QueryResult object. Returned by Query->execute().
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- * @scope prototype
- */
-class Tx_Extbase_Persistence_QueryResult implements Tx_Extbase_Persistence_QueryResultInterface {
-
- /**
- * @var array The rows of the query result
- */
- protected $rows;
-
- /**
- * Constructs this QueryResult
- *
- * @param array $rows The
- */
- public function __construct(array $rows) {
- $this->rows = $rows;
- }
-
- /**
- * Returns an array of all the column names in the table view of this result set.
- *
- * @return array array holding the column names.
- */
- public function getColumnNames() {
- if (!is_null($this->rows)) {
- return array_keys($this->rows[0]);
- } else {
- return array();
- }
- }
-
- /**
- * Returns an iterator over the Rows of the result table. The rows are
- * returned according to the ordering specified in the query.
- *
- * @return Tx_Extbase_Persistence_RowIteratorInterface a RowIterator
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if this call is the second time either getRows() or getNodes() has been called on the same QueryResult object or if another error occurs.
- */
- public function getRows() {
- if ($this->rows === NULL) throw new Tx_Extbase_Persistence_Exception_RepositoryException('Illegal getRows() call - can be called only once.', 1237991809);
-
- $rowIterator = t3lib_div::makeInstance('Tx_Extbase_Persistence_RowIterator');
- foreach ($this->rows as $row) {
- $rowIterator->append(t3lib_div::makeInstance('Tx_Extbase_Persistence_Row', $row));
- }
- $this->rows = NULL;
-
- return $rowIterator;
- }
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A persistence query result interface
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_QueryResultInterface {
-
- /**
- * Constructs this QueryResult
- *
- * @param array $identifiers
- */
- public function __construct(array $tuples);
-
- /**
- * Returns an array of all the column names in the table view of this result set.
- *
- * @return array array holding the column names.
- * @throws Tx_Extbase_Persistence_Exeption_RepositoryException if an error occurs.
- */
- public function getColumnNames();
-
- /**
- * Returns an iterator over the Rows of the result table. The rows are
- * returned according to the ordering specified in the query.
- *
- * @return IteratorInterface a RowIterator
- * @throws Tx_Extbase_Persistence_Exeption_RepositoryException if this call is the second time either getRows() or getNodes() has been called on the same QueryResult object or if another error occurs.
- */
- public function getRows();
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A RangeIterator
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- * @scope prototype
- */
-class Tx_Extbase_Persistence_RangeIterator implements Tx_Extbase_Persistence_RangeIteratorInterface {
-
- /**
- * @var array
- */
- protected $elements;
-
- /**
- * @var integer
- */
- protected $position = 0;
-
- /**
- * Constructs a new RangeIterator
- *
- * @param array $elements The elements to populate the iterator with
- * @return void
- */
- public function __construct(array $elements = array()) {
- $this->elements = $elements;
- }
-
- /**
- * Append a new element to the end of the iteration
- *
- * @param mixed $element The element to append to the iteration
- * @return void
- */
- public function append($element) {
- $this->elements[] = $element;
- }
-
- /**
- * Removes the last element returned by next()
- *
- * @return void
- */
- public function remove() {
- $positionToRemove = $this->getPosition()-1;
- array_splice($this->elements, $positionToRemove, 1);
- // array_splice resets the array pointer, so we fix it together with the internal position
- for ($skipped = 0; $skipped < --$this->position; $skipped++) next($this->elements);
- }
-
- /**
- * Returns FALSE if there are more elements available.
- *
- * @return boolean
- */
- public function hasNext() {
- return $this->getPosition() < $this->getSize();
- }
-
- /**
- * Return the next (i.e. current) element in the iterator
- *
- * @return mixed The next element in the iteration
- */
- public function next() {
- if ($this->hasNext()) {
- $this->position++;
- $element = current($this->elements);
- next($this->elements);
- return $element;
- } else {
- throw new OutOfBoundsException('Tried to go past the last element in the iterator.', 1187530869);
- }
- }
-
- /**
- * Skip a number of elements in the iterator.
- *
- * @param integer $skipNum the non-negative number of elements to skip
- * @return void
- * @throws OutOfBoundsException if skipped past the last element in the iterator.
- */
- public function skip($skipNum) {
- $newPosition = $this->getPosition() + $skipNum;
- if ($newPosition > $this->getSize()) {
- throw new OutOfBoundsException('Skip operation past the last element in the iterator.', 1187530862);
- } else {
- $this->position = $newPosition;
- for ($skipped = 0; $skipped < $skipNum; $skipped++) next($this->elements);
- }
- }
-
- /**
- * Returns the total number of of items available through this iterator.
- *
- * For example, for some node $n, $n->getNodes()->getSize() returns the number
- * of child nodes of $n visible through the current Session.
- *
- * In some implementations precise information about the number of elements may
- * not be available. In such cases this method must return -1. API clients will
- * then be able to use RangeIterator->getNumberRemaining() to get an
- * estimate on the number of elements.
- *
- * @return integer
- */
- public function getSize() {
- return count($this->elements);
- }
-
- /**
- * Returns the current position within the iterator. The number
- * returned is the 0-based index of the next element in the iterator,
- * i.e. the one that will be returned on the subsequent next() call.
- *
- * Note that this method does not check if there is a next element,
- * i.e. an empty iterator will always return 0.
- *
- * @return integer The current position, 0-based
- */
- public function getPosition() {
- return $this->position;
- }
-
- // non-JSR-283 methods below
-
- /**
- * Alias for hasNext(), valid() is required by SPL Iterator
- *
- * @return boolean
- */
- public function valid() {
- return $this->hasNext();
- }
-
- /**
- * Rewinds the element cursor, required by SPL Iterator
- *
- * @return void
- */
- public function rewind() {
- $this->position = 0;
- reset($this->elements);
- }
-
- /**
- * Returns the current element, i.e. the element the last next() call returned
- * Required by SPL Iterator
- *
- * @return mixed The current element
- */
- public function current() {
- return current($this->elements);
- }
-
- /**
- * Returns the key of the current element
- * Required by SPL Iterator
- *
- * return integer The key of the current element
- */
- public function key() {
- return $this->getPosition();
- }
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Extends Iterator with the skip, getSize and getPosition methods. The base
- * interface of all type-specific iterators in the JCR and its sub packages.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_RangeIteratorInterface extends Tx_Extbase_Persistence_IteratorInterface {
-
- /**
- * Skip a number of elements in the iterator.
- *
- * @param integer $skipNum the non-negative number of elements to skip
- * @throws OutOfBoundsException if skipped past the last element in the iterator.
- */
- public function skip($skipNum);
-
- /**
- * Returns the total number of of items available through this iterator.
- *
- * For example, for some node $n, $n->getNodes()->getSize() returns the
- * number of child nodes of $n visible through the current Session.
- *
- * In some implementations precise information about the number of elements may
- * not be available. In such cases this method must return -1. API clients will
- * then be able to use RangeIterator->getNumberRemaining() to get an
- * estimate on the number of elements.
- *
- * @return integer
- */
- public function getSize();
-
- /**
- * Returns the current position within the iterator. The number
- * returned is the 0-based index of the next element in the iterator,
- * i.e. the one that will be returned on the subsequent next() call.
- *
- * Note that this method does not check if there is a next element,
- * i.e. an empty iterator will always return 0.
- *
- * @return integer
- */
- public function getPosition();
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A row in the query result table.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- * @scope prototype
- */
-class Tx_Extbase_Persistence_Row implements Tx_Extbase_Persistence_RowInterface {
-
- /**
- * @var array
- */
- protected $tuple;
-
- /**
- * Constructs this Row instance
- *
- * @param array $tuple
- */
- public function __construct(array $tuple = array()) {
- $this->tuple = $tuple;
- }
-
- /**
- * @return boolean TRUE if the columnName is set
- */
- public function hasValue($columnName) {
- return $this->offsetExists($columnName);
- }
-
- /**
- * Returns an array of all the values in the same order as the column names
- * returned by QueryResult.getColumnNames().
- *
- * @return array a Value array.
- */
- public function getValues() {
- return array_values($this->tuple);
- }
-
- /**
- * Returns the value of the indicated column in this Row.
- *
- * @param string $columnName name of query result table column
- * @return Tx_Extbase_Persistence_ValueInterface a Value
- */
- public function getValue($columnName) {
- return $this->offsetGet($columnName);
- }
-
- /**
- * Loads the row at a given offset.
- *
- * @param string $offset
- * @param mixed $value The value
- * @return void
- */
- public function offsetSet($offset, $value) {
- $this->tuple[$offset] = $value;
- }
-
- /**
- * Checks if a given offset exists in the row
- *
- * @param string $offset
- * @return boolean TRUE if the given offset exists; otherwise FALSE
- */
- public function offsetExists($offset) {
- return isset($this->tuple[$offset]);
- }
-
- /**
- * Unsets the storage at the given offset
- *
- * @param string $offset The offset
- * @return void
- */
- public function offsetUnset($offset) {
- unset($this->tuple[$offset]);
- }
-
- /**
- * Returns the value at the given offset
- *
- * @param string $offset The offset
- * @return The value|NULL if the offset does not exist
- */
- public function offsetGet($offset) {
- return $this->offsetExists($offset) ? $this->tuple[$offset] : NULL;
- }
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A row in the query result table.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_RowInterface {
-
- /**
- * @return boolean TRUE if the columnName is set
- */
- public function hasValue($columnName);
-
- /**
- * Returns an array of all the values in the same order as the column names
- * returned by QueryResult.getColumnNames().
- *
- * @return array a Value array.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if an error occurs
- */
- public function getValues();
-
- /**
- * Returns the value of the indicated column in this Row.
- *
- * @param string $columnName name of query result table column
- * @return \F3\PHPCR\ValueInterface a Value
- * @throws \F3\PHPCR\ItemNotFoundException if columnName s not among the column names of the query result table.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getValue($columnName);
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Allows easy iteration through a list of Rows with nextRow as well as a skip
- * method inherited from RangeIterator.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- * @scope prototype
- */
-class Tx_Extbase_Persistence_RowIterator extends Tx_Extbase_Persistence_RangeIterator implements Tx_Extbase_Persistence_RowIteratorInterface {
-
- /**
- * Returns the next Row in the iteration.
- *
- * @return Tx_Extbase_Persistence_RowInterface
- * @throws OutOfBoundsException if the iterator contains no more elements.
- */
- public function nextRow() {
- return $this->next();
- }
-
-}
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Allows easy iteration through a list of Rows with nextRow as well as a skip
- * method inherited from RangeIterator.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_RowIteratorInterface extends Tx_Extbase_Persistence_RangeIteratorInterface {
-
- /**
- * Returns the next Row in the iteration.
- *
- * @return Tx_Extbase_Persistence_RowInterface
- * @throws OutOfBoundsException if the iterator contains no more elements.
- */
- public function nextRow();
-
-}
-
-?>
\ No newline at end of file
const OPERATOR_EQUAL_TO_NULL = 'operatorEqualToNull';
const OPERATOR_NOT_EQUAL_TO_NULL = 'operatorNotEqualToNull';
- const OPERATOR_IN = 'operatorIn';
- const OPERATOR_NOT_IN = 'operatorNotIn';
-
+
/**
* The TYPO3 database object
*
$sql['fields'][] = $tableName . '.*';
$sql['tables'][] = $tableName;
$querySettings = $query->getQuerySettings();
- if ($querySettings instanceof Tx_Extbase_Persistence_Typo3QuerySettingsInterface) {
+ if ($querySettings instanceof Tx_Extbase_Persistence_QuerySettingsInterface) {
if ($querySettings->getRespectEnableFields()) {
$this->addEnableFieldsStatement($tableName, $sql);
}
* @return void
*/
protected function parseConstraint(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint = NULL, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters) {
- if ($constraint === NULL) return;
if ($constraint instanceof Tx_Extbase_Persistence_QOM_AndInterface) {
$sql['where'][] = '(';
$this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters);
$sql['where'][] = ')';
} elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_ComparisonInterface) {
$this->parseComparison($constraint, $source, $sql, $parameters);
- } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_RelatedInterface) {
- $this->parseRelated($constraint, $sql, $parameters);
}
}
// FIXME this else branch enables equals() to behave like in(). This behavior is deprecated and will be removed in future. Use in() instead.
$operator = Tx_Extbase_Persistence_QueryInterface::OPERATOR_IN;
}
-
- if ($operand2 === NULL) {
- if ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO) {
- $operator = self::OPERATOR_EQUAL_TO_NULL;
- } elseif ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_NOT_EQUAL_TO) {
- $operator = self::OPERATOR_NOT_EQUAL_TO_NULL;
- }
- }
-
+
if ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_IN) {
- $this->parseDynamicOperand($operand1, $operator, $source, $sql, $parameters, NULL, $operand2);
$items = array();
+ $hasValue = FALSE;
foreach ($operand2 as $value) {
- $items[] = $this->getPlainValue($value);
+ $value = $this->getPlainValue($value);
+ if ($value !== NULL) {
+ $items[] = $value;
+ $hasValue = TRUE;
+ }
+ }
+ if ($hasValue === FALSE) {
+ $sql['where'][] = '1<>1';
+ } else {
+ $this->parseDynamicOperand($operand1, $operator, $source, $sql, $parameters, NULL, $operand2);
+ $items = array();
+ foreach ($operand2 as $value) {
+ $items[] = $this->getPlainValue($value);
+ }
+ $parameters[] = $items;
}
- $parameters[] = $items;
} elseif ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_CONTAINS) {
- $dataMap = $this->dataMapper->getDataMap($source->getNodeTypeName());
- $columnMap = $dataMap->getColumnMap($operand1->getPropertyName());
- $typeOfRelation = $columnMap->getTypeOfRelation();
- if ($typeOfRelation === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
- $relationTableName = $columnMap->getRelationTableName();
- $sql['where'][] = 'uid IN (SELECT uid_local FROM ' . $relationTableName . ' WHERE uid_foreign=' . $this->getPlainValue($operand2) . ')';
- } elseif ($typeOfRelation === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
- $parentKeyFieldName = $columnMap->getParentKeyFieldName();
- if (isset($parentKeyFieldName)) {
- $columnName = $this->dataMapper->convertPropertyNameToColumnName($operand1->getPropertyName(), $source->getNodeTypeName());
- $childTableName = $columnMap->getChildTableName();
- $sql['where'][] = 'uid=(SELECT ' . $childTableName . '.' . $parentKeyFieldName . ' FROM ' . $childTableName . ' WHERE ' . $childTableName . '.uid=' . $this->getPlainValue($operand2) . ')';
+ if ($operand2 === NULL) {
+ $sql['where'][] = '1<>1';
+ } else {
+ $dataMap = $this->dataMapper->getDataMap($source->getNodeTypeName());
+ $columnMap = $dataMap->getColumnMap($operand1->getPropertyName());
+ $typeOfRelation = $columnMap->getTypeOfRelation();
+ if ($typeOfRelation === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
+ $relationTableName = $columnMap->getRelationTableName();
+ $sql['where'][] = 'uid IN (SELECT uid_local FROM ' . $relationTableName . ' WHERE uid_foreign=' . $this->getPlainValue($operand2) . ')';
+ } elseif ($typeOfRelation === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
+ $parentKeyFieldName = $columnMap->getParentKeyFieldName();
+ if (isset($parentKeyFieldName)) {
+ $columnName = $this->dataMapper->convertPropertyNameToColumnName($operand1->getPropertyName(), $source->getNodeTypeName());
+ $childTableName = $columnMap->getChildTableName();
+ $sql['where'][] = 'uid=(SELECT ' . $childTableName . '.' . $parentKeyFieldName . ' FROM ' . $childTableName . ' WHERE ' . $childTableName . '.uid=' . $this->getPlainValue($operand2) . ')';
+ } else {
+ $tableName = $operand1->getSelectorName();
+ $statement = '(' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'%,' . $this->getPlainValue($operand2) . ',%\'';
+ $statement .= ' OR ' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'%,' . $this->getPlainValue($operand2) . '\'';
+ $statement .= ' OR ' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'' . $this->getPlainValue($operand2) . ',%\')';
+ $sql['where'][] = $statement;
+ }
} else {
- $tableName = $operand1->getSelectorName();
- $statement = '(' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'%,' . $this->getPlainValue($operand2) . ',%\'';
- $statement .= ' OR ' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'%,' . $this->getPlainValue($operand2) . '\'';
- $statement .= ' OR ' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'' . $this->getPlainValue($operand2) . ',%\')';
- $sql['where'][] = $statement;
+ throw new Tx_Extbase_Persistence_Exception_RepositoryException('Unsupported relation for contains().', 1267832524);
}
- } else {
- throw new Tx_Extbase_Persistence_Exception_RepositoryException('Unsupported relation for contains().', 1267832524);
}
} else {
+ if ($operand2 === NULL) {
+ if ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO) {
+ $operator = self::OPERATOR_EQUAL_TO_NULL;
+ } elseif ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_NOT_EQUAL_TO) {
+ $operator = self::OPERATOR_NOT_EQUAL_TO_NULL;
+ }
+ }
$this->parseDynamicOperand($operand1, $operator, $source, $sql, $parameters);
- $parameters[] = $this->getPlainValue($operand2);
+ $parameters[] = $this->getPlainValue($operand2);
}
}
protected function getPlainValue($input) {
if ($input instanceof DateTime) {
return $input->getTimestamp();
- } elseif ($input instanceof Tx_Extbase_DomainObject_DomainObjectinterface) {
+ } elseif ($input instanceof Tx_Extbase_DomainObject_DomainObjectInterface) {
return $input->getUid();
+ } elseif (is_bool($input)) {
+ return $input === TRUE ? 1 : 0;
} else {
return $input;
}
* @version $Id$
* @api
*/
-class Tx_Extbase_Persistence_Typo3QuerySettings implements Tx_Extbase_Persistence_Typo3QuerySettingsInterface {
+class Tx_Extbase_Persistence_Typo3QuerySettings implements Tx_Extbase_Persistence_QuerySettingsInterface {
/**
* Flag if the storage page should be respected for the query.
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * TYPO3 Query settings interface. This interfaceis NOT part of the FLOW3 API.
- * It reflects the settings unique to TYPO3 4.x.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- * @api
- */
-interface Tx_Extbase_Persistence_Typo3QuerySettingsInterface extends Tx_Extbase_Persistence_QuerySettingsInterface {
-
- /**
- * Sets the flag if the storage page should be respected for the query.
- *
- * @param $respectStoragePage If TRUE the storage page ID will be determined and the statement will be extended accordingly.
- * @return $this (fluent interface)
- * @api
- */
- public function setRespectStoragePage($respectStoragePage);
-
- /**
- * Sets the flag if the visibility in the frontend should be respected.
- *
- * @param $respectEnableFields TRUE if the visibility in the frontend should be respected. If TRUE, the "enable fields" of TYPO3 will be added to the query statement.
- * @return $this (fluent interface)
- * @api
- */
- public function setRespectEnableFields($respectEnableFields);
-
- /**
- * Sets the flag if if the sys language should be respected.
- *
- * @param $respectSysLanguage TRUE if the sys language should be respected.
- * @return $this (fluent interface)
- * @api
- */
- public function setRespectSysLanguage($respectSysLanguage);
-
- /**
- * Returns the state, if the sys language should be respected.
- *
- * @return boolean TRUE, if the sys language should be respected; otherwise FALSE.
- */
- public function getRespectSysLanguage();
-
-
- /**
- * Sets the state, if the QueryResult should be returned unmapped.
- *
- * @return boolean TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
- * @api
- */
- public function setReturnRawQueryResult($returnRawQueryResult);
-
- /**
- * Returns the state, if the QueryResult should be returned unmapped.
- *
- * @return boolean TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
- * @api
- */
- public function getReturnRawQueryResult();
-
-}
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A generic holder for the value of a property. A Value object can be used
- * without knowing the actual property type (STRING, DOUBLE, BINARY etc.).
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- * @scope prototype
- */
-class Tx_Extbase_Persistence_Value implements Tx_Extbase_Persistence_ValueInterface {
-
- /**
- * @var mixed
- */
- protected $value;
-
- /**
- * @var integer
- */
- protected $type;
-
- /**
- * Constructs a Value object from the given $value and $type arguments
- *
- * @param mixed $value The value of the Value object
- * @param integer $type A type, see constants in \F3\PHPCR\PropertyType
- * @return void
- */
- public function __construct($value, $type) {
- $this->value = $value;
- $this->type = $type;
- }
-
- /**
- * Returns a string representation of this value. For Value objects being
- * of type DATE the string will conform to ISO8601 format.
- *
- * @return string A String representation of the value of this property.
- */
- public function getString() {
- if ($this->value === NULL) return NULL;
- if (is_array($this->value)) return $this->value;
- if ($this->value instanceof Tx_Extbase_DomainObject_AbstractDomainObject) {
- return (string)$this->value->getUid();
- }
-
- switch ($this->type) {
- case Tx_Extbase_Persistence_PropertyType::DATE:
- if (is_a($this->value, 'DateTime')) {
- return $this->value->format('U');
- } else {
- $this->value = new DateTime($this->value);
- return $this->value->format('U');
- }
- case Tx_Extbase_Persistence_PropertyType::BOOLEAN:
- return (string)(int)$this->value;
- default:
- return (string)$this->value;
- }
- }
-
- /**
- * Returns the value as string, alias for getString()
- *
- * @return string
- */
- public function __toString() {
- return $this->getString();
- }
-
- /**
- * Returns a Binary representation of this value. The Binary object in turn provides
- * methods to access the binary data itself. Uses the standard conversion to binary
- * (see JCR specification).
- *
- * @return \F3\TYPO3CR\Binary A Binary representation of this value.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getBinary() {
- throw new Tx_Extbase_Persistence_Exception_UnsupportedMethod('Method not yet implemented, sorry!', 1217843676);
- }
-
- /**
- * Returns a long (integer) representation of this value.
- *
- * @return string A long representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a long is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getLong() {
- return (int)$this->value;
- }
-
- /**
- * Returns a BigDecimal representation of this value (aliased to getDouble()).
- *
- * @return float A double representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getDecimal() {
- return $this->getDouble();
- }
-
- /**
- * Returns a double (floating point) representation of this value.
- *
- * @return float A double representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a double is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getDouble() {
- return (double)$this->value;
- }
-
- /**
- * Returns a DateTime representation of this value.
- *
- * @return DateTime A DateTime representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a \DateTime is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getDate() {
- if (is_a($this->value, 'DateTime')) {
- return clone($this->value);
- }
-
- try {
- return new DateTime($this->value);
- } catch (Exception $e) {
- throw new Tx_Extbase_Persistence_Exception_ValueFormatException('Conversion to a DateTime object is not possible. Cause: ' . $e->getMessage(), 1190034628);
- }
- }
-
- /**
- * Returns a boolean representation of this value.
- *
- * @return string A boolean representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a boolean is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getBoolean() {
- return (boolean)$this->value;
- }
-
- /**
- * Returns the type of this Value. One of:
- * * \F3\PHPCR\PropertyType::STRING
- * * \F3\PHPCR\PropertyType::DATE
- * * \F3\PHPCR\PropertyType::BINARY
- * * \F3\PHPCR\PropertyType::DOUBLE
- * * \F3\PHPCR\PropertyType::DECIMAL
- * * \F3\PHPCR\PropertyType::LONG
- * * \F3\PHPCR\PropertyType::BOOLEAN
- * * \F3\PHPCR\PropertyType::NAME
- * * \F3\PHPCR\PropertyType::PATH
- * * \F3\PHPCR\PropertyType::REFERENCE
- * * \F3\PHPCR\PropertyType::WEAKREFERENCE
- * * \F3\PHPCR\PropertyType::URI
- *
- * The type returned is that which was set at property creation.
- * @return integer The type of the value
- */
- public function getType() {
- return $this->type;
- }
-
-}
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A ValueFactory, used to create Value objects.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- * @scope prototype
- */
-class Tx_Extbase_Persistence_ValueFactory implements Tx_Extbase_Persistence_ValueFactoryInterface {
-
- /**
- * Returns a Value object with the specified value. If $type is given,
- * conversion is attempted before creating the Value object.
- *
- * If no type is given, the value is stored as is, i.e. it's type is
- * preserved. Exceptions are:
- * * if the given $value is a Node object, it's Identifier is fetched for the
- * Value object and the type of that object will be REFERENCE
- * * if the given $value is a Node object, it's Identifier is fetched for the
- * Value object and the type of that object will be WEAKREFERENCE if $weak
- * is set to TRUE
- * * if the given $Value is a \DateTime object, the Value type will be DATE.
- *
- * @param mixed $value The value to use when creating the Value object
- * @param integer $type Type request for the Value object
- * @param boolean $weak When a Node is given as $value this can be given as TRUE to create a WEAKREFERENCE, $type is ignored in that case!
- * @return \F3\PHPCR\ValueInterface
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException is thrown if the specified value cannot be converted to the specified type.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the specified Node is not referenceable, the current Session is no longer active, or another error occurs.
- * @throws \IllegalArgumentException if the specified DateTime value cannot be expressed in the ISO 8601-based format defined in the JCR 2.0 specification and the implementation does not support dates incompatible with that format.
- */
- public function createValue($value, $type = Tx_Extbase_Persistence_PropertyType::UNDEFINED, $weak = FALSE) {
- if (is_array($value) && array_key_exists('uid', $value)) {
- $value = $value['uid'];
- }
-
- if ($type === Tx_Extbase_Persistence_PropertyType::UNDEFINED) {
- return t3lib_div::makeInstance('Tx_Extbase_Persistence_Value', $value, self::guessType($value));
- } else {
- return $this->createValueWithGivenType($value, $type);
- }
- }
-
- /**
- * Returns a Value object with the specified value. Conversion from string
- * is attempted before creating the Value object.
- *
- * @param mixed $value
- * @param integer $type
- * @return \F3\PHPCR\ValueInterface
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException is thrown if the specified value cannot be converted to the specified type.
- */
- protected function createValueWithGivenType($value, $type) {
- switch ($type) {
- case Tx_Extbase_Persistence_PropertyType::DATE:
- try {
- $value = new DateTime($value);
- } catch (Exception $e) {
- throw new Tx_Extbase_Persistence_Exception_ValueFormatException('The given value could not be converted to a DateTime object.', 1211372741);
- }
- break;
- case Tx_Extbase_Persistence_PropertyType::BINARY:
- // we do not do anything here, getBinary on Value objects does the hard work
- break;
- case Tx_Extbase_Persistence_PropertyType::DECIMAL:
- case Tx_Extbase_Persistence_PropertyType::DOUBLE:
- $value = (float)$value;
- break;
- case Tx_Extbase_Persistence_PropertyType::BOOLEAN:
- $value = (boolean)$value;
- break;
- case Tx_Extbase_Persistence_PropertyType::LONG:
- $value = (int)$value;
- break;
- }
- return t3lib_div::makeInstance('Tx_Persistence_Value', $value, $type);
- }
-
- /**
- * Guesses the type for the given value
- *
- * @param mixed $value
- * @return integer
- * @todo Check type guessing/conversion when we go for PHP6
- */
- public static function guessType($value) {
- $type = Tx_Extbase_Persistence_PropertyType::UNDEFINED;
-
- if ($value instanceof DateTime) {
- $type = Tx_Extbase_Persistence_PropertyType::DATE;
- } elseif (is_double($value)) {
- $type = Tx_Extbase_Persistence_PropertyType::DOUBLE;
- } elseif (is_bool($value)) {
- $type = Tx_Extbase_Persistence_PropertyType::BOOLEAN;
- } elseif (is_long($value)) {
- $type = Tx_Extbase_Persistence_PropertyType::LONG;
- } elseif (is_string($value)) {
- $type = Tx_Extbase_Persistence_PropertyType::STRING;
- }
-
- return $type;
- }
-}
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * The ValueFactory object provides methods for the creation Value objects that can
- * then be used to set properties.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_ValueFactoryInterface {
-
- /**
- * Returns a Value object with the specified value. If $type is given,
- * conversion is attempted before creating the Value object.
- *
- * If no type is given, the value is stored as is, i.e. it's type is
- * preserved. Exceptions are:
- * * if the given $value is a Node object, it's Identifier is fetched for the
- * Value object and the type of that object will be REFERENCE
- * * if the given $value is a Node object, it's Identifier is fetched for the
- * Value object and the type of that object will be WEAKREFERENCE if $weak
- * is set to TRUE
- * * if the given $Value is a \DateTime object, the Value type will be DATE.
- *
- * @param mixed $value The value to use when creating the Value object
- * @param integer $type Type request for the Value object
- * @param boolean $weak When a Node is given as $value this can be given as TRUE to create a WEAKREFERENCE
- * @return Tx_Extbase_Persistence_ValueInterface
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException is thrown if the specified value cannot be converted to the specified type.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the specified Node is not referenceable, the current Session is no longer active, or another error occurs.
- * @throws IllegalArgumentException if the specified DateTime value cannot be expressed in the ISO 8601-based format defined in the JCR 2.0 specification and the implementation does not support dates incompatible with that format.
- */
- public function createValue($value, $type = NULL, $weak = FALSE);
-
-}
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A generic holder for the value of a property. A Value object can be used
- * without knowing the actual property type (STRING, DOUBLE, BINARY etc.).
- *
- * Any implementation of this interface must adhere to the following behavior:
- *
- * Two Value instances, v1 and v2, are considered equal if and only if:
- * * v1.getType() == v2.getType(), and,
- * * v1.getString().equals(v2.getString())
- *
- * Actually comparing two Value instances by converting them to string form may not
- * be practical in some cases (for example, if the values are very large binaries).
- * Consequently, the above is intended as a normative definition of Value equality
- * but not as a procedural test of equality. It is assumed that implementations
- * will have efficient means of determining equality that conform with the above
- * definition. An implementation is only required to support equality comparisons on
- * Value instances that were acquired from the same Session and whose contents have
- * not been read. The equality comparison must not change the state of the Value
- * instances even though the getString() method in the above definition implies a
- * state change.
- *
- * The deprecated getStream() method and it's related exceptions and rules have been
- * omitted in this PHP port of the API.
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id$
- */
-interface Tx_Extbase_Persistence_ValueInterface {
-
- /**
- * Returns a string representation of this value.
- *
- * @return string A string representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a String is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getString();
-
- /**
- * Returns a Binary representation of this value. The Binary object in turn provides
- * methods to access the binary data itself. Uses the standard conversion to binary
- * (see JCR specification).
- *
- * @return \F3\PHPCR\BinaryInterface A Binary representation of this value.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getBinary();
-
- /**
- * Returns a long representation of this value.
- *
- * @return string A long representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a long is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getLong();
-
- /**
- * Returns a BigDecimal representation of this value.
- *
- * @return string A double representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getDecimal();
-
- /**
- * Returns a double representation of this value.
- *
- * @return string A double representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a double is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getDouble();
-
- /**
- * Returns a \DateTime representation of this value.
- *
- * The object returned is a copy of the stored value, so changes to it are
- * not reflected in internal storage.
- *
- * @return \DateTime A \DateTime representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a \DateTime is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getDate();
-
- /**
- * Returns a boolean representation of this value.
- *
- * @return string A boolean representation of the value of this property.
- * @throws Tx_Extbase_Persistence_Exception_ValueFormatException if conversion to a boolean is not possible.
- * @throws Tx_Extbase_Persistence_Exception_RepositoryException if another error occurs.
- */
- public function getBoolean();
-
- /**
- * Returns the type of this Value. One of:
- * * PropertyType.STRING
- * * PropertyType.DATE
- * * PropertyType.BINARY
- * * PropertyType.DOUBLE
- * * PropertyType.LONG
- * * PropertyType.BOOLEAN
- * * PropertyType.NAME
- * * PropertyType.PATH
- * * PropertyType.REFERENCE
- * * PropertyType.WEAKREFERENCE
- * * PropertyType.URI
- *
- * The type returned is that which was set at property creation.
- * @return integer The type of the value
- */
- public function getType();
-}
-
-?>
\ No newline at end of file
'tx_extbase_persistence_backendinterface' => $extensionClassesPath . 'Persistence/BackendInterface.php',
'tx_extbase_persistence_exception' => $extensionClassesPath . 'Persistence/Exception.php',
'tx_extbase_persistence_identitymap' => $extensionClassesPath . 'Persistence/IdentityMap.php',
- 'tx_extbase_persistence_iteratorinterface' => $extensionClassesPath . 'Persistence/IteratorInterface.php',
'tx_extbase_persistence_lazyloadingproxy' => $extensionClassesPath . 'Persistence/LazyLoadingProxy.php',
'tx_extbase_persistence_lazyobjectstorage' => $extensionClassesPath . 'Persistence/LazyObjectStorage.php',
'tx_extbase_persistence_loadingstrategyinterface' => $extensionClassesPath . 'Persistence/LoadingStrategyInterface.php',
'tx_extbase_persistence_queryfactory' => $extensionClassesPath . 'Persistence/QueryFactory.php',
'tx_extbase_persistence_queryfactoryinterface' => $extensionClassesPath . 'Persistence/QueryFactoryInterface.php',
'tx_extbase_persistence_queryinterface' => $extensionClassesPath . 'Persistence/QueryInterface.php',
- 'tx_extbase_persistence_queryresult' => $extensionClassesPath . 'Persistence/QueryResult.php',
- 'tx_extbase_persistence_queryresultinterface' => $extensionClassesPath . 'Persistence/QueryResultInterface.php',
'tx_extbase_persistence_querysettingsinterface' => $extensionClassesPath . 'Persistence/QuerySettingsInterface.php',
- 'tx_extbase_persistence_rangeiterator' => $extensionClassesPath . 'Persistence/RangeIterator.php',
- 'tx_extbase_persistence_rangeiteratorinterface' => $extensionClassesPath . 'Persistence/RangeIteratorInterface.php',
'tx_extbase_persistence_repository' => $extensionClassesPath . 'Persistence/Repository.php',
'tx_extbase_persistence_repositoryinterface' => $extensionClassesPath . 'Persistence/RepositoryInterface.php',
- 'tx_extbase_persistence_row' => $extensionClassesPath . 'Persistence/Row.php',
- 'tx_extbase_persistence_rowinterface' => $extensionClassesPath . 'Persistence/RowInterface.php',
- 'tx_extbase_persistence_rowiterator' => $extensionClassesPath . 'Persistence/RowIterator.php',
- 'tx_extbase_persistence_rowiteratorinterface' => $extensionClassesPath . 'Persistence/RowIteratorInterface.php',
'tx_extbase_persistence_session' => $extensionClassesPath . 'Persistence/Session.php',
'tx_extbase_persistence_typo3querysettings' => $extensionClassesPath . 'Persistence/Typo3QuerySettings.php',
'tx_extbase_persistence_typo3querysettingsinterface' => $extensionClassesPath . 'Persistence/Typo3QuerySettingsInterface.php',
- 'tx_extbase_persistence_value' => $extensionClassesPath . 'Persistence/Value.php',
- 'tx_extbase_persistence_valuefactory' => $extensionClassesPath . 'Persistence/ValueFactory.php',
- 'tx_extbase_persistence_valuefactoryinterface' => $extensionClassesPath . 'Persistence/ValueFactoryInterface.php',
- 'tx_extbase_persistence_valueinterface' => $extensionClassesPath . 'Persistence/ValueInterface.php',
'tx_extbase_persistence_exception_cleanstatenotmemorized' => $extensionClassesPath . 'Persistence/Exception/CleanStateNotMemorized.php',
'tx_extbase_persistence_exception_illegalobjecttype' => $extensionClassesPath . 'Persistence/Exception/IllegalObjectType.php',
'tx_extbase_persistence_exception_invalidclass' => $extensionClassesPath . 'Persistence/Exception/InvalidClass.php',