function ConfigurableLanguage::preDelete

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

Throws

\DeleteDefaultLanguageException Exception thrown if we're trying to delete the default language entity. This is not allowed as a site must have a default language.

Overrides ConfigEntityBase::preDelete

File

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

Class

ConfigurableLanguage
Defines the ConfigurableLanguage entity.

Namespace

Drupal\language\Entity

Code

public static function preDelete(EntityStorageInterface $storage, array $entities) {
    $default_langcode = static::getDefaultLangcode();
    foreach ($entities as $entity) {
        if ($entity->id() == $default_langcode && !$entity->isUninstalling()) {
            throw new DeleteDefaultLanguageException('Can not delete the default language');
        }
    }
}

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