Updates all Locations of content identified with $contentId with $versionNo.

@param mixed $contentId
@param mixed $versionNo
2050
public function updateLocationsContentVersionNo($contentId, $versionNo)
    {
        $query = $this->handler->createUpdateQuery();
        $query->update(
            $this->handler->quoteTable('ezcontentobject_tree')
        )->set(
            $this->handler->quoteColumn('contentobject_version'),
            $query->bindValue($versionNo, null, \PDO::PARAM_INT)
        )->where(
            $query->expr->eq(
                $this->handler->quoteColumn('contentobject_id'),
                $contentId
            )
        );
        $query->prepare()->execute();
    }
1195065
public function duplicateContent(ContentInterface $content, $contentId = null)
    {
        $newContent = $this->cloneContent($content);
        $newContent->setContentId($contentId);
        $newContent->setName($this->duplicateLabel($content->getName()));
        $newContent = $this->setVersionName($newContent);

        return $newContent;
    }
138493
protected function loadFieldData($fieldId, $versionNo)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select(
                // Tag
                'DISTINCT t.id AS eztags_id',
                't.parent_id AS eztags_parent_id',
                't.main_tag_id AS eztags_main_tag_id',
                't.keyword AS eztags_keyword',
                't.depth AS eztags_depth',
                't.path_string AS eztags_path_string',
                't.modified AS eztags_modified',
                't.remote_id AS eztags_remote_id',
                't.main_language_id AS eztags_main_language_id',
                't.language_mask AS eztags_language_mask',
                // Tag keywords
                'k.keyword AS eztags_keyword_keyword',
                'k.locale AS eztags_keyword_locale',
                // Tag attribute links
                'tal.priority AS eztags_attribute_link_priority'
            )
            ->from($this->connection->quoteIdentifier('eztags'), 't')
            ->innerJoin(
                't',
                $this->connection->quoteIdentifier('eztags_attribute_link'),
                'tal',
                $query->expr()->eq(
                    $this->connection->quoteIdentifier('t.id'),
                    $this->connection->quoteIdentifier('tal.keyword_id')
                )
            )
            ->innerJoin(
                't',
                $this->connection->quoteIdentifier('eztags_keyword'),
                'k',
                $query->expr()->eq(
                    $this->connection->quoteIdentifier('t.id'),
                    $this->connection->quoteIdentifier('k.keyword_id')
                )
            )->where(
                $query->expr()->andX(
                    $query->expr()->eq('tal.objectattribute_id', ':objectattribute_id'),
                    $query->expr()->eq('tal.objectattribute_version', ':objectattribute_version')
                )
            )
            ->setParameter(':objectattribute_id', $fieldId, PDO::PARAM_INT)
            ->setParameter(':objectattribute_version', $versionNo, PDO::PARAM_INT)
            ->orderBy($this->connection->quoteIdentifier('tal.priority'), 'ASC');

        $statement = $query->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);

        $tagList = [];
        foreach ($rows as $row) {
            $tagId = (int) $row['eztags_id'];
            if (!isset($tagList[$tagId])) {
                $tagList[$tagId] = [];
                $tagList[$tagId]['id'] = (int) $row['eztags_id'];
                $tagList[$tagId]['parent_id'] = (int) $row['eztags_parent_id'];
                $tagList[$tagId]['main_tag_id'] = (int) $row['eztags_main_tag_id'];
                $tagList[$tagId]['keywords'] = [];
                $tagList[$tagId]['depth'] = (int) $row['eztags_depth'];
                $tagList[$tagId]['path_string'] = $row['eztags_path_string'];
                $tagList[$tagId]['modified'] = (int) $row['eztags_modified'];
                $tagList[$tagId]['remote_id'] = $row['eztags_remote_id'];
                $tagList[$tagId]['always_available'] = ((int) $row['eztags_language_mask'] & 1) ? true : false;
                $tagList[$tagId]['main_language_code'] = $this->languageHandler->load($row['eztags_main_language_id'])->languageCode;
                $tagList[$tagId]['language_codes'] = [];
            }

            if (!isset($tagList[$tagId]['keywords'][$row['eztags_keyword_locale']])) {
                $tagList[$tagId]['keywords'][$row['eztags_keyword_locale']] = $row['eztags_keyword_keyword'];
            }

            if (!in_array($row['eztags_keyword_locale'], $tagList[$tagId]['language_codes'], true)) {
                $tagList[$tagId]['language_codes'][] = $row['eztags_keyword_locale'];
            }
        }

        return array_values($tagList);
    }
