Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BlockHooks.php

function BlockHooks::configurableLanguageDelete

Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.

Delete the potential block visibility settings of the deleted language.

File

core/modules/block/src/Hook/BlockHooks.php, line 171

Class

BlockHooks
Hook implementations for block.

Namespace

Drupal\block\Hook

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal