Example #1
0
 /**
  * Finds an object from the repository by searching for its technical UID.
  * TODO This is duplicated code; see Argument class
  *
  * @param string $dataType the data type to fetch
  * @param integer $uid The object's uid
  * @return object Either the object matching the uid or, if none or more than one object was found, NULL
  */
 protected function findObjectByUid($dataType, $uid)
 {
     $query = $this->queryFactory->create($dataType);
     $query->getQuerySettings()->setRespectSysLanguage(FALSE);
     $query->getQuerySettings()->setRespectStoragePage(FALSE);
     return $query->matching($query->equals('uid', (int) $uid))->execute()->getFirst();
 }
Example #2
0
 /**
  * Builds and returns the prepared query, ready to be executed.
  *
  * @param DomainObjectInterface $parentObject
  * @param string $propertyName
  * @param string $fieldValue
  * @return Persistence\QueryInterface
  */
 protected function getPreparedQuery(DomainObjectInterface $parentObject, $propertyName, $fieldValue = '')
 {
     $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
     $type = $this->getType(get_class($parentObject), $propertyName);
     $query = $this->queryFactory->create($type);
     $query->getQuerySettings()->setRespectStoragePage(false);
     $query->getQuerySettings()->setRespectSysLanguage(false);
     if ($columnMap->getTypeOfRelation() === ColumnMap::RELATION_HAS_MANY) {
         if ($columnMap->getChildSortByFieldName() !== null) {
             $query->setOrderings([$columnMap->getChildSortByFieldName() => Persistence\QueryInterface::ORDER_ASCENDING]);
         }
     } elseif ($columnMap->getTypeOfRelation() === ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
         $query->setSource($this->getSource($parentObject, $propertyName));
         if ($columnMap->getChildSortByFieldName() !== null) {
             $query->setOrderings([$columnMap->getChildSortByFieldName() => Persistence\QueryInterface::ORDER_ASCENDING]);
         }
     }
     $query->matching($this->getConstraint($query, $parentObject, $propertyName, $fieldValue, $columnMap->getRelationTableMatchFields()));
     return $query;
 }
 /**
  * Return a query object for the given type.
  *
  * @param string $type
  * @return QueryInterface
  */
 public function createQueryForType($type)
 {
     return $this->queryFactory->create($type);
 }