private function _applyFieldTranslationSetting(ElementInterface $owner, SuperTableField $field)
    {
        // If the field is translatable, see if there are any global blocks that should be localized
        if ($field->localizeBlocks) {
            $blockQuery = SuperTableBlockElement::find()
                ->fieldId($field->id)
                ->ownerId($owner->id)
                ->anyStatus()
                ->siteId($owner->siteId)
                ->ownerSiteId(':empty:');

            $blocks = $blockQuery->all();

            if (!empty($blocks)) {
                // Duplicate the blocks for each of the owner's other sites
                $elementsService = Craft::$app->getElements();
                $siteIds = ArrayHelper::getColumn(ElementHelper::supportedSitesForElement($owner), 'siteId');
                
                foreach ($siteIds as $siteId) {
                    if ($siteId != $owner->siteId) {
                        $blockQuery->siteId = $siteId;
                        $siteBlocks = $blockQuery->all();

                        foreach ($siteBlocks as $siteBlock) {
                            $elementsService->duplicateElement($siteBlock, [
                                'siteId' => (int)$siteId,
                                'ownerSiteId' => (int)$siteId,
                            ]);
                        }
                    }
                }

                // Now resave the blocks for this site
                foreach ($blocks as $block) {
                    $block->ownerSiteId = $owner->siteId;
                    Craft::$app->getElements()->saveElement($block, false);
                }
            }
        } else {
            // Otherwise, see if the field has any localized blocks that should be deleted
            $elementsService = Craft::$app->getElements();

            foreach (Craft::$app->getSites()->getAllSiteIds() as $siteId) {
                if ($siteId != $owner->siteId) {
                    $blocks = SuperTableBlockElement::find()
                        ->fieldId($field->id)
                        ->ownerId($owner->id)
                        ->anyStatus()
                        ->siteId($siteId)
                        ->ownerSiteId($siteId)
                        ->all();

                    foreach ($blocks as $block) {
                        $elementsService->deleteElement($block);
                    }
                }
            }
        }
    }
private function _applyFieldTranslationSetting(ElementInterface $owner, SuperTableField $field)
    {
        // If the field is translatable, see if there are any global blocks that should be localized
        if ($field->localizeBlocks) {
            $blockQuery = SuperTableBlockElement::find()
                ->fieldId($field->id)
                ->ownerId($owner->id)
                ->anyStatus()
                ->siteId($owner->siteId)
                ->ownerSiteId(':empty:');

            $blocks = $blockQuery->all();

            if (!empty($blocks)) {
                // Duplicate the blocks for each of the owner's other sites
                $elementsService = Craft::$app->getElements();
                $siteIds = ArrayHelper::getColumn(ElementHelper::supportedSitesForElement($owner), 'siteId');
                
                foreach ($siteIds as $siteId) {
                    if ($siteId != $owner->siteId) {
                        $blockQuery->siteId = $siteId;
                        $siteBlocks = $blockQuery->all();

                        foreach ($siteBlocks as $siteBlock) {
                            $elementsService->duplicateElement($siteBlock, [
                                'siteId' => (int)$siteId,
                                'ownerSiteId' => (int)$siteId,
                            ]);
                        }
                    }
                }

                // Now resave the blocks for this site
                foreach ($blocks as $block) {
                    $block->ownerSiteId = $owner->siteId;
                    Craft::$app->getElements()->saveElement($block, false);
                }
            }
        } else {
            // Otherwise, see if the field has any localized blocks that should be deleted
            $elementsService = Craft::$app->getElements();

            foreach (Craft::$app->getSites()->getAllSiteIds() as $siteId) {
                if ($siteId != $owner->siteId) {
                    $blocks = SuperTableBlockElement::find()
                        ->fieldId($field->id)
                        ->ownerId($owner->id)
                        ->anyStatus()
                        ->siteId($siteId)
                        ->ownerSiteId($siteId)
                        ->all();

                    foreach ($blocks as $block) {
                        $elementsService->deleteElement($block);
                    }
                }
            }
        }
    }
private function _applyFieldTranslationSetting ( ElementInterface $ owner , SuperTableField $ field ) { // If the field is translatable, see if there are any global blocks that should be localized if ( $ field -> localizeBlocks ) { $ blockQuery = SuperTableBlockElement :: find ( ) -> fieldId ( $ field -> id ) -> ownerId ( $ owner -> id ) -> anyStatus ( ) -> siteId ( $ owner -> siteId ) -> ownerSiteId ( ':empty:' ) ; $ blocks = $ blockQuery -> all ( ) ; if ( ! empty ( $ blocks ) ) { // Duplicate the blocks for each of the owner's other sites $ elementsService = Craft :: $ app -> getElements ( ) ; $ siteIds = ArrayHelper :: getColumn ( ElementHelper :: supportedSitesForElement ( $ owner ) , 'siteId' ) ; foreach ( $ siteIds as $ siteId ) { if ( $ siteId != $ owner -> siteId ) { $ blockQuery -> siteId = $ siteId ; $ siteBlocks = $ blockQuery -> all ( ) ; foreach ( $ siteBlocks as $ siteBlock ) { $ elementsService -> duplicateElement ( $ siteBlock , [ 'siteId' => ( int ) $ siteId , 'ownerSiteId' => ( int ) $ siteId , ] ) ; } } } // Now resave the blocks for this site foreach ( $ blocks as $ block ) { $ block -> ownerSiteId = $ owner -> siteId ; Craft :: $ app -> getElements ( ) -> saveElement ( $ block , false ) ; } } } else { // Otherwise, see if the field has any localized blocks that should be deleted $ elementsService = Craft :: $ app -> getElements ( ) ; foreach ( Craft :: $ app -> getSites ( ) -> getAllSiteIds ( ) as $ siteId ) { if ( $ siteId != $ owner -> siteId ) { $ blocks = SuperTableBlockElement :: find ( ) -> fieldId ( $ field -> id ) -> ownerId ( $ owner -> id ) -> anyStatus ( ) -> siteId ( $ siteId ) -> ownerSiteId ( $ siteId ) -> all ( ) ; foreach ( $ blocks as $ block ) { $ elementsService -> deleteElement ( $ block ) ; } } } } }
Applies the field's translation setting to a set of blocks.

@param ElementInterface $owner
@param SuperTableField $field
Applies the field s translation setting to a set of blocks .