diff core/modules/language/src/Entity/ConfigurableLanguage.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children af1871eacc83
line wrap: on
line diff
--- a/core/modules/language/src/Entity/ConfigurableLanguage.php	Tue Jul 10 15:07:59 2018 +0100
+++ b/core/modules/language/src/Entity/ConfigurableLanguage.php	Thu Feb 28 13:21:36 2019 +0000
@@ -16,6 +16,13 @@
  * @ConfigEntityType(
  *   id = "configurable_language",
  *   label = @Translation("Language"),
+ *   label_collection = @Translation("Languages"),
+ *   label_singular = @Translation("language"),
+ *   label_plural = @Translation("languages"),
+ *   label_count = @PluralTranslation(
+ *     singular = "@count language",
+ *     plural = "@count languages",
+ *   ),
  *   handlers = {
  *     "list_builder" = "Drupal\language\LanguageListBuilder",
  *     "access" = "Drupal\language\LanguageAccessControlHandler",
@@ -139,6 +146,14 @@
       // 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();
+    }
   }
 
   /**
@@ -173,6 +188,12 @@
     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();
   }
 
   /**