Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / language / src / Entity / ConfigurableLanguage.php
index c277a85bd76260d5767b66cfead646b12bb46b1a..25c588050af963cca41b0f2d5136f47e15a4b18a 100644 (file)
@@ -16,6 +16,13 @@ use Drupal\language\ConfigurableLanguageInterface;
  * @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 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
       // 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 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
     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();
   }
 
   /**