From 163b7ab6e0958c71b6731860397aab972984a94c Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Fri, 4 Aug 2023 16:42:39 +0200 Subject: [PATCH] IBX-4031: Code cleanup --- eZ/Publish/Core/Repository/ContentService.php | 80 +------------------ 1 file changed, 1 insertion(+), 79 deletions(-) diff --git a/eZ/Publish/Core/Repository/ContentService.php b/eZ/Publish/Core/Repository/ContentService.php index f0c2990c79..faea58a9ef 100644 --- a/eZ/Publish/Core/Repository/ContentService.php +++ b/eZ/Publish/Core/Repository/ContentService.php @@ -1507,85 +1507,7 @@ public function publishVersion(APIVersionInfo $versionInfo, array $translations } /** - * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException - */ - protected function copyNonTranslatableFieldsFromPublishedVersion(APIContent $currentVersionContent): void - { - $versionInfo = $currentVersionContent->getVersionInfo(); - $contentType = $currentVersionContent->getContentType(); - - $publishedContent = $this->internalLoadContentById($versionInfo->getContentInfo()->getId()); - $publishedVersionInfo = $publishedContent->getVersionInfo(); - - if ( - !$publishedVersionInfo->isPublished() - || - ($versionInfo->versionNo >= $publishedVersionInfo->versionNo) - ) { - return; - } - - $publishedContentFieldsInMainLanguage = $publishedContent->getFieldsByLanguage( - $publishedContent->getVersionInfo()->getContentInfo()->getMainLanguageCode() - ); - - $fieldValues = []; - $persistenceFields = []; - foreach ($currentVersionContent->getFields() as $field) { - $fieldDefinition = $contentType->getFieldDefinition($field->fieldDefIdentifier); - $fieldValues[$fieldDefinition->identifier][$field->languageCode] = $field->getValue(); - - if ( - $fieldDefinition->isTranslatable - || $field->languageCode === $versionInfo->initialLanguageCode - ) { - continue; - } - - $fieldType = $this->fieldTypeRegistry->getFieldType( - $fieldDefinition->fieldTypeIdentifier - ); - - $newValue = $publishedContentFieldsInMainLanguage[$field->fieldDefIdentifier]->getValue(); - $fieldValues[$fieldDefinition->identifier][$field->languageCode] = $newValue; - - $persistenceFields[] = new SPIField( - [ - 'id' => $field->id, - 'fieldDefinitionId' => $fieldDefinition->id, - 'type' => $fieldDefinition->fieldTypeIdentifier, - 'value' => $fieldType->toPersistenceValue($newValue), - 'languageCode' => $field->languageCode, - 'versionNo' => $versionInfo->versionNo, - ] - ); - } - - $updateStruct = new SPIContentUpdateStruct(); - $updateStruct->name = $this->nameSchemaService->resolveNameSchema( - $currentVersionContent, - $fieldValues, - $versionInfo->languageCodes, - $contentType - ); - $updateStruct->initialLanguageId = $this->persistenceHandler - ->contentLanguageHandler() - ->loadByLanguageCode( - $versionInfo->initialLanguageCode - )->id; - $updateStruct->creatorId = $versionInfo->creatorId; - $updateStruct->modificationDate = time(); - $updateStruct->fields = $persistenceFields; - - $this->persistenceHandler->contentHandler()->updateContent( - $versionInfo->getContentInfo()->getId(), - $versionInfo->versionNo, - $updateStruct - ); - } - - /** - * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException + * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException */ protected function copyNonTranslatableFieldsFromPublishedVersion(APIContent $currentVersionContent): void {