608958
static public function copyTranslations( $objectID, $versionNum )
    {
        $object = eZContentObject::fetch( $objectID );
        if ( !$object instanceof eZContentObject )
        {
            return array( 'status' => eZModuleOperationInfo::STATUS_CANCELLED );
        }
        $publishedVersionNum = $object->attribute( 'current_version' );
        if ( !$publishedVersionNum )
        {
            return;
        }
        $publishedVersion = $object->version( $publishedVersionNum );
        $publishedVersionTranslations = $publishedVersion->translations();
        $publishedLanguages = eZContentLanguage::languagesByMask( $object->attribute( 'language_mask' ) );
        $publishedLanguageCodes = array_keys( $publishedLanguages );

        $version = $object->version( $versionNum );
        $versionTranslationList = array_keys( eZContentLanguage::languagesByMask( $version->attribute( 'language_mask' ) ) );

        foreach ( $publishedVersionTranslations as $translation )
        {
            $translationLanguageCode = $translation->attribute( 'language_code' );
            if ( in_array( $translationLanguageCode, $versionTranslationList )
                || !in_array( $translationLanguageCode, $publishedLanguageCodes ) )
            {
                continue;
            }

            foreach ( $translation->objectAttributes() as $attribute )
            {
                $clonedAttribute = $attribute->cloneContentObjectAttribute( $versionNum, $publishedVersionNum, $objectID );
                $clonedAttribute->sync();
            }
        }

        $version->updateLanguageMask();
    }
1352922
public function updateContentObjects(Type $fromType, Type $toType)
    {
        $this->contentUpdater->applyUpdates(
            $fromType->id,
            $this->contentUpdater->determineActions($fromType, $toType)
        );
    }
556622
public function version($versionId, $reset = false)
    {
        $versions = $this->versions($reset);
        if (empty($versions[$versionId])) {
            return null;
        }

        return $versions[$versionId];
    }
342404
public function createOrUpdate($id, $instanceName, $content)
    {
        if ($this->exists($id, $instanceName)) {
            $this->update($id, $instanceName, $content);
        } else {
            $this->create($id, $instanceName, $content);
        }
    }
791049
static function removeById( $attributeId, $version = null )
    {
        if ( $version !== null )
    	   $conds = array( 'contentobject_attribute_id' => $attributeId, 'contentobject_version' => $version  );
    	else
    	    $conds = array( 'contentobject_attribute_id' => $attributeId );

        eZPersistentObject::removeObject( self::definition(), $conds, null );
    }
831973
public function contentVersion($contentId, $versionNo)
    {
        if ($this->allCleared === true || $this->isSwitchedOff()) {
            return;
        }

        // todo Once we can require 2.2.2+, simplify to just invalidate "content-{$contentId}-version-{$versionNo}"
        $this->cache->deleteItem("ez-content-version-info-${contentId}-${versionNo}");
        $this->cache->invalidateTags(["content-${contentId}-version-list", "content-{$contentId}-version-{$versionNo}"]);
    }
100493
public function redirectCurrentVersion($contentId)
    {
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);

        return new Values\TemporaryRedirect(
            $this->router->generate(
                'ezpublish_rest_loadContentInVersion',
                array(
                    'contentId' => $contentId,
                    'versionNumber' => $contentInfo->currentVersionNo,
                )
            )
        );
    }
