function NegotiationConfigureForm::disableLanguageSwitcher

Same name in other branches
  1. 9 core/modules/language/src/Form/NegotiationConfigureForm.php \Drupal\language\Form\NegotiationConfigureForm::disableLanguageSwitcher()
  2. 8.9.x core/modules/language/src/Form/NegotiationConfigureForm.php \Drupal\language\Form\NegotiationConfigureForm::disableLanguageSwitcher()
  3. 10 core/modules/language/src/Form/NegotiationConfigureForm.php \Drupal\language\Form\NegotiationConfigureForm::disableLanguageSwitcher()

Disables the language switcher blocks.

Parameters

array $language_types: An array containing all language types whose language switchers need to be disabled.

1 call to NegotiationConfigureForm::disableLanguageSwitcher()
NegotiationConfigureForm::submitForm in core/modules/language/src/Form/NegotiationConfigureForm.php
Form submission handler.

File

core/modules/language/src/Form/NegotiationConfigureForm.php, line 330

Class

NegotiationConfigureForm
Configure the selected language negotiation method for this site.

Namespace

Drupal\language\Form

Code

protected function disableLanguageSwitcher(array $language_types) {
    $theme = $this->themeHandler
        ->getDefault();
    $blocks = $this->blockStorage
        ->loadByProperties([
        'theme' => $theme,
    ]);
    foreach ($language_types as $language_type) {
        foreach ($blocks as $block) {
            if ($block->getPluginId() == 'language_block:' . $language_type) {
                $block->delete();
            }
        }
    }
}

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