eZ\Publish\Core\Persistence\Legacy\Content\Mapper::extractVersionInfoListFromRows PHP Method

extractVersionInfoListFromRows() public method

Extracts a VersionInfo object from $row.
public extractVersionInfoListFromRows ( array $rows, array $nameRows ) : eZ\Publish\SPI\Persistence\Content\VersionInfo[]
$rows array
$nameRows array
return eZ\Publish\SPI\Persistence\Content\VersionInfo[]
    public function extractVersionInfoListFromRows(array $rows, array $nameRows)
    {
        $nameData = array();
        foreach ($nameRows as $row) {
            $versionId = $row['ezcontentobject_name_contentobject_id'] . '_' . $row['ezcontentobject_name_content_version'];
            $nameData[$versionId][$row['ezcontentobject_name_content_translation']] = $row['ezcontentobject_name_name'];
        }
        $versionInfoList = array();
        foreach ($rows as $row) {
            $versionId = $row['ezcontentobject_id'] . '_' . $row['ezcontentobject_version_version'];
            if (!isset($versionInfoList[$versionId])) {
                $versionInfo = new VersionInfo();
                $versionInfo->id = (int) $row['ezcontentobject_version_id'];
                $versionInfo->contentInfo = $this->extractContentInfoFromRow($row, 'ezcontentobject_');
                $versionInfo->versionNo = (int) $row['ezcontentobject_version_version'];
                $versionInfo->creatorId = (int) $row['ezcontentobject_version_creator_id'];
                $versionInfo->creationDate = (int) $row['ezcontentobject_version_created'];
                $versionInfo->modificationDate = (int) $row['ezcontentobject_version_modified'];
                $versionInfo->initialLanguageCode = $this->languageHandler->load($row['ezcontentobject_version_initial_language_id'])->languageCode;
                $versionInfo->languageIds = $this->extractLanguageIdsFromMask((int) $row['ezcontentobject_version_language_mask']);
                $versionInfo->status = (int) $row['ezcontentobject_version_status'];
                $versionInfo->names = $nameData[$versionId];
                $versionInfoList[$versionId] = $versionInfo;
            }
        }
        return array_values($versionInfoList);
    }

Usage Example

コード例 #1
0
ファイル: TreeHandler.php プロジェクト: Pixy/ezpublish-kernel
 /**
  * Returns the versions for $contentId.
  *
  * @param int $contentId
  *
  * @return \eZ\Publish\SPI\Persistence\Content\VersionInfo[]
  */
 public function listVersions($contentId)
 {
     $rows = $this->contentGateway->listVersions($contentId);
     if (empty($rows)) {
         return array();
     }
     $idVersionPairs = array_map(function ($row) use($contentId) {
         return array('id' => $contentId, 'version' => $row['ezcontentobject_version_version']);
     }, $rows);
     $nameRows = $this->contentGateway->loadVersionedNameData($idVersionPairs);
     return $this->contentMapper->extractVersionInfoListFromRows($rows, $nameRows);
 }
All Usage Examples Of eZ\Publish\Core\Persistence\Legacy\Content\Mapper::extractVersionInfoListFromRows