[TASK] Resync TYPO3Flow- and Extbase-Persistence
authorAlexander Schnitzler <alex.schnitzler@typovision.de>
Tue, 30 Oct 2012 10:01:09 +0000 (11:01 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 5 Nov 2012 21:57:23 +0000 (22:57 +0100)
Releases: 6.0
Fixes: #42505
Change-Id: I1d3160013b248afcf0451fbc49bdb68b6bf9c92e
Reviewed-on: http://review.typo3.org/16037
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Persistence/Exception/InvalidQueryException.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Generic/Exception/NotImplementedException.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/Generic/PersistenceManager.php
typo3/sysext/extbase/Classes/Persistence/Generic/Query.php
typo3/sysext/extbase/Classes/Persistence/PersistenceManagerInterface.php
typo3/sysext/extbase/Classes/Persistence/QueryInterface.php
typo3/sysext/extbase/Classes/Persistence/RepositoryInterface.php

diff --git a/typo3/sysext/extbase/Classes/Persistence/Exception/InvalidQueryException.php b/typo3/sysext/extbase/Classes/Persistence/Exception/InvalidQueryException.php
new file mode 100644 (file)
index 0000000..3432584
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+namespace TYPO3\CMS\Extbase\Persistence\Exception;
+
+/*                                                                        *
+ * This script belongs to the Extbase framework.                          *
+ *                                                                        *
+ * This class is a backport of the corresponding class of FLOW3.          *
+ * All credits go to the v5 team.                                         *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License, either version 3   *
+ * of the License, or (at your option) any later version.                 *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * An "Invalid Query" Exception
+ *
+ * @api
+ */
+class InvalidQueryException extends \TYPO3\CMS\Extbase\Exception {
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Exception/NotImplementedException.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Exception/NotImplementedException.php
new file mode 100644 (file)
index 0000000..0c03d25
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace TYPO3\CMS\Extbase\Persistence\Generic\Exception;
+
+/*                                                                        *
+ * This script belongs to the Extbase framework.                          *
+ *                                                                        *
+ * This class is a backport of the corresponding class of FLOW3.          *
+ * All credits go to the v5 team.                                         *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License, either version 3   *
+ * of the License, or (at your option) any later version.                 *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * An "NotImplementedException" exception
+ */
+class NotImplementedException extends \TYPO3\CMS\Extbase\Persistence\Exception {
+
+       /**
+        * @param string $method
+        */
+       public function __construct($method) {
+               parent::__construct(sprintf('Method %s is not supported by generic persistence"', $method), 1350213237);
+       }
+}
+
+?>
\ No newline at end of file
index 7856cfa..eaca145 100644 (file)
@@ -436,7 +436,7 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
                $childClassName = $this->getType(get_class($parentObject), $propertyName);
                $right = $this->qomFactory->selector($childClassName, $columnMap->getChildTableName());
                $joinCondition = $this->qomFactory->equiJoinCondition($columnMap->getRelationTableName(), $columnMap->getChildKeyFieldName(), $columnMap->getChildTableName(), 'uid');
-               $source = $this->qomFactory->join($left, $right, \TYPO3\CMS\Extbase\Persistence\QueryInterface::JCR_JOIN_TYPE_INNER, $joinCondition);
+               $source = $this->qomFactory->join($left, $right, \TYPO3\CMS\Extbase\Persistence\Generic\Query::JCR_JOIN_TYPE_INNER, $joinCondition);
                return $source;
        }
 
index e5e65e6..986a746 100644 (file)
@@ -139,10 +139,11 @@ class PersistenceManager implements \TYPO3\CMS\Extbase\Persistence\PersistenceMa
         *
         * @param mixed $identifier
         * @param string $objectType
+        * @param boolean $useLazyLoading Set to TRUE if you want to use lazy loading for this object
         * @return object The object for the identifier if it is known, or NULL
         * @api
         */
-       public function getObjectByIdentifier($identifier, $objectType) {
+       public function getObjectByIdentifier($identifier, $objectType = NULL, $useLazyLoading = FALSE) {
                return $this->backend->getObjectByIdentifier($identifier, $objectType);
        }
 
@@ -181,6 +182,129 @@ class PersistenceManager implements \TYPO3\CMS\Extbase\Persistence\PersistenceMa
                }
        }
 
+       /**
+        * Adds an object to the persistence.
+        *
+        * @param object $object The object to add
+        * @return void
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @api
+        */
+       public function add($object) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Removes an object to the persistence.
+        *
+        * @param object $object The object to remove
+        * @return void
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @api
+        */
+       public function remove($object) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Update an object in the persistence.
+        *
+        * @param object $object The modified object
+        * @return void
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
+        * @api
+        */
+       public function update($object) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Injects the Extbase settings, called by Extbase.
+        *
+        * @param array $settings
+        * @return void
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @api
+        */
+       public function injectSettings(array $settings) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Initializes the persistence manager, called by Extbase.
+        *
+        * @return void
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @api
+        */
+       public function initialize() {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Clears the in-memory state of the persistence.
+        *
+        * Managed instances become detached, any fetches will
+        * return data directly from the persistence "backend".
+        *
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @return void
+        */
+       public function clearState() {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Checks if the given object has ever been persisted.
+        *
+        * @param object $object The object to check
+        * @return boolean TRUE if the object is new, FALSE if the object exists in the repository
+        * @api
+        */
+       public function isNewObject($object) {
+               return $this->backend->isNewObject($object);
+       }
+
+       /**
+        * Converts the given object into an array containing the identity of the domain object.
+        *
+        * @param object $object The object to be converted
+        * @return array The identity array in the format array('__identity' => '...')
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if the given object is not known to the Persistence Manager
+        * @api
+        */
+       public function convertObjectToIdentityArray($object) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Recursively iterates through the given array and turns objects
+        * into arrays containing the identity of the domain object.
+        *
+        * @param array $array The array to be iterated over
+        * @return array The modified array without objects
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if array contains objects that are not known to the Persistence Manager
+        * @api
+        * @see convertObjectToIdentityArray()
+        */
+       public function convertObjectsToIdentityArrays(array $array) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
+
+       /**
+        * Return a query object for the given type.
+        *
+        * @param string $type
+        * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @api
+        */
+       public function createQueryForType($type) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
 }
 
 
index bc28aa1..9bef16c 100644 (file)
@@ -35,6 +35,26 @@ namespace TYPO3\CMS\Extbase\Persistence\Generic;
 class Query implements \TYPO3\CMS\Extbase\Persistence\QueryInterface {
 
        /**
+        * An inner join.
+        */
+       const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner';
+
+       /**
+        * A left-outer join.
+        */
+       const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
+
+       /**
+        * A right-outer join.
+        */
+       const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
+
+       /**
+        * Charset of strings in QOM
+        */
+       const CHARSET = 'utf-8';
+
+       /**
         * @var string
         */
        protected $type;
@@ -445,7 +465,7 @@ class Query implements \TYPO3\CMS\Extbase\Persistence\QueryInterface {
                if (is_object($operand) || $caseSensitive) {
                        $comparison = $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), \TYPO3\CMS\Extbase\Persistence\QueryInterface::OPERATOR_EQUAL_TO, $operand);
                } else {
-                       $comparison = $this->qomFactory->comparison($this->qomFactory->lowerCase($this->qomFactory->propertyValue($propertyName, $this->getSelectorName())), \TYPO3\CMS\Extbase\Persistence\QueryInterface::OPERATOR_EQUAL_TO, \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter')->conv_case(\TYPO3\CMS\Extbase\Persistence\QueryInterface::CHARSET, $operand, 'toLower'));
+                       $comparison = $this->qomFactory->comparison($this->qomFactory->lowerCase($this->qomFactory->propertyValue($propertyName, $this->getSelectorName())), \TYPO3\CMS\Extbase\Persistence\QueryInterface::OPERATOR_EQUAL_TO, \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter')->conv_case(\TYPO3\CMS\Extbase\Persistence\Generic\Query::CHARSET, $operand, 'toLower'));
                }
                return $comparison;
        }
@@ -455,10 +475,11 @@ class Query implements \TYPO3\CMS\Extbase\Persistence\QueryInterface {
         *
         * @param string $propertyName The name of the property to compare against
         * @param mixed $operand The value to compare with
+        * @param boolean $caseSensitive Whether the matching should be done case-sensitive
         * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
         * @api
         */
-       public function like($propertyName, $operand) {
+       public function like($propertyName, $operand, $caseSensitive = TRUE) {
                return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), \TYPO3\CMS\Extbase\Persistence\QueryInterface::OPERATOR_LIKE, $operand);
        }
 
@@ -557,6 +578,29 @@ class Query implements \TYPO3\CMS\Extbase\Persistence\QueryInterface {
                return array('type', 'source', 'constraint', 'statement', 'orderings', 'limit', 'offset', 'querySettings');
        }
 
+       /**
+        * Returns the query result count.
+        *
+        * @return integer The query result count
+        * @api
+        */
+       public function count() {
+               return $this->execute()->count();
+       }
+
+       /**
+        * Returns an "isEmpty" criterion used for matching objects against a query.
+        * It matches if the multivalued property contains no values or is NULL.
+        *
+        * @param string $propertyName The name of the multivalued property to compare against
+        * @return boolean
+        * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a single-valued property
+        * @api
+        */
+       public function isEmpty($propertyName) {
+               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException(__METHOD__);
+       }
 }
 
 
index 7540864..382250f 100644 (file)
@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Extbase\Persistence;
 /**
  * The Extbase Persistence Manager interface
  */
-interface PersistenceManagerInterface
-{
+interface PersistenceManagerInterface {
+
        /**
         * Commits new objects and changes to objects in the current persistence
         * session into the backend
@@ -47,16 +47,18 @@ interface PersistenceManagerInterface
         *
         * @param mixed $identifier
         * @param string $objectType
+        * @param boolean $useLazyLoading Set to TRUE if you want to use lazy loading for this object
         * @return object The object for the identifier if it is known, or NULL
         * @api
         */
-       public function getObjectByIdentifier($identifier, $objectType);
+       public function getObjectByIdentifier($identifier, $objectType = NULL, $useLazyLoading = FALSE);
 
        /**
         * Returns the number of records matching the query.
         *
         * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
         * @return integer
+        * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
         * @api
         */
        public function getObjectCountByQuery(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query);
@@ -66,6 +68,7 @@ interface PersistenceManagerInterface
         *
         * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
         * @return array
+        * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
         * @api
         */
        public function getObjectDataByQuery(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query);
@@ -74,10 +77,105 @@ interface PersistenceManagerInterface
         * Registers a repository
         *
         * @param string $className The class name of the repository to be reigistered
+        * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
         * @return void
         */
        public function registerRepositoryClassName($className);
 
+       /**
+        * Adds an object to the persistence.
+        *
+        * @param object $object The object to add
+        * @return void
+        * @api
+        */
+       public function add($object);
+
+       /**
+        * Removes an object to the persistence.
+        *
+        * @param object $object The object to remove
+        * @return void
+        * @api
+        */
+       public function remove($object);
+
+       /**
+        * Update an object in the persistence.
+        *
+        * @param object $object The modified object
+        * @return void
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
+        * @api
+        */
+       public function update($object);
+
+       /**
+        * Injects the Extbase settings, called by Extbase.
+        *
+        * @param array $settings
+        * @return void
+        * @api
+        */
+       public function injectSettings(array $settings);
+
+       /**
+        * Initializes the persistence manager, called by Extbase.
+        *
+        * @return void
+        * @api
+        */
+       public function initialize();
+
+       /**
+        * Clears the in-memory state of the persistence.
+        *
+        * Managed instances become detached, any fetches will
+        * return data directly from the persistence "backend".
+        *
+        * @return void
+        */
+       public function clearState();
+
+       /**
+        * Checks if the given object has ever been persisted.
+        *
+        * @param object $object The object to check
+        * @return boolean TRUE if the object is new, FALSE if the object exists in the repository
+        * @api
+        */
+       public function isNewObject($object);
+
+       /**
+        * Converts the given object into an array containing the identity of the domain object.
+        *
+        * @param object $object The object to be converted
+        * @return array The identity array in the format array('__identity' => '...')
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if the given object is not known to the Persistence Manager
+        * @api
+        */
+       public function convertObjectToIdentityArray($object);
+
+       /**
+        * Recursively iterates through the given array and turns objects
+        * into arrays containing the identity of the domain object.
+        *
+        * @param array $array The array to be iterated over
+        * @return array The modified array without objects
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException if array contains objects that are not known to the Persistence Manager
+        * @api
+        * @see convertObjectToIdentityArray()
+        */
+       public function convertObjectsToIdentityArrays(array $array);
+
+       /**
+        * Return a query object for the given type.
+        *
+        * @param string $type
+        * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
+        * @api
+        */
+       public function createQueryForType($type);
 }
 
 ?>
\ No newline at end of file
index 3936125..34a032b 100644 (file)
@@ -19,90 +19,89 @@ namespace TYPO3\CMS\Extbase\Persistence;
  * @api
  */
 interface QueryInterface {
+
        /**
         * The '=' comparison operator.
-        *
         * @api
         */
        const OPERATOR_EQUAL_TO = 1;
+
        /**
         * The '!=' comparison operator.
-        *
         * @api
         */
        const OPERATOR_NOT_EQUAL_TO = 2;
+
        /**
         * The '<' comparison operator.
-        *
         * @api
         */
        const OPERATOR_LESS_THAN = 3;
+
        /**
         * The '<=' comparison operator.
-        *
         * @api
         */
        const OPERATOR_LESS_THAN_OR_EQUAL_TO = 4;
+
        /**
         * The '>' comparison operator.
-        *
         * @api
         */
        const OPERATOR_GREATER_THAN = 5;
+
        /**
         * The '>=' comparison operator.
-        *
         * @api
         */
        const OPERATOR_GREATER_THAN_OR_EQUAL_TO = 6;
+
        /**
         * The 'like' comparison operator.
-        *
         * @api
         */
        const OPERATOR_LIKE = 7;
+
        /**
-        * The 'contains' comparison operator.
-        *
+        * The 'contains' comparison operator for collections.
         * @api
         */
        const OPERATOR_CONTAINS = 8;
+
        /**
         * The 'in' comparison operator.
-        *
         * @api
         */
        const OPERATOR_IN = 9;
+
        /**
-        * Constants representing the direction when ordering result sets.
-        */
-       const ORDER_ASCENDING = 'ASC';
-       const ORDER_DESCENDING = 'DESC';
-       /**
-        * An inner join.
-        */
-       const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner';
-       /**
-        * A left-outer join.
+        * The 'is NULL' comparison operator.
+        * @api
         */
-       const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
+       const OPERATOR_IS_NULL = 10;
+
        /**
-        * A right-outer join.
+        * The 'is empty' comparison operator for collections.
+        * @api
         */
-       const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
+       const OPERATOR_IS_EMPTY = 11;
+
        /**
-        * Charset of strings in QOM
+        * Constants representing the direction when ordering result sets.
         */
-       const CHARSET = 'utf-8';
+       const ORDER_ASCENDING = 'ASC';
+       const ORDER_DESCENDING = 'DESC';
+
        /**
         * Gets the node-tuple source for this query.
         *
         * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface the node-tuple source; non-NULL
+        * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
         */
        public function getSource();
 
        /**
-        * Executes the query against the backend and returns the result
+        * Executes the query and returns the result.
         *
         * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array The query result object or an array if $this->getQuerySettings()->getReturnRawQueryResult() is TRUE
         * @api
@@ -112,8 +111,8 @@ interface QueryInterface {
        /**
         * Sets the property names to order the result by. Expected like this:
         * array(
-        * 'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
-        * 'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
+        *  'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
+        *  'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
         * )
         *
         * @param array $orderings The property names to order by
@@ -124,7 +123,7 @@ interface QueryInterface {
 
        /**
         * Sets the maximum size of the result set to limit. Returns $this to allow
-        * for chaining (fluid interface)
+        * for chaining (fluid interface).
         *
         * @param integer $limit
         * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
@@ -134,7 +133,7 @@ interface QueryInterface {
 
        /**
         * Sets the start offset of the result set to offset. Returns $this to
-        * allow for chaining (fluid interface)
+        * allow for chaining (fluid interface).
         *
         * @param integer $offset
         * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
@@ -144,7 +143,7 @@ interface QueryInterface {
 
        /**
         * The constraint used to limit the result set. Returns $this to allow
-        * for chaining (fluid interface)
+        * for chaining (fluid interface).
         *
         * @param object $constraint Some constraint, depending on the backend
         * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
@@ -153,7 +152,9 @@ interface QueryInterface {
        public function matching($constraint);
 
        /**
-        * Performs a logical conjunction of the two given constraints.
+        * Performs a logical conjunction of the two given constraints. The method
+        * takes one or more constraints and concatenates them with a boolean AND.
+        * It also accepts a single array of constraints to be concatenated.
         *
         * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
         * @return object
@@ -162,7 +163,9 @@ interface QueryInterface {
        public function logicalAnd($constraint1);
 
        /**
-        * Performs a logical disjunction of the two given constraints
+        * Performs a logical disjunction of the two given constraints. The method
+        * takes one or more constraints and concatenates them with a boolean OR.
+        * It also accepts a single array of constraints to be concatenated.
         *
         * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
         * @return object
@@ -180,33 +183,44 @@ interface QueryInterface {
        public function logicalNot($constraint);
 
        /**
-        * Returns an equals criterion used for matching objects against a query
+        * Returns an equals criterion used for matching objects against a query.
+        *
+        * It matches if the $operand equals the value of the property named
+        * $propertyName. If $operand is NULL a strict check for NULL is done. For
+        * strings the comparison can be done with or without case-sensitivity.
         *
         * @param string $propertyName The name of the property to compare against
         * @param mixed $operand The value to compare with
-        * @param boolean $caseSensitive Whether the equality test should be done case-sensitive
+        * @param boolean $caseSensitive Whether the equality test should be done case-sensitive for strings
         * @return object
         * @api
         */
        public function equals($propertyName, $operand, $caseSensitive = TRUE);
 
        /**
-        * Returns a like criterion used for matching objects against a query
+        * Returns a like criterion used for matching objects against a query.
+        * Matches if the property named $propertyName is like the $operand, using
+        * standard SQL wildcards.
         *
         * @param string $propertyName The name of the property to compare against
-        * @param mixed $operand The value to compare with
+        * @param string $operand The value to compare with
+        * @param boolean $caseSensitive Whether the matching should be done case-sensitive
         * @return object
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a non-string property
         * @api
         */
-       public function like($propertyName, $operand);
+       public function like($propertyName, $operand, $caseSensitive = TRUE);
 
        /**
         * Returns a "contains" criterion used for matching objects against a query.
         * It matches if the multivalued property contains the given operand.
         *
-        * @param string $propertyName The name of the (multivalued) property to compare against
+        * If NULL is given as $operand, there will never be a match!
+        *
+        * @param string $propertyName The name of the multivalued property to compare against
         * @param mixed $operand The value to compare with
         * @return object
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a single-valued property
         * @api
         */
        public function contains($propertyName, $operand);
@@ -218,6 +232,7 @@ interface QueryInterface {
         * @param string $propertyName The name of the property to compare against
         * @param mixed $operand The value to compare with, multivalued
         * @return object
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a multi-valued property
         * @api
         */
        public function in($propertyName, $operand);
@@ -228,6 +243,7 @@ interface QueryInterface {
         * @param string $propertyName The name of the property to compare against
         * @param mixed $operand The value to compare with
         * @return object
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a multi-valued property or with a non-literal/non-DateTime operand
         * @api
         */
        public function lessThan($propertyName, $operand);
@@ -238,6 +254,7 @@ interface QueryInterface {
         * @param string $propertyName The name of the property to compare against
         * @param mixed $operand The value to compare with
         * @return object
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a multi-valued property or with a non-literal/non-DateTime operand
         * @api
         */
        public function lessThanOrEqual($propertyName, $operand);
@@ -248,6 +265,7 @@ interface QueryInterface {
         * @param string $propertyName The name of the property to compare against
         * @param mixed $operand The value to compare with
         * @return object
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a multi-valued property or with a non-literal/non-DateTime operand
         * @api
         */
        public function greaterThan($propertyName, $operand);
@@ -258,6 +276,7 @@ interface QueryInterface {
         * @param string $propertyName The name of the property to compare against
         * @param mixed $operand The value to compare with
         * @return object
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a multi-valued property or with a non-literal/non-DateTime operand
         * @api
         */
        public function greaterThanOrEqual($propertyName, $operand);
@@ -266,6 +285,7 @@ interface QueryInterface {
         * Returns the type this query cares for.
         *
         * @return string
+        * @deprecated since Extbase 6.0, will be removed in Extbase 7.0
         * @api
         */
        public function getType();
@@ -276,7 +296,8 @@ interface QueryInterface {
         *
         * @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
         * @return void
-        * @api This method is not part of FLOW3 API
+        * @todo decide whether this can be deprecated somewhen
+        * @api This method is not part of TYPO3Flow API
         */
        public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings);
 
@@ -284,10 +305,65 @@ interface QueryInterface {
         * Returns the Query Settings.
         *
         * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
-        * @api This method is not part of FLOW3 API
+        * @todo decide whether this can be deprecated somewhen
+        * @api This method is not part of  TYPO3Flow API
         */
        public function getQuerySettings();
 
+       /**
+        * Returns the query result count.
+        *
+        * @return integer The query result count
+        * @api
+        */
+       public function count();
+
+       /**
+        * Gets the property names to order the result by, like this:
+        * array(
+        *  'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
+        *  'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
+        * )
+        *
+        * @return array
+        * @api
+        */
+       public function getOrderings();
+
+       /**
+        * Returns the maximum size of the result set to limit.
+        *
+        * @param integer
+        * @api
+        */
+       public function getLimit();
+
+       /**
+        * Returns the start offset of the result set.
+        *
+        * @return integer
+        * @api
+        */
+       public function getOffset();
+
+       /**
+        * Gets the constraint for this query.
+        *
+        * @return mixed the constraint, or null if none
+        * @api
+        */
+       public function getConstraint();
+
+       /**
+        * Returns an "isEmpty" criterion used for matching objects against a query.
+        * It matches if the multivalued property contains no values or is NULL.
+        *
+        * @param string $propertyName The name of the multivalued property to compare against
+        * @return boolean
+        * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException if used on a single-valued property
+        * @api
+        */
+       public function isEmpty($propertyName);
 }
 
 ?>
\ No newline at end of file
index f09700c..2d1cd7d 100644 (file)
@@ -75,7 +75,7 @@ interface RepositoryInterface
        /**
         * Returns all objects of this repository.
         *
-        * @return array An array of objects, empty if no objects found
+        * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array The query result
         * @api
         */
        public function findAll();
@@ -110,8 +110,8 @@ interface RepositoryInterface
         * Sets the property names to order the result by per default.
         * Expected like this:
         * array(
-        * 'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
-        * 'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
+        * 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
+        * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
         * )
         *
         * @param array $defaultOrderings The property names to order by