function block_configurable_language_delete

Same name in other branches
  1. 9 core/modules/block/block.module \block_configurable_language_delete()
  2. 10 core/modules/block/block.module \block_configurable_language_delete()
  3. 11.x core/modules/block/block.module \block_configurable_language_delete()

Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.

Delete the potential block visibility settings of the deleted language.

File

core/modules/block/block.module, line 276

Code

function block_configurable_language_delete(ConfigurableLanguageInterface $language) {
    // Remove the block visibility settings for the deleted language.
    foreach (Block::loadMultiple() as $block) {
        
        /** @var $block \Drupal\block\BlockInterface */
        $visibility = $block->getVisibility();
        if (isset($visibility['language']['langcodes'][$language->id()])) {
            unset($visibility['language']['langcodes'][$language->id()]);
            $block->setVisibilityConfig('language', $visibility['language']);
            $block->save();
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.