コード例 #1
0
 /**
  * Load name data for set of content id's and corresponding version number.
  *
  * @param array[] $rows array of hashes with 'id' and 'version' to load names for
  *
  * @return array
  */
 public function loadVersionedNameData($rows)
 {
     $query = $this->queryBuilder->createNamesQuery();
     $conditions = array();
     foreach ($rows as $row) {
         $conditions[] = $query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('contentobject_id'), $query->bindValue($row['id'], null, \PDO::PARAM_INT)), $query->expr->eq($this->dbHandler->quoteColumn('content_version'), $query->bindValue($row['version'], null, \PDO::PARAM_INT)));
     }
     $query->where($query->expr->lOr($conditions));
     $stmt = $query->prepare();
     $stmt->execute();
     return $stmt->fetchAll(\PDO::FETCH_ASSOC);
 }
コード例 #2
0
 /**
  * Loads data that related to $toContentId
  *
  * @param int $toContentId
  * @param int $relationType
  *
  * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
  */
 public function loadReverseRelations($toContentId, $relationType = null)
 {
     $query = $this->queryBuilder->createRelationFindQuery();
     $query->where($query->expr->eq($this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link'), $query->bindValue($toContentId, null, \PDO::PARAM_INT)));
     // ezcontentobject join
     $query->from($this->dbHandler->quoteTable('ezcontentobject'))->where($query->expr->lAnd($query->expr->eq($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $this->dbHandler->quoteColumn('from_contentobject_id', 'ezcontentobject_link')), $query->expr->eq($this->dbHandler->quoteColumn('current_version', 'ezcontentobject'), $this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link')), $query->expr->eq($this->dbHandler->quoteColumn('status', 'ezcontentobject'), $query->bindValue(1, null, \PDO::PARAM_INT))));
     // relation type
     if (isset($relationType)) {
         $query->where($query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn('relation_type', 'ezcontentobject_link'), $query->bindValue($relationType, null, \PDO::PARAM_INT)), 0));
     }
     $statement = $query->prepare();
     $statement->execute();
     return $statement->fetchAll(\PDO::FETCH_ASSOC);
 }
コード例 #3
0
 /**
  * Loads the actual content based on the provided IDs
  *
  * @param array $contentIds
  * @param mixed $translations
  *
  * @return mixed[]
  */
 protected function loadContent(array $contentIds, $translations)
 {
     $loadQuery = $this->queryBuilder->createFindQuery($translations);
     $loadQuery->where($loadQuery->expr->eq('ezcontentobject_version.status', VersionInfo::STATUS_PUBLISHED), $loadQuery->expr->in($this->handler->quoteColumn('id', 'ezcontentobject'), $contentIds));
     $statement = $loadQuery->prepare();
     $statement->execute();
     $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
     // Sort array, as defined in the $contentIds array
     $contentIdOrder = array_flip($contentIds);
     usort($rows, function ($current, $next) use($contentIdOrder) {
         return $contentIdOrder[$current['ezcontentobject_id']] - $contentIdOrder[$next['ezcontentobject_id']];
     });
     foreach ($rows as &$row) {
         $row['ezcontentobject_always_available'] = $this->languageMaskGenerator->isAlwaysAvailable($row['ezcontentobject_language_mask']);
         $row['ezcontentobject_main_language_code'] = $this->languageHandler->load($row['ezcontentobject_initial_language_id'])->languageCode;
         $row['ezcontentobject_version_languages'] = $this->languageMaskGenerator->extractLanguageIdsFromMask($row['ezcontentobject_version_language_mask']);
         $row['ezcontentobject_version_initial_language_code'] = $this->languageHandler->load($row['ezcontentobject_version_initial_language_id'])->languageCode;
     }
     return $rows;
 }