コード例 #1
1
ファイル: PropertyAdapter.php プロジェクト: patrova/omeka-s
 /**
  * {@inheritDoc}
  */
 public function sortQuery(QueryBuilder $qb, array $query)
 {
     if (is_string($query['sort_by'])) {
         if ('item_count' == $query['sort_by']) {
             $entityAlias = $this->getEntityClass();
             $valuesAlias = $this->createAlias();
             $resourceAlias = $this->createAlias();
             $countAlias = $this->createAlias();
             $qb->addSelect("COUNT({$valuesAlias}.id) HIDDEN {$countAlias}")->leftJoin("{$entityAlias}.values", $valuesAlias)->leftJoin("{$valuesAlias}.resource", $resourceAlias, 'WITH', "{$resourceAlias} INSTANCE OF Omeka\\Entity\\Item")->addGroupBy("{$entityAlias}.id")->addOrderBy($countAlias, $query['sort_order']);
         } else {
             parent::sortQuery($qb, $query);
         }
     }
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function sortQuery(QueryBuilder $qb, array $query)
 {
     if (is_string($query['sort_by'])) {
         if ('item_count' == $query['sort_by']) {
             $this->sortByCount($qb, $query, 'resources', 'Omeka\\Entity\\Item');
         } else {
             parent::sortQuery($qb, $query);
         }
     }
 }
コード例 #3
0
ファイル: JobAdapter.php プロジェクト: patrova/omeka-s
 /**
  * {@inheritDoc}
  */
 public function sortQuery(QueryBuilder $qb, array $query)
 {
     if (is_string($query['sort_by'])) {
         if ('owner_email' == $query['sort_by']) {
             $entityClass = $this->getEntityClass();
             $ownerAlias = $this->createAlias();
             $qb->leftJoin("{$entityClass}.owner", $ownerAlias)->addOrderBy("{$ownerAlias}.email", $query['sort_order']);
         } else {
             parent::sortQuery($qb, $query);
         }
     }
 }
コード例 #4
0
ファイル: VocabularyAdapter.php プロジェクト: patrova/omeka-s
 /**
  * {@inheritDoc}
  */
 public function sortQuery(QueryBuilder $qb, array $query)
 {
     if (is_string($query['sort_by'])) {
         if ('property_count' == $query['sort_by']) {
             $this->sortByCount($qb, $query, 'properties');
         } elseif ('resource_class_count' == $query['sort_by']) {
             $this->sortByCount($qb, $query, 'resourceClasses');
         } else {
             parent::sortQuery($qb, $query);
         }
     }
 }
コード例 #5
0
 /**
  * {@inheritDoc}
  */
 public function sortQuery(QueryBuilder $qb, array $query)
 {
     if (is_string($query['sort_by'])) {
         if ('resource_class_label' == $query['sort_by']) {
             $resourceClassAlias = $this->createAlias();
             $qb->leftJoin('Omeka\\Entity\\ResourceTemplate.resourceClass', $resourceClassAlias)->addOrderBy("{$resourceClassAlias}.label", $query['sort_order']);
         } elseif ('item_count' == $query['sort_by']) {
             $this->sortByCount($qb, $query, 'resources', 'Omeka\\Entity\\Item');
         } else {
             parent::sortQuery($qb, $query);
         }
     }
 }
コード例 #6
0
 /**
  * {@inheritDoc}
  */
 public function sortQuery(QueryBuilder $qb, array $query)
 {
     if (is_string($query['sort_by'])) {
         $property = $this->getPropertyByTerm($query['sort_by']);
         $entityClass = $this->getEntityClass();
         if ($property) {
             $valuesAlias = $this->createAlias();
             $qb->leftJoin("{$entityClass}.values", $valuesAlias, 'WITH', $qb->expr()->eq("{$valuesAlias}.property", $property->getId()));
             $qb->addOrderBy("{$valuesAlias}.value", $query['sort_order']);
         } elseif ('resource_class_label' == $query['sort_by']) {
             $resourceClassAlias = $this->createAlias();
             $qb->leftJoin("{$entityClass}.resourceClass", $resourceClassAlias)->addOrderBy("{$resourceClassAlias}.label", $query['sort_order']);
         } elseif ('owner_name' == $query['sort_by']) {
             $ownerAlias = $this->createAlias();
             $qb->leftJoin("{$entityClass}.owner", $ownerAlias)->addOrderBy("{$ownerAlias}.name", $query['sort_order']);
         } else {
             parent::sortQuery($qb, $query);
         }
     }
 }
コード例 #7
0
ファイル: ValueHydrator.php プロジェクト: patrova/omeka-s
 /**
  * Hydrate a resource value
  *
  * @param array $valueObject
  * @param Value $value
  */
 protected function hydrateResource(array $valueObject, Value $value)
 {
     $value->setType(Value::TYPE_RESOURCE);
     $value->setValue(null);
     // set default
     $value->setLang(null);
     // set default
     $value->setUriLabel(null);
     // set default
     $valueResource = $this->adapter->getEntityManager()->find('Omeka\\Entity\\Resource', $valueObject['value_resource_id']);
     if (null === $valueResource) {
         throw new Exception\NotFoundException(sprintf($this->adapter->getTranslator()->translate('Resource not found with id %s.'), $valueObject['value_resource_id']));
     }
     if ($valueResource instanceof Media) {
         $translator = $this->adapter->getTranslator();
         $exception = new Exception\ValidationException();
         $exception->getErrorStore()->addError('value', $translator->translate('A value resource cannot be Media.'));
         throw $exception;
     }
     $value->setValueResource($valueResource);
 }