lib/Core/Service/BlockService.php
private function updateBlockTranslations(
        BlockDefinitionInterface $blockDefinition,
        PersistenceBlock $persistenceBlock,
        APIBlockUpdateStruct $blockUpdateStruct
    ): PersistenceBlock {
        if ($blockUpdateStruct->locale === $persistenceBlock->mainLocale) {
            $persistenceBlock = $this->blockHandler->updateBlockTranslation(
                $persistenceBlock,
                $blockUpdateStruct->locale,
                BlockTranslationUpdateStruct::fromArray(
                    [
                        'parameters' => iterator_to_array(
                            $this->parameterMapper->serializeValues(
                                $blockDefinition,
                                $blockUpdateStruct->getParameterValues(),
                                $persistenceBlock->parameters[$persistenceBlock->mainLocale]
                            )
                        ),
                    ]
                )
            );
        }

        $untranslatableParams = iterator_to_array(
            $this->parameterMapper->extractUntranslatableParameters(
                $blockDefinition,
                $persistenceBlock->parameters[$persistenceBlock->mainLocale]
            )
        );

        $localesToUpdate = [$blockUpdateStruct->locale];
        if ($persistenceBlock->mainLocale === $blockUpdateStruct->locale) {
            $localesToUpdate = $persistenceBlock->availableLocales;

            // Remove the main locale from the array, since we already updated that one
            $mainLocaleOffset = array_search($persistenceBlock->mainLocale, $persistenceBlock->availableLocales, true);
            if (is_int($mainLocaleOffset)) {
                array_splice($localesToUpdate, $mainLocaleOffset, 1);
            }
        }

        foreach ($localesToUpdate as $locale) {
            $params = $persistenceBlock->parameters[$locale];

            if ($locale === $blockUpdateStruct->locale) {
                $params = iterator_to_array(
                    $this->parameterMapper->serializeValues(
                        $blockDefinition,
                        $blockUpdateStruct->getParameterValues(),
                        $params
                    )
                );
            }

            $persistenceBlock = $this->blockHandler->updateBlockTranslation(
                $persistenceBlock,
                $locale,
                BlockTranslationUpdateStruct::fromArray(
                    [
                        'parameters' => $untranslatableParams + $params,
                    ]
                )
            );
        }

        return $persistenceBlock;
    }
private function updateBlockTranslations(
        BlockDefinitionInterface $blockDefinition,
        PersistenceBlock $persistenceBlock,
        APIBlockUpdateStruct $blockUpdateStruct
    ): PersistenceBlock {
        if ($blockUpdateStruct->locale === $persistenceBlock->mainLocale) {
            $persistenceBlock = $this->blockHandler->updateBlockTranslation(
                $persistenceBlock,
                $blockUpdateStruct->locale,
                BlockTranslationUpdateStruct::fromArray(
                    [
                        'parameters' => iterator_to_array(
                            $this->parameterMapper->serializeValues(
                                $blockDefinition,
                                $blockUpdateStruct->getParameterValues(),
                                $persistenceBlock->parameters[$persistenceBlock->mainLocale]
                            )
                        ),
                    ]
                )
            );
        }

        $untranslatableParams = iterator_to_array(
            $this->parameterMapper->extractUntranslatableParameters(
                $blockDefinition,
                $persistenceBlock->parameters[$persistenceBlock->mainLocale]
            )
        );

        $localesToUpdate = [$blockUpdateStruct->locale];
        if ($persistenceBlock->mainLocale === $blockUpdateStruct->locale) {
            $localesToUpdate = $persistenceBlock->availableLocales;

            // Remove the main locale from the array, since we already updated that one
            $mainLocaleOffset = array_search($persistenceBlock->mainLocale, $persistenceBlock->availableLocales, true);
            if (is_int($mainLocaleOffset)) {
                array_splice($localesToUpdate, $mainLocaleOffset, 1);
            }
        }

        foreach ($localesToUpdate as $locale) {
            $params = $persistenceBlock->parameters[$locale];

            if ($locale === $blockUpdateStruct->locale) {
                $params = iterator_to_array(
                    $this->parameterMapper->serializeValues(
                        $blockDefinition,
                        $blockUpdateStruct->getParameterValues(),
                        $params
                    )
                );
            }

            $persistenceBlock = $this->blockHandler->updateBlockTranslation(
                $persistenceBlock,
                $locale,
                BlockTranslationUpdateStruct::fromArray(
                    [
                        'parameters' => $untranslatableParams + $params,
                    ]
                )
            );
        }

        return $persistenceBlock;
    }
private function updateBlockTranslations ( BlockDefinitionInterface $ blockDefinition , PersistenceBlock $ persistenceBlock , APIBlockUpdateStruct $ blockUpdateStruct ) : PersistenceBlock { if ( $ blockUpdateStruct -> locale === $ persistenceBlock -> mainLocale ) { $ persistenceBlock = $ this -> blockHandler -> updateBlockTranslation ( $ persistenceBlock , $ blockUpdateStruct -> locale , BlockTranslationUpdateStruct :: fromArray ( [ 'parameters' => iterator_to_array ( $ this -> parameterMapper -> serializeValues ( $ blockDefinition , $ blockUpdateStruct -> getParameterValues ( ) , $ persistenceBlock -> parameters [ $ persistenceBlock -> mainLocale ] ) ) , ] ) ) ; } $ untranslatableParams = iterator_to_array ( $ this -> parameterMapper -> extractUntranslatableParameters ( $ blockDefinition , $ persistenceBlock -> parameters [ $ persistenceBlock -> mainLocale ] ) ) ; $ localesToUpdate = [ $ blockUpdateStruct -> locale ] ; if ( $ persistenceBlock -> mainLocale === $ blockUpdateStruct -> locale ) { $ localesToUpdate = $ persistenceBlock -> availableLocales ; // Remove the main locale from the array, since we already updated that one $ mainLocaleOffset = array_search ( $ persistenceBlock -> mainLocale , $ persistenceBlock -> availableLocales , true ) ; if ( is_int ( $ mainLocaleOffset ) ) { array_splice ( $ localesToUpdate , $ mainLocaleOffset , 1 ) ; } } foreach ( $ localesToUpdate as $ locale ) { $ params = $ persistenceBlock -> parameters [ $ locale ] ; if ( $ locale === $ blockUpdateStruct -> locale ) { $ params = iterator_to_array ( $ this -> parameterMapper -> serializeValues ( $ blockDefinition , $ blockUpdateStruct -> getParameterValues ( ) , $ params ) ) ; } $ persistenceBlock = $ this -> blockHandler -> updateBlockTranslation ( $ persistenceBlock , $ locale , BlockTranslationUpdateStruct :: fromArray ( [ 'parameters' => $ untranslatableParams + $ params , ] ) ) ; } return $ persistenceBlock ; }
Updates translations for specified block.

This makes sure that untranslatable parameters are always kept in sync between all
available translations in the block. This means that if main translation is updated,
all other translations need to be updated too to reflect changes to untranslatable params,
and if any other translation is updated, it needs to take values of untranslatable params
from the main translation.
Updates translations for specified block .