Builds a VersionInfo domain object from value object returned from persistence.

@param \eZ\Publish\SPI\Persistence\Content\VersionInfo $spiVersionInfo
@param array $prioritizedLanguages

@return \eZ\Publish\Core\Repository\Values\Content\VersionInfo
436955
public function buildVersionInfoDomainObject(SPIVersionInfo $spiVersionInfo, array $prioritizedLanguages = [])
    {
        // Map SPI statuses to API
        switch ($spiVersionInfo->status) {
            case SPIVersionInfo::STATUS_ARCHIVED:
                $status = APIVersionInfo::STATUS_ARCHIVED;
                break;

            case SPIVersionInfo::STATUS_PUBLISHED:
                $status = APIVersionInfo::STATUS_PUBLISHED;
                break;

            case SPIVersionInfo::STATUS_DRAFT:
            default:
                $status = APIVersionInfo::STATUS_DRAFT;
        }

        // Find prioritised language among names
        $prioritizedNameLanguageCode = null;
        foreach ($prioritizedLanguages as $prioritizedLanguage) {
            if (isset($spiVersionInfo->names[$prioritizedLanguage])) {
                $prioritizedNameLanguageCode = $prioritizedLanguage;
                break;
            }
        }

        return new VersionInfo(
            array(
                'id' => $spiVersionInfo->id,
                'versionNo' => $spiVersionInfo->versionNo,
                'modificationDate' => $this->getDateTime($spiVersionInfo->modificationDate),
                'creatorId' => $spiVersionInfo->creatorId,
                'creationDate' => $this->getDateTime($spiVersionInfo->creationDate),
                'status' => $status,
                'initialLanguageCode' => $spiVersionInfo->initialLanguageCode,
                'languageCodes' => $spiVersionInfo->languageCodes,
                'names' => $spiVersionInfo->names,
                'contentInfo' => $this->buildContentInfoDomainObject($spiVersionInfo->contentInfo),
                'prioritizedNameLanguageCode' => $prioritizedNameLanguageCode,
            )
        );
    }
1180079
public function mapOsVersion(?string $osVersion, ?string $osName = null): VersionInterface
    {
        return (new PlatformVersionMapper())->mapOsVersion($osVersion, $osName);
    }
694002
public function addPublishLanguage(\Sulu\Bundle\MediaBundle\Entity\FileVersionPublishLanguage $publishLanguages)
    {
        $this->publishLanguages[] = $publishLanguages;

        return $this;
    }
877792
public function createVersionInfoForContent(Content $content, $versionNo, $userId)
    {
        $versionInfo = new VersionInfo();

        $versionInfo->contentInfo = $content->versionInfo->contentInfo;
        $versionInfo->versionNo = $versionNo;
        $versionInfo->creatorId = $userId;
        $versionInfo->status = VersionInfo::STATUS_DRAFT;
        $versionInfo->initialLanguageCode = $content->versionInfo->initialLanguageCode;
        $versionInfo->creationDate = time();
        $versionInfo->modificationDate = $versionInfo->creationDate;
        $versionInfo->names = is_object($content->versionInfo) ? $content->versionInfo->names : array();
        $versionInfo->languageCodes = $content->versionInfo->languageCodes;

        return $versionInfo;
    }