1076697
public function linkUrl($urlId, $fieldId, $versionNo)
    {
        $query = $this->connection->createQueryBuilder();

        $query
            ->insert($this->connection->quoteIdentifier(self::URL_LINK_TABLE))
            ->values(
                [
                    'contentobject_attribute_id' => ':contentobject_attribute_id',
                    'contentobject_attribute_version' => ':contentobject_attribute_version',
                    'url_id' => ':url_id',
                ]
            )
            ->setParameter(':contentobject_attribute_id', $fieldId, PDO::PARAM_INT)
            ->setParameter(':contentobject_attribute_version', $versionNo, PDO::PARAM_INT)
            ->setParameter(':url_id', $urlId, PDO::PARAM_INT)
        ;

        $query->execute();
    }
46736
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
    {
        if (empty($fieldIds)) {
            // Nothing to do
            return;
        }

        $deleteQuery = $this->connection->createQueryBuilder();
        $deleteQuery
            ->delete($this->connection->quoteIdentifier(self::MAP_LOCATION_TABLE))
            ->where(
                $deleteQuery->expr()->andX(
                    $deleteQuery->expr()->in(
                        $this->connection->quoteIdentifier('contentobject_attribute_id'),
                        ':fieldIds'
                    ),
                    $deleteQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_version'),
                        ':versionNo'
                    )
                )
            )
            ->setParameter(':fieldIds', $fieldIds, Connection::PARAM_INT_ARRAY)
            ->setParameter(':versionNo', $versionInfo->versionNo, PDO::PARAM_INT)
        ;

        $deleteQuery->execute();
    }
228253
public function removeFileReferences(array $fieldIds, $versionNo)
    {
        if (empty($fieldIds)) {
            return;
        }

        $deleteQuery = $this->connection->createQueryBuilder();
        $deleteQuery
            ->delete($this->connection->quoteIdentifier($this->getStorageTable()))
            ->where(
                $deleteQuery->expr()->andX(
                    $deleteQuery->expr()->in(
                        $this->connection->quoteIdentifier('contentobject_attribute_id'),
                        ':fieldIds'
                    ),
                    $deleteQuery->expr()->eq(
                        $this->connection->quoteIdentifier('version'),
                        ':versionNo'
                    )
                )
            )
            ->setParameter(':fieldIds', $fieldIds, Connection::PARAM_INT_ARRAY)
            ->setParameter(':versionNo', $versionNo, PDO::PARAM_INT)
        ;

        $deleteQuery->execute();
    }
945247
public function deleteTranslationFromVersion($contentId, $versionNo, $languageCode)
    {
        try {
            return $this->innerGateway->deleteTranslationFromVersion($contentId, $versionNo, $languageCode);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
596795
public function linkUrl($urlId, $fieldId, $versionNo)
    {
        $dbHandler = $this->getConnection();

        $q = $dbHandler->createInsertQuery();
        $q->insertInto(
            $dbHandler->quoteTable(self::URL_LINK_TABLE)
        )->set(
            $dbHandler->quoteColumn('contentobject_attribute_id'),
            $q->bindValue($fieldId, null, PDO::PARAM_INT)
        )->set(
            $dbHandler->quoteColumn('contentobject_attribute_version'),
            $q->bindValue($versionNo, null, PDO::PARAM_INT)
        )->set(
            $dbHandler->quoteColumn('url_id'),
            $q->bindValue($urlId, null, PDO::PARAM_INT)
        );

        $q->prepare()->execute();
    }
176598
public function deleteFields($contentId, VersionInfo $versionInfo)
    {
        foreach ($this->contentGateway->getFieldIdsByType($contentId, $versionInfo->versionNo) as $fieldType => $ids) {
            $this->storageHandler->deleteFieldData($fieldType, $versionInfo, $ids);
        }
        $this->contentGateway->deleteFields($contentId, $versionInfo->versionNo);
    }
266916
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
    {
        $query = $this->connection->createQueryBuilder();
        $query->delete('ngsyliusproduct')
            ->where(
                $query->expr()->eq('contentobject_id', ':contentobject_id')
            )
            ->setParameter('contentobject_id', $versionInfo->contentInfo->id, Type::INTEGER);

        $query->execute();
    }