Beispiel #1
0
 /**
  * Returns the base query for retrieving related objects.
  *
  * See {@link getRelatedObject()} and {@link getRelatedObjects()}. Can be
  * modified by additional where conditions and simply be used with
  * {@link find()} and the related class name, to retrieve a sub-set of
  * related objects.
  *
  * If multiple relations are defined for the $relatedClass (using {@link
  * ezcPersistentRelationCollection}), the parameter $relationName becomes
  * mandatory to determine which relation definition to use. For normal
  * relations, this parameter is silently ignored.
  *
  * If you provide a $setName, the resulting set of related objects fetched
  * by {@link find()} is cached under the given name for $object. You can
  * retrieve this set either through {@link getRelatedObjectSubset()} or by
  * issueing the same query (or a query with the same $object and $setName)
  * again. Overwriting a once created named set can be enfored using the
  * 'refetch' option in {@link ezcPersistentSessionIdentityDecoratorOptions}.
  *
  * @param ezcPersistentObject $object
  * @param string $relatedClass
  * @param string $relationName
  * @param string $setName
  *
  * @return ezcPersistentRelationFindQuery
  *
  * @throws ezcPersistentRelationNotFoundException
  *         if the given $object does not have a relation to $relatedClass.
  */
 public function createRelationFindQuery($object, $relatedClass, $relationName = null, $setName = null)
 {
     $originalQuery = $this->session->createRelationFindQuery($object, $relatedClass, $relationName);
     $q = new ezcPersistentRelationFindQuery($originalQuery->query, $originalQuery->className);
     if ($setName !== null) {
         $q->relationSetName = $setName;
         $q->relationSource = $object;
     }
     return $q;
 }