function block_configurable_language_delete

block_configurable_language_delete(ConfigurableLanguageInterface $language)

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 275
Controls the visual building blocks a page is constructed with.

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();
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!block!block.module/function/block_configurable_language_delete/8.1.x