private function promptUserForMainLanguageChange(
        ContentInfo $contentInfo,
        $languageCode,
        array $lastVersionLanguageCodes
    ) {
        $contentName = "#{$contentInfo->id} ($contentInfo->name)";
        $this->output->writeln(
            "<comment>The specified Translation '{$languageCode}' is the Main Translation of the Content {$contentName}. It needs to be changed before removal.</comment>"
        );

        // get main Translation candidates w/o Translation being removed
        $mainTranslationCandidates = array_filter(
            $lastVersionLanguageCodes,
            function ($versionLanguageCode) use ($languageCode) {
                return $versionLanguageCode !== $languageCode;
            }
        );
        if (empty($mainTranslationCandidates)) {
            throw new InvalidArgumentException(
                'language-code',
                "The last Version of the Content {$contentName} has no other Translations beside the main one"
            );
        }
        $question = new ChoiceQuestion(
            "Set the Main Translation of the Content {$contentName} to:",
            array_values($mainTranslationCandidates)
        );

        $newMainLanguageCode = $this->questionHelper->ask($this->input, $this->output, $question);
        $this->output->writeln(
            "<info>Updating Main Translation of the Content {$contentName} to {$newMainLanguageCode}</info>"
        );

        $contentMetadataUpdateStruct = $this->contentService->newContentMetadataUpdateStruct();
        $contentMetadataUpdateStruct->mainLanguageCode = $newMainLanguageCode;

        return $this->contentService->updateContentMetadata(
            $contentInfo,
            $contentMetadataUpdateStruct
        )->contentInfo;
    }
private function promptUserForMainLanguageChange(
        ContentInfo $contentInfo,
        $languageCode,
        array $lastVersionLanguageCodes
    ) {
        $contentName = "#{$contentInfo->id} ($contentInfo->name)";
        $this->output->writeln(
            "<comment>The specified Translation '{$languageCode}' is the Main Translation of the Content {$contentName}. It needs to be changed before removal.</comment>"
        );

        // get main Translation candidates w/o Translation being removed
        $mainTranslationCandidates = array_filter(
            $lastVersionLanguageCodes,
            function ($versionLanguageCode) use ($languageCode) {
                return $versionLanguageCode !== $languageCode;
            }
        );
        if (empty($mainTranslationCandidates)) {
            throw new InvalidArgumentException(
                'language-code',
                "The last Version of the Content {$contentName} has no other Translations beside the main one"
            );
        }
        $question = new ChoiceQuestion(
            "Set the Main Translation of the Content {$contentName} to:",
            array_values($mainTranslationCandidates)
        );

        $newMainLanguageCode = $this->questionHelper->ask($this->input, $this->output, $question);
        $this->output->writeln(
            "<info>Updating Main Translation of the Content {$contentName} to {$newMainLanguageCode}</info>"
        );

        $contentMetadataUpdateStruct = $this->contentService->newContentMetadataUpdateStruct();
        $contentMetadataUpdateStruct->mainLanguageCode = $newMainLanguageCode;

        return $this->contentService->updateContentMetadata(
            $contentInfo,
            $contentMetadataUpdateStruct
        )->contentInfo;
    }
private function promptUserForMainLanguageChange ( ContentInfo $ contentInfo , $ languageCode , array $ lastVersionLanguageCodes ) { $ contentName = "#{$contentInfo->id} ($contentInfo->name)" ; $ this -> output -> writeln ( "<comment>The specified Translation '{$languageCode}' is the Main Translation of the Content {$contentName}. It needs to be changed before removal.</comment>" ) ; // get main Translation candidates w/o Translation being removed $ mainTranslationCandidates = array_filter ( $ lastVersionLanguageCodes , function ( $ versionLanguageCode ) use ( $ languageCode ) { return $ versionLanguageCode !== $ languageCode ; } ) ; if ( empty ( $ mainTranslationCandidates ) ) { throw new InvalidArgumentException ( 'language-code' , "The last Version of the Content {$contentName} has no other Translations beside the main one" ) ; } $ question = new ChoiceQuestion ( "Set the Main Translation of the Content {$contentName} to:" , array_values ( $ mainTranslationCandidates ) ) ; $ newMainLanguageCode = $ this -> questionHelper -> ask ( $ this -> input , $ this -> output , $ question ) ; $ this -> output -> writeln ( "<info>Updating Main Translation of the Content {$contentName} to {$newMainLanguageCode}</info>" ) ; $ contentMetadataUpdateStruct = $ this -> contentService -> newContentMetadataUpdateStruct ( ) ; $ contentMetadataUpdateStruct -> mainLanguageCode = $ newMainLanguageCode ; return $ this -> contentService -> updateContentMetadata ( $ contentInfo , $ contentMetadataUpdateStruct ) -> contentInfo ; }
Interact with user to update main Language of a Content Object.

@param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
@param string $languageCode language code of the Translation to be deleted
@param string[] $lastVersionLanguageCodes all Translations last Version has.

@return \eZ\Publish\API\Repository\Values\Content\ContentInfo
Interact with user to update main Language of a Content Object .