convertCriteria() public méthode

Generic converter of criteria into query fragments.
public convertCriteria ( eZ\Publish\Core\Persistence\Database\SelectQuery $query, eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion, array $languageSettings ) : eZ\Publish\Core\Persistence\Database\Expression
$query eZ\Publish\Core\Persistence\Database\SelectQuery
$criterion eZ\Publish\API\Repository\Values\Content\Query\Criterion
$languageSettings array
Résultat eZ\Publish\Core\Persistence\Database\Expression
Exemple #1
0
 /**
  * Generate query expression for a Criterion this handler accepts.
  *
  * accept() must be called before calling this method.
  *
  * @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  * @param array $languageSettings
  *
  * @return \eZ\Publish\Core\Persistence\Database\Expression
  */
 public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
 {
     $subexpressions = array();
     foreach ($criterion->criteria as $subCriterion) {
         $subexpressions[] = $converter->convertCriteria($query, $subCriterion, $languageSettings);
     }
     return $query->expr->lOr($subexpressions);
 }
 /**
  * Generate query expression for a Criterion this handler accepts.
  *
  * accept() must be called before calling this method.
  *
  * @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  * @param array $fieldFilters
  *
  * @return \eZ\Publish\Core\Persistence\Database\Expression
  */
 public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $fieldFilters)
 {
     $subexpressions = array();
     foreach ($criterion->criteria as $subCriterion) {
         $subexpressions[] = $converter->convertCriteria($query, $subCriterion, $fieldFilters);
     }
     return $query->expr->lAnd($subexpressions);
 }
 /**
  * Get query condition.
  *
  * @param Criterion $filter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param array $languageFilter
  *
  * @return string
  */
 protected function getQueryCondition(Criterion $filter, SelectQuery $query, array $languageFilter)
 {
     $condition = $query->expr->lAnd($this->criteriaConverter->convertCriteria($query, $filter, $languageFilter), $query->expr->eq('ezcontentobject.status', ContentInfo::STATUS_PUBLISHED), $query->expr->eq('ezcontentobject_version.status', VersionInfo::STATUS_PUBLISHED));
     // If not main-languages query
     if (!empty($languageFilter['languages'])) {
         $condition = $query->expr->lAnd($condition, $query->expr->gt($query->expr->bitAnd($this->handler->quoteColumn('language_mask', 'ezcontentobject'), $query->bindValue($this->getLanguageMask($languageFilter), null, PDO::PARAM_INT)), $query->bindValue(0, null, PDO::PARAM_INT)));
     }
     return $condition;
 }
 /**
  * Get query condition
  *
  * @param Criterion $filter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param mixed $translations
  *
  * @return string
  */
 protected function getQueryCondition(Criterion $filter, SelectQuery $query, $translations)
 {
     $condition = $query->expr->lAnd($this->criteriaConverter->convertCriteria($query, $filter), $query->expr->eq('ezcontentobject.status', ContentInfo::STATUS_PUBLISHED), $query->expr->eq('ezcontentobject_version.status', VersionInfo::STATUS_PUBLISHED));
     if ($translations === null) {
         return $condition;
     }
     $translationQuery = $query->subSelect();
     $translationQuery->select($this->handler->quoteColumn('contentobject_id'))->from($this->handler->quoteTable('ezcontentobject_attribute'))->where($translationQuery->expr->in($this->handler->quoteColumn('language_code'), $translations));
     return $query->expr->lAnd($condition, $query->expr->in($this->handler->quoteColumn('id', 'ezcontentobject'), $translationQuery));
 }
 /**
  * Returns total results count for $criterion and $sortClauses.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  *
  * @return array
  */
 protected function getTotalCount(Criterion $criterion)
 {
     $query = $this->handler->createSelectQuery();
     $query->select($query->alias($query->expr->count('*'), 'count'))->from($this->handler->quoteTable('ezcontentobject_tree'))->innerJoin('ezcontentobject', 'ezcontentobject_tree.contentobject_id', 'ezcontentobject.id')->innerJoin('ezcontentobject_version', 'ezcontentobject.id', 'ezcontentobject_version.contentobject_id');
     $query->where($this->criteriaConverter->convertCriteria($query, $criterion), $query->expr->eq('ezcontentobject.status', $query->bindValue(1, null, PDO::PARAM_INT)), $query->expr->eq('ezcontentobject_version.status', $query->bindValue(1, null, PDO::PARAM_INT)), $query->expr->neq($this->handler->quoteColumn('depth', 'ezcontentobject_tree'), $query->bindValue(0, null, PDO::PARAM_INT)));
     $statement = $query->prepare();
     $statement->execute();
     $res = $statement->fetchAll(PDO::FETCH_ASSOC);
     return (int) $res[0]['count'];
 }
 /**
  * Returns total results count for $criterion and $sortClauses.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  * @param array $languageFilter
  *
  * @return array
  */
 protected function getTotalCount(Criterion $criterion, array $languageFilter)
 {
     $query = $this->handler->createSelectQuery();
     $query->select($query->alias($query->expr->count('*'), 'count'))->from($this->handler->quoteTable('ezcontentobject_tree'))->innerJoin('ezcontentobject', 'ezcontentobject_tree.contentobject_id', 'ezcontentobject.id')->innerJoin('ezcontentobject_version', 'ezcontentobject.id', 'ezcontentobject_version.contentobject_id');
     $query->where($this->criteriaConverter->convertCriteria($query, $criterion, $languageFilter), $query->expr->eq('ezcontentobject.status', $query->bindValue(1, null, PDO::PARAM_INT)), $query->expr->eq('ezcontentobject_version.status', $query->bindValue(1, null, PDO::PARAM_INT)), $query->expr->neq($this->handler->quoteColumn('depth', 'ezcontentobject_tree'), $query->bindValue(0, null, PDO::PARAM_INT)));
     // If not main-languages query
     if (!empty($languageFilter['languages'])) {
         $query->where($query->expr->gt($query->expr->bitAnd($this->handler->quoteColumn('language_mask', 'ezcontentobject'), $query->bindValue($this->getLanguageMask($languageFilter), null, PDO::PARAM_INT)), $query->bindValue(0, null, PDO::PARAM_INT)));
     }
     $statement = $query->prepare();
     $statement->execute();
     return (int) $statement->fetchColumn();
 }
 /**
  * Get query condition.
  *
  * @param Criterion $filter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param array $fieldFilters
  *
  * @return string
  */
 protected function getQueryCondition(Criterion $filter, SelectQuery $query, $fieldFilters)
 {
     $condition = $query->expr->lAnd($this->criteriaConverter->convertCriteria($query, $filter, $fieldFilters), $query->expr->eq('ezcontentobject.status', ContentInfo::STATUS_PUBLISHED), $query->expr->eq('ezcontentobject_version.status', VersionInfo::STATUS_PUBLISHED));
     return $condition;
 }
 /**
  * Generate query expression for a Criterion this handler accepts.
  *
  * accept() must be called before calling this method.
  *
  * @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  * @param array $languageSettings
  *
  * @return \eZ\Publish\Core\Persistence\Database\Expression
  */
 public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
 {
     return $query->expr->not($converter->convertCriteria($query, $criterion->criteria[0], $languageSettings));
 }
 /**
  * Generate query expression for a Criterion this handler accepts.
  *
  * accept() must be called before calling this method.
  *
  * @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  * @param array $fieldFilters
  *
  * @return \eZ\Publish\Core\Persistence\Database\Expression
  */
 public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $fieldFilters)
 {
     return $query->expr->not($converter->convertCriteria($query, $criterion->criteria[0], $fieldFilters));
 }
 /**
  * Generate query expression for a Criterion this handler accepts
  *
  * accept() must be called before calling this method.
  *
  * @param \eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter $converter
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  *
  * @return \eZ\Publish\Core\Persistence\Database\Expression
  */
 public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion)
 {
     return $query->expr->not($converter->convertCriteria($query, $criterion->criteria[0]));
 }