diff --git a/core/includes/language.inc b/core/includes/language.inc index e0550ff..03a9b48 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -134,10 +134,12 @@ function language_types_info() { * * @return * An array of language type names. + * + * @deprecated as of 8.0, use + * \Drupal::languageManager()->getConfigurableLanguageTypes() instead. */ function language_types_get_configurable() { - $configurable = \Drupal::config('system.language.types')->get('configurable'); - return $configurable ? $configurable : array(); + return \Drupal::languageManager()->getConfigurableLanguageTypes(); } /** diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index fffbb1e..3af2df7 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -130,6 +130,7 @@ public function init() { return; } if ($this->isMultilingual()) { + // FIXME! // This is still assumed by various functions to be loaded. include_once DRUPAL_ROOT . '/core/includes/language.inc'; } @@ -363,6 +364,13 @@ public function getLanguageTypes() { /** * {@inheritdoc} */ + public function getConfigurableLanguageTypes() { + return \Drupal::config('system.language.types')->get('configurable') ?: array(); + } + + /** + * {@inheritdoc} + */ public function getTypeDefaults() { return array( Language::TYPE_INTERFACE => TRUE, diff --git a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php index 2ac9137..2007985 100644 --- a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php +++ b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php @@ -141,6 +141,18 @@ public function getFallbackCandidates($langcode = NULL, array $context = array() public function getLanguageTypes(); /** + * Returns only the configurable language types. + * + * A language type maybe configurable or fixed. A fixed language type is a + * type whose language negotiation methods are module-defined and not altered + * through the user interface. + * + * @return + * An array of language type names. + */ + public function getConfigurableLanguageTypes(); + + /** * Returns a list of the built-in language types. * * @return array diff --git a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php index f91eed3..66813fc 100644 --- a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php +++ b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php @@ -117,7 +117,7 @@ public function processOutbound($path, &$options = array(), Request $request = N protected function initProcessors($scope) { $interface = '\Drupal\Core\PathProcessor\\' . Unicode::ucfirst($scope) . 'PathProcessorInterface'; $this->processors[$scope] = array(); - foreach (language_types_get_configurable() as $type) { + foreach ($this->languageManager->getConfigurableLanguageTypes() as $type) { foreach ($this->languageManager->getNegotiationMethods($type) as $method_id => $method) { if (!isset($this->processors[$scope][$method_id])) { $reflector = new \ReflectionClass($method['class']); diff --git a/core/modules/language/lib/Drupal/language/LanguageManager.php b/core/modules/language/lib/Drupal/language/LanguageManager.php index 8e11446..fc341fa 100644 --- a/core/modules/language/lib/Drupal/language/LanguageManager.php +++ b/core/modules/language/lib/Drupal/language/LanguageManager.php @@ -67,7 +67,7 @@ public function getLanguageList($flags = Language::STATE_CONFIGURABLE) { // Use language module configuration if available. $language_ids = $this->configStorage->listAll('language.entity'); - foreach (\Drupal::service('config.factory')->loadMultiple($language_ids) as $language_config) { + foreach ($this->configStorage->loadMultiple($language_ids) as $language_config) { $langcode = $language_config->get('id'); $info = $language_config->get(); $info['default'] = ($langcode == $default->id); diff --git a/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php b/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php index 226e1fe..615471f 100644 --- a/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php +++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/Plugin/LanguageNegotiation/LanguageNegotiationTest.php @@ -8,6 +8,7 @@ namespace Drupal\language_test\Plugin\LanguageNegotiation; use Drupal\Core\Language\LanguageNegotiationMethodBase; +use Drupal\Core\Session\AccountInterface; use Symfony\Component\HttpFoundation\Request; /** @@ -31,7 +32,7 @@ class LanguageNegotiationTest extends LanguageNegotiationMethodBase { /** * {@inheritdoc} */ - public function negotiateLanguage(array $languages, Request $request = NULL) { + public function negotiateLanguage(AccountInterface $current_user, Request $request = NULL) { return 'it'; }