693123
public function insertVersion(VersionInfo $versionInfo, array $fields)
    {
        /** @var $q \eZ\Publish\Core\Persistence\Database\InsertQuery */
        $q = $this->dbHandler->createInsertQuery();
        $q->insertInto(
            $this->dbHandler->quoteTable('ezcontentobject_version')
        )->set(
            $this->dbHandler->quoteColumn('id'),
            $this->dbHandler->getAutoIncrementValue('ezcontentobject_version', 'id')
        )->set(
            $this->dbHandler->quoteColumn('version'),
            $q->bindValue($versionInfo->versionNo, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('modified'),
            $q->bindValue($versionInfo->modificationDate, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('creator_id'),
            $q->bindValue($versionInfo->creatorId, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('created'),
            $q->bindValue($versionInfo->creationDate, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('status'),
            $q->bindValue($versionInfo->status, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('initial_language_id'),
            $q->bindValue(
                $this->languageHandler->loadByLanguageCode($versionInfo->initialLanguageCode)->id,
                null,
                \PDO::PARAM_INT
            )
        )->set(
            $this->dbHandler->quoteColumn('contentobject_id'),
            $q->bindValue($versionInfo->contentInfo->id, null, \PDO::PARAM_INT)
        )->set(
            // As described in field mapping document
            $this->dbHandler->quoteColumn('workflow_event_pos'),
            $q->bindValue(0, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('language_mask'),
            $q->bindValue(
                $this->generateLanguageMask(
                    $fields,
                    $versionInfo->initialLanguageCode,
                    $versionInfo->contentInfo->alwaysAvailable
                ),
                null,
                \PDO::PARAM_INT
            )
        );

        $q->prepare()->execute();

        return $this->dbHandler->lastInsertId(
            $this->dbHandler->getSequenceName('ezcontentobject_version', 'id')
        );
    }
1029570
private function getNamesForAllLanguages(array $contentInfo)
    {
        $nameDataArray = $this->contentGateway->loadVersionedNameData([
            [
                'id' => $contentInfo['id'],
                'version' => $contentInfo['current_version'],
            ],
        ]);

        $namesForAllLanguages = [];
        foreach ($nameDataArray as $nameData) {
            $namesForAllLanguages[$nameData['ezcontentobject_name_content_translation']]
                = $nameData['ezcontentobject_name_name'];
        }

        return $namesForAllLanguages;
    }
165327
public function publishVersion($contentId, $versionNumber)
    {
        if (!$this->isUserContent($contentId)) {
            parent::publishVersion($contentId, $versionNumber);
        }

        return new NoContent();
    }
704547
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerShedulesVersionQuery::create()
            ->filterByDealerShedules($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
1244748
protected function isUrlAliasLoadable(
        SPIURLAlias $spiUrlAlias,
        ?string $languageCode,
        bool $showAllTranslations,
        array $prioritizedLanguageList
    ) {
        if (isset($languageCode) && !in_array($languageCode, $spiUrlAlias->languageCodes)) {
            return false;
        }

        if ($showAllTranslations) {
            return true;
        }

        foreach ($spiUrlAlias->pathData as $levelPathData) {
            if ($levelPathData['always-available']) {
                continue;
            }

            foreach ($levelPathData['translations'] as $translationLanguageCode => $translation) {
                if (in_array($translationLanguageCode, $prioritizedLanguageList)) {
                    continue 2;
                }
            }

            return false;
        }

        return true;
    }
622232
public function addVersionInformation(SystemInformationToolbarItem $systemInformation)
    {
        $value = null;
        $extensionDirectory = ExtensionManagementUtility::extPath('bootstrap_package');

        // Try to get current version from git
        if (file_exists($extensionDirectory . '.git')) {
            CommandUtility::exec('git --version', $_, $returnCode);
            if ((int)$returnCode === 0) {
                $currentDir = getcwd();
                chdir($extensionDirectory);
                $tag = trim(CommandUtility::exec('git tag -l --points-at HEAD'));
                if ($tag) {
                    $value = $tag;
                } else {
                    $branch = trim(CommandUtility::exec('git rev-parse --abbrev-ref HEAD'));
                    $revision = trim(CommandUtility::exec('git rev-parse --short HEAD'));
                    $value = $branch . ', ' . $revision;
                }
                chdir($currentDir);
            }
        }

        // Fallback to version from extension manager
        if ($value === null) {
            $value = ExtensionManagementUtility::getExtensionVersion('bootstrap_package');
        }

        // Set system information entry
        $systemInformation->addSystemInformation(
            'Bootstrap Package',
            htmlspecialchars($value, ENT_QUOTES | ENT_HTML5),
            'systeminformation-bootstrappackage'
        );
    }
1129646
public function buildContentInfoDomainObject(SPIContentInfo $spiContentInfo)
    {
        // Map SPI statuses to API
        switch ($spiContentInfo->status) {
            case SPIContentInfo::STATUS_TRASHED:
                $status = ContentInfo::STATUS_TRASHED;
                break;

            case SPIContentInfo::STATUS_PUBLISHED:
                $status = ContentInfo::STATUS_PUBLISHED;
                break;

            case SPIContentInfo::STATUS_DRAFT:
            default:
                $status = ContentInfo::STATUS_DRAFT;
        }

        return new ContentInfo(
            array(
                'id' => $spiContentInfo->id,
                'contentTypeId' => $spiContentInfo->contentTypeId,
                'name' => $spiContentInfo->name,
                'sectionId' => $spiContentInfo->sectionId,
                'currentVersionNo' => $spiContentInfo->currentVersionNo,
                'published' => $spiContentInfo->isPublished,
                'ownerId' => $spiContentInfo->ownerId,
                'modificationDate' => $spiContentInfo->modificationDate == 0 ?
                    null :
                    $this->getDateTime($spiContentInfo->modificationDate),
                'publishedDate' => $spiContentInfo->publicationDate == 0 ?
                    null :
                    $this->getDateTime($spiContentInfo->publicationDate),
                'alwaysAvailable' => $spiContentInfo->alwaysAvailable,
                'remoteId' => $spiContentInfo->remoteId,
                'mainLanguageCode' => $spiContentInfo->mainLanguageCode,
                'mainLocationId' => $spiContentInfo->mainLocationId,
                'status' => $status,
                'isHidden' => $spiContentInfo->isHidden,
            )
        );
    }
1374891
protected function incrementVersion($version, $patch_limit = 20, $minor_limit = 50)
    {
        if (!$this->isVersionNumeric($version)) {
            throw new DeploymentRuntimeException(
                'Unable to increment semantic version.'
            );
        }
        list($major, $minor, $patch) = explode('.', $version);

        if ($patch < $patch_limit) {
            ++$patch;
        } else if ($minor < $minor_limit) {
            ++$minor;
            $patch = 0;
        } else {
            ++$major;
            $patch = 0;
            $minor = 0;
        }

        return "{$major}.{$minor}.{$patch}";
    }
571375
public function setContentLanguages($contentLanguages)
    {
        $fileVersion = $this->getFileVersion();

        foreach ($contentLanguages as $locale) {
            $contentLanguage = new FileVersionContentLanguage();
            $contentLanguage->setFileVersion($fileVersion);
            $contentLanguage->setLocale($locale);
            if (!$fileVersion->getContentLanguages()->contains($contentLanguage)) {
                $fileVersion->addContentLanguage($contentLanguage);
            }
        }

        return $this;
    }
495370
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerVersionQuery::create()
            ->filterByDealer($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
892439
public function setPublishLanguages($publishLanguages)
    {
        $fileVersion = $this->getFileVersion();

        foreach ($publishLanguages as $locale) {
            $publishLanguage = new FileVersionPublishLanguage();
            $publishLanguage->setFileVersion($fileVersion);
            $publishLanguage->setLocale($locale);
            if (!$fileVersion->getPublishLanguages()->contains($publishLanguage)) {
                $fileVersion->addPublishLanguage($publishLanguage);
            }
        }

        return $this;
    }
800088
public function getPrimaryLanguage(array $priorityLanguages = array())
    {
        $votedLanguages = $this->getVoteLanguages(self::VOTED_HIGH);

        if (!count($votedLanguages)) {
            $votedLanguages = $this->getVoteLanguages();

            if (!count($votedLanguages)) {
                return null;
            }
        }

        if (!count($priorityLanguages)) {
            return array_shift($votedLanguages);
        }

        if (count($priorityLanguages) == 1) {
            return $priorityLanguages[0];
        }

        foreach ($priorityLanguages as $priorityLanguage) {
            if (in_array($priorityLanguage, $votedLanguages)) {
                return $priorityLanguage;
            }
        }

        return array_shift($priorityLanguages);
    }
364468
public function getFieldName(SPIValue $value, FieldDefinition $fieldDefinition, $languageCode)
    {
        if (empty($value->destinationContentId)) {
            return '';
        }

        try {
            $contentInfo = $this->handler->loadContentInfo($value->destinationContentId);
            $versionInfo = $this->handler->loadVersionInfo($value->destinationContentId, $contentInfo->currentVersionNo);
        } catch (NotFoundException $e) {
            return '';
        }

        if (isset($versionInfo->names[$languageCode])) {
            return $versionInfo->names[$languageCode];
        }

        return $versionInfo->names[$contentInfo->mainLanguageCode];
    }