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

Breadcrumb

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

function ConfigurableLanguage::preDelete

Throws

\Drupal\language\Exception\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 179

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

API Navigation

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