function ConfigurableLanguage::postSave

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

Overrides EntityBase::postSave

File

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

Class

ConfigurableLanguage
Defines the ConfigurableLanguage entity.

Namespace

Drupal\language\Entity

Code

public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);
    $language_manager = \Drupal::languageManager();
    $language_manager->reset();
    if (!$this->isLocked() && $language_manager instanceof ConfigurableLanguageManagerInterface && !$this->isSyncing()) {
        $language_manager->updateLockedLanguageWeights();
    }
    // Update URL Prefixes for all languages after the
    // LanguageManagerInterface::getLanguages() cache is flushed.
    language_negotiation_url_prefixes_update();
    // If after adding this language the site will become multilingual, we need
    // to rebuild language services.
    if (!$this->preSaveMultilingual && !$update && $language_manager instanceof ConfigurableLanguageManagerInterface) {
        $language_manager::rebuildServices();
    }
    if (!$update) {
        // Install any available language configuration overrides for the language.
        \Drupal::service('language.config_factory_override')->installLanguageOverrides($this->id());
    }
    if (!$this->isLocked() && !$update) {
        // Add language to the list of language domains.
        $config = \Drupal::configFactory()->getEditable('language.negotiation');
        $domains = $config->get('url.domains');
        $domains[$this->id()] = '';
        $config->set('url.domains', $domains)
            ->save(TRUE);
    }
}

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