function ConfigurableLanguage::postDelete

Same name in other branches
  1. 9 core/modules/language/src/Entity/ConfigurableLanguage.php \Drupal\language\Entity\ConfigurableLanguage::postDelete()
  2. 10 core/modules/language/src/Entity/ConfigurableLanguage.php \Drupal\language\Entity\ConfigurableLanguage::postDelete()
  3. 11.x core/modules/language/src/Entity/ConfigurableLanguage.php \Drupal\language\Entity\ConfigurableLanguage::postDelete()

Overrides EntityBase::postDelete

File

core/modules/language/src/Entity/ConfigurableLanguage.php, line 185

Class

ConfigurableLanguage
Defines the ConfigurableLanguage entity.

Namespace

Drupal\language\Entity

Code

public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage, $entities);
    $language_manager = \Drupal::languageManager();
    $language_manager->reset();
    $entity = reset($entities);
    if ($language_manager instanceof ConfigurableLanguageManagerInterface && !$entity->isUninstalling() && !$entity->isSyncing()) {
        $language_manager->updateLockedLanguageWeights();
    }
    // If after deleting this language the site will become monolingual, we need
    // to rebuild language services.
    if (!\Drupal::languageManager()->isMultilingual()) {
        ConfigurableLanguageManager::rebuildServices();
    }
    // Remove language from language prefix and domain list.
    $config = \Drupal::configFactory()->getEditable('language.negotiation');
    $config->clear('url.prefixes.' . $entity->id());
    $config->clear('url.domains.' . $entity->id());
    $config->save(TRUE);
}

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