Commit 0b55dcd8 authored by catch's avatar catch

Issue #1862202 by plach, Berdir, katbailey, ParisLiakos, alexpott, chx, sun,...

Issue #1862202 by plach, Berdir, katbailey, ParisLiakos, alexpott, chx, sun, larowlan, Gábor Hojtsy, cosmicdreams, vijaycs85, YesCT, penyaskito, andypost, Albert Volkman, joelpitett: Objectify the language system.
parent 37723a56
......@@ -225,7 +225,6 @@ services:
arguments: ['@event_dispatcher', '@service_container', '@controller_resolver']
language_manager:
class: Drupal\Core\Language\LanguageManager
arguments: ['@state', '@module_handler']
string_translator.custom_strings:
class: Drupal\Core\StringTranslation\Translator\CustomStrings
arguments: ['@settings']
......@@ -233,6 +232,9 @@ services:
- { name: string_translator, priority: 30 }
string_translation:
class: Drupal\Core\StringTranslation\TranslationManager
arguments: ['@language_manager']
calls:
- [initLanguageManager]
database.slave:
class: Drupal\Core\Database\Connection
factory_class: Drupal\Core\Database\Database
......@@ -518,11 +520,6 @@ services:
tags:
- { name: event_subscriber }
arguments: ['@config.storage', '@config.storage.snapshot']
language_request_subscriber:
class: Drupal\Core\EventSubscriber\LanguageRequestSubscriber
tags:
- { name: event_subscriber }
arguments: ['@language_manager', '@string_translation']
exception_controller:
class: Drupal\Core\Controller\ExceptionController
arguments: ['@content_negotiation', '@string_translation', '@title_resolver', '@html_page_renderer']
......
......@@ -2331,7 +2331,7 @@ function drupal_installation_attempted() {
function drupal_language_initialize() {
$language_manager = \Drupal::languageManager();
$language_manager->init();
\Drupal::translation()->setDefaultLangcode($language_manager->getLanguage(Language::TYPE_INTERFACE)->id);
\Drupal::translation()->setDefaultLangcode($language_manager->getCurrentLanguage()->id);
}
/**
......@@ -2343,47 +2343,10 @@ function drupal_language_initialize() {
* The type of language object needed, e.g. Language::TYPE_INTERFACE.
*
* @deprecated as of Drupal 8.0. Use
* \Drupal::languageManager()->getLanguage($type).
* \Drupal::languageManager()->getCurrentLanguage().
*/
function language($type) {
return \Drupal::languageManager()->getLanguage($type);
}
/**
* Returns an array of the available language types.
*
* @return array
* An array of all language types where the keys of each are the language type
* name and its value is its configurability (TRUE/FALSE).
*/
function language_types_get_all() {
$types = \Drupal::config('system.language.types')->get('all');
return $types ? $types : array_keys(language_types_get_default());
}
/**
* Returns a list of the built-in language types.
*
* @return array
* An array of key-values pairs where the key is the language type name and
* the value is its configurability (TRUE/FALSE).
*/
function language_types_get_default() {
return array(
Language::TYPE_INTERFACE => TRUE,
Language::TYPE_CONTENT => FALSE,
Language::TYPE_URL => FALSE,
);
}
/**
* Returns TRUE if there is more than one language enabled.
*
* @return bool
* TRUE if more than one language is enabled.
*/
function language_multilingual() {
return \Drupal::languageManager()->isMultilingual();
return \Drupal::languageManager()->getCurrentLanguage($type);
}
/**
......@@ -2397,101 +2360,12 @@ function language_multilingual() {
* @return array
* An associative array of languages, keyed by the language code, ordered by
* weight ascending and name ascending.
*/
function language_list($flags = Language::STATE_CONFIGURABLE) {
$languages = &drupal_static(__FUNCTION__);
// Initialize master language list.
if (!isset($languages)) {
// Initialize local language list cache.
$languages = array();
// Fill in master language list based on current configuration.
$default = language_default();
if (language_multilingual() || \Drupal::moduleHandler()->moduleExists('language')) {
// Use language module configuration if available.
$language_entities = config_get_storage_names_with_prefix('language.entity.');
// Initialize default property so callers have an easy reference and can
// save the same object without data loss.
foreach ($language_entities as $langcode_config_name) {
$langcode = substr($langcode_config_name, strlen('language.entity.'));
$info = \Drupal::config($langcode_config_name)->get();
$languages[$langcode] = new Language(array(
'default' => ($info['id'] == $default->id),
'name' => $info['label'],
'id' => $info['id'],
'direction' => $info['direction'],
'locked' => $info['locked'],
'weight' => $info['weight'],
));
}
Language::sort($languages);
}
// If the language module is enabled but the configuration has not been
// written yet, returning an empty language list will cause errors. For
// example the cache clear in search_module_preinstall().
if (empty($languages)) {
// No language module, so use the default language only.
$languages = array($default->id => $default);
// Add the special languages, they will be filtered later if needed.
$languages += language_default_locked_languages($default->weight);
}
}
// Filter the full list of languages based on the value of the $all flag. By
// default we remove the locked languages, but the caller may request for
// those languages to be added as well.
$filtered_languages = array();
// Add the site's default language if flagged as allowed value.
if ($flags & Language::STATE_SITE_DEFAULT) {
$default = isset($default) ? $default : language_default();
// Rename the default language.
$default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name));
$filtered_languages['site_default'] = $default;
}
foreach ($languages as $langcode => $language) {
if (($language->locked && !($flags & Language::STATE_LOCKED)) || (!$language->locked && !($flags & Language::STATE_CONFIGURABLE))) {
continue;
}
$filtered_languages[$langcode] = $language;
}
return $filtered_languages;
}
/**
* Returns a list of the default locked languages.
*
* @param int $weight
* An integer value that is used as the start value for the weights of the
* locked languages.
*
* @return array
* An array of language objects.
* @deprecated as of Drupal 8.0. Use
* \Drupal::languageManager()->getLanguages() instead.
*/
function language_default_locked_languages($weight = 0) {
$locked_language = array(
'default' => FALSE,
'locked' => TRUE,
'enabled' => TRUE,
);
$languages = array();
$languages[Language::LANGCODE_NOT_SPECIFIED] = new Language(array(
'id' => Language::LANGCODE_NOT_SPECIFIED,
'name' => t('Not specified'),
'weight' => ++$weight,
) + $locked_language);
$languages[Language::LANGCODE_NOT_APPLICABLE] = new Language(array(
'id' => Language::LANGCODE_NOT_APPLICABLE,
'name' => t('Not applicable'),
'weight' => ++$weight,
) + $locked_language);
return $languages;
function language_list($flags = Language::STATE_CONFIGURABLE) {
return \Drupal::languageManager()->getLanguages($flags);
}
/**
......@@ -2502,47 +2376,14 @@ function language_default_locked_languages($weight = 0) {
*
* @return \Drupal\core\Language\Language|null
* A fully-populated language object or NULL.
*/
function language_load($langcode) {
$languages = language_list(Language::STATE_ALL);
return isset($languages[$langcode]) ? $languages[$langcode] : NULL;
}
/**
* Produced the printed name for a language for display.
*
* @param string $langcode
* The language code.
* @see \Drupal\Core\Language\LanguageManager::getLanguage()
*
* @return string
* The printed name of the language.
* @deprecated as of Drupal 8.0. Use \Drupal::languageManager()->getLanguage()
* instead.
*/
function language_name($langcode) {
if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
return t('None');
}
if ($language = language_load($langcode)) {
return $language->name;
}
if (empty($langcode)) {
return t('Unknown');
}
return t('Unknown (@langcode)', array('@langcode' => $langcode));
}
/**
* Checks if a language is locked.
*
* @param string $langcode
* The language code.
*
* @return bool
* Returns whether the language is locked.
*/
function language_is_locked($langcode) {
$language = language_load($langcode);
return ($language ? $language->locked : FALSE);
function language_load($langcode) {
return \Drupal::languageManager()->getLanguage($langcode);
}
/**
......@@ -2550,35 +2391,12 @@ function language_is_locked($langcode) {
*
* @return \Drupal\Core\Language\Language
* A language object.
*/
function language_default() {
$info = variable_get('language_default', array(
'id' => 'en',
'name' => 'English',
'direction' => 0,
'weight' => 0,
'locked' => 0,
));
$info['default'] = TRUE;
return new Language($info);
}
/**
* Stores or retrieves the path derived during language negotiation.
*
* @param string $new_path
* The altered path.
*
* @todo Replace this with a path processor in language module. See
* http://drupal.org/node/1888424.
* @deprecated as of Drupal 8.0. Use
* \Drupal::languageManager()->getDefaultLanguage() instead.
*/
function _language_resolved_path($new_path = NULL) {
$path = &drupal_static(__FUNCTION__, NULL);
if ($new_path === NULL) {
return $path;
}
$path = $new_path;
return $path;
function language_default() {
return \Drupal::languageManager()->getDefaultLanguage();
}
/**
......
......@@ -4531,11 +4531,12 @@ function drupal_render_cid_parts($granularity = NULL) {
global $theme, $base_root, $user;
$cid_parts[] = $theme;
// If Locale is enabled but we have only one language we do not need it as cid
// part.
if (language_multilingual()) {
foreach (language_types_get_configurable() as $language_type) {
$cid_parts[] = language($language_type)->id;
// If we have only one language enabled we do not need it as cid part.
$language_manager = \Drupal::languageManager();
if ($language_manager->isMultilingual()) {
foreach ($language_manager->getLanguageTypes() as $type) {
$cid_parts[] = $language_manager->getCurrentLanguage($type)->id;
}
}
......
<?php
use Drupal\Component\Utility\UserAgent;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Settings;
......@@ -300,6 +301,9 @@ function install_begin_request(&$install_state) {
exit;
}
// Register the 'language_manager' service.
$container->register('language_manager', 'Drupal\Core\Language\LanguageManager');
// If we have a language selected and it is not yet saved in the system
// (eg. pre-database data screens we are unable to persistently store
// the default language), we should set language_default so the proper
......@@ -370,7 +374,6 @@ function install_begin_request(&$install_state) {
else {
// @todo Move into a proper Drupal\Core\DependencyInjection\InstallContainerBuilder.
$container = new ContainerBuilder();
$container->register('event_dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher');
$container->register('config.storage', 'Drupal\Core\Config\InstallStorage');
......@@ -388,9 +391,7 @@ function install_begin_request(&$install_state) {
->addArgument(new Reference('config.typed'));
// Register the 'language_manager' service.
$container
->register('language_manager', 'Drupal\Core\Language\LanguageManager')
->addArgument(NULL);
$container->register('language_manager', 'Drupal\Core\Language\LanguageManager');
// Register the translation services.
install_register_translation_service($container);
......@@ -1505,6 +1506,7 @@ function install_register_translation_service(ContainerBuilder $container) {
$container->register('string_translator.custom_strings', 'Drupal\Core\StringTranslation\Translator\CustomStrings')
->addArgument(settings());
$container->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager')
->addArgument(new Reference('language_manager'))
->addMethodCall('addTranslator', array(new Reference('string_translator.file_translation')))
->addMethodCall('addTranslator', array(new Reference('string_translator.custom_strings')));
}
......@@ -1582,9 +1584,6 @@ function install_select_language(&$install_state) {
* @ingroup forms
*/
function install_select_language_form($form, &$form_state, $files = array()) {
include_once __DIR__ . '/../modules/language/language.module';
include_once __DIR__ . '/../modules/language/language.negotiation.inc';
$standard_languages = LanguageManager::getStandardLanguageList();
$select_options = array();
$browser_options = array();
......@@ -1596,22 +1595,19 @@ function install_select_language_form($form, &$form_state, $files = array()) {
// Select lists based on available language files.
foreach ($files as $langcode => $uri) {
$select_options[$langcode] = isset($standard_languages[$langcode]) ? $standard_languages[$langcode][1] : $langcode;
$browser_options[$langcode] = new Language(array(
'id' => $langcode,
));
$browser_options[] = $langcode;
}
}
else {
// Select lists based on all standard languages.
foreach ($standard_languages as $langcode => $language_names) {
$select_options[$langcode] = $language_names[1];
$browser_options[$langcode] = new Language(array(
'id' => $langcode,
));
$browser_options[] = $langcode;
}
}
$browser_langcode = language_from_browser($browser_options);
$request = Request::createFromGlobals();
$browser_langcode = UserAgent::getBestMatchingLangcode($request->server->get('HTTP_ACCEPT_LANGUAGE'), $browser_options);
$form['langcode'] = array(
'#type' => 'select',
'#title' => t('Choose language'),
......
This diff is collapsed.
......@@ -1235,7 +1235,7 @@ function theme_links($variables) {
$output .= '<ul' . new Attribute($attributes) . '>';
$active = \Drupal::linkGenerator()->getActive();
$language_url = \Drupal::languageManager()->getLanguage(Language::TYPE_URL);
$language_url = \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_URL);
foreach ($links as $key => $link) {
$link += array(
......@@ -2072,7 +2072,7 @@ function template_preprocess_html(&$variables) {
$variables['html_attributes'] = new Attribute;
// HTML element attributes.
$language_interface = \Drupal::service('language_manager')->getLanguage();
$language_interface = \Drupal::service('language_manager')->getCurrentLanguage();
$variables['html_attributes']['lang'] = $language_interface->id;
$variables['html_attributes']['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
......
......@@ -478,9 +478,7 @@ function update_prepare_stored_includes() {
foreach ($language_types as $language_type) {
$negotiation = update_variable_get("language_negotiation_$language_type", array());
foreach ($negotiation as &$method) {
if (isset($method['file']) && $method['file'] == 'includes/locale.inc') {
$method['file'] = 'core/modules/language/language.negotiation.inc';
}
unset($method['file']);
}
update_variable_set("language_negotiation_$language_type", $negotiation);
}
......@@ -525,9 +523,6 @@ function update_prepare_d8_language() {
db_drop_field('languages', 'native');
db_drop_field('languages', 'enabled');
// Update language count.
\Drupal::state()->set('language_count', db_query('SELECT COUNT(language) FROM {languages}')->fetchField());
// Rename the languages table to language.
db_rename_table('languages', 'language');
......@@ -556,7 +551,7 @@ function update_prepare_d8_language() {
db_add_field('language', 'locked', $locked_spec);
$max_language_weight = db_query('SELECT MAX(weight) FROM {language}')->fetchField();
$languages = language_default_locked_languages($max_language_weight);
$languages = \Drupal::languageManager()->getDefaultLockedLanguages($max_language_weight);
foreach ($languages as $language) {
db_insert('language')
->fields(array(
......@@ -1640,7 +1635,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) {
// Fill in master language list based on current configuration.
$default = language_default();
if (language_multilingual() || \Drupal::moduleHandler()->moduleExists('language')) {
if (\Drupal::languageManager()->isMultilingual() || \Drupal::moduleHandler()->moduleExists('language')) {
// Use language module configuration if available. We can not use
// entity_load_multiple() because this breaks during updates.
$language_entities = config_get_storage_names_with_prefix('language.entity.');
......@@ -1665,7 +1660,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) {
// No language module, so use the default language only.
$languages = array($default->id => $default);
// Add the special languages, they will be filtered later if needed.
$languages += language_default_locked_languages($default->weight);
$languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->weight);
}
}
......
......@@ -533,7 +533,7 @@ public static function translation() {
/**
* Returns the language manager service.
*
* @return \Drupal\Core\Language\LanguageManager
* @return \Drupal\Core\Language\LanguageManagerInterface
* The language manager.
*/
public static function languageManager() {
......
<?php
/**
* @file
* Contains \Drupal\Component\Utility\UserAgent.
*/
namespace Drupal\Component\Utility;
/**
* Provides user agent related utility functions.
*/
class UserAgent {
/**
* Identifies user agent language from the Accept-language HTTP header.
*
* The algorithm works as follows:
* - map user agent language codes to available language codes.
* - order all user agent language codes by qvalue from high to low.
* - add generic user agent language codes if they aren't already specified
* but with a slightly lower qvalue.
* - find the most specific available language code with the highest qvalue.
* - if 2 or more languages are having the same qvalue, respect the order of
* them inside the $languages array.
*
* We perform user agent accept-language parsing only if page cache is
* disabled, otherwise we would cache a user-specific preference.
*
* @param string $http_accept_language
* The value of the "Accept-Language" HTTP header.
* @param array $langcodes
* An array of available language codes to pick from.
* @param array $mappings
* (optional) Custom mappings to support user agents that are sending non
* standard language codes. No mapping is assumed by default.
*
* @return string
* The selected language code or FALSE if no valid language can be
* identified.
*/
public static function getBestMatchingLangcode($http_accept_language, $langcodes, $mappings = array()) {
// The Accept-Language header contains information about the language
// preferences configured in the user's user agent / operating system.
// RFC 2616 (section 14.4) defines the Accept-Language header as follows:
// Accept-Language = "Accept-Language" ":"
// 1#( language-range [ ";" "q" "=" qvalue ] )
// language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
// Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
$ua_langcodes = array();
if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($http_accept_language), $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if ($mappings) {
$langcode = strtolower($match[1]);
foreach ($mappings as $ua_langcode => $standard_langcode) {
if ($langcode == $ua_langcode) {
$match[1] = $standard_langcode;
}
}
}
// We can safely use strtolower() here, tags are ASCII.
// RFC2616 mandates that the decimal part is no more than three digits,
// so we multiply the qvalue by 1000 to avoid floating point
// comparisons.
$langcode = strtolower($match[1]);
$qvalue = isset($match[2]) ? (float) $match[2] : 1;
// Take the highest qvalue for this langcode. Although the request
// supposedly contains unique langcodes, our mapping possibly resolves
// to the same langcode for different qvalues. Keep the highest.
$ua_langcodes[$langcode] = max(
(int) ($qvalue * 1000),
(isset($ua_langcodes[$langcode]) ? $ua_langcodes[$langcode] : 0)
);
}
}
// We should take pristine values from the HTTP headers, but Internet
// Explorer from version 7 sends only specific language tags (eg. fr-CA)
// without the corresponding generic tag (fr) unless explicitly configured.
// In that case, we assume that the lowest value of the specific tags is the
// value of the generic language to be as close to the HTTP 1.1 spec as
// possible.
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 and
// http://blogs.msdn.com/b/ie/archive/2006/10/17/accept-language-header-for-internet-explorer-7.aspx
asort($ua_langcodes);
foreach ($ua_langcodes as $langcode => $qvalue) {
// For Chinese languages the generic tag is either zh-hans or zh-hant, so
// we need to handle this separately, we can not split $langcode on the
// first occurrence of '-' otherwise we get a non-existing language zh.
// All other languages use a langcode without a '-', so we can safely
// split on the first occurrence of it.
$generic_tag = '';
if (strlen($langcode) > 7 && (substr($langcode, 0, 7) == 'zh-hant' || substr($langcode, 0, 7) == 'zh-hans')) {
$generic_tag = substr($langcode, 0, 7);
}
else {
$generic_tag = strtok($langcode, '-');
}
if (!empty($generic_tag) && !isset($ua_langcodes[$generic_tag])) {
// Add the generic langcode, but make sure it has a lower qvalue as the
// more specific one, so the more specific one gets selected if it's
// defined by both the user agent and us.
$ua_langcodes[$generic_tag] = $qvalue - 0.1;
}
}
// Find the enabled language with the greatest qvalue, following the rules
// of RFC 2616 (section 14.4). If several languages have the same qvalue,
// prefer the one with the greatest weight.
$best_match_langcode = FALSE;
$max_qvalue = 0;
foreach ($langcodes as $langcode_case_sensitive) {
// Language tags are case insensitive (RFC2616, sec 3.10).
$langcode = strtolower($langcode_case_sensitive);
// If nothing matches below, the default qvalue is the one of the wildcard
// language, if set, or is 0 (which will never match).
$qvalue = isset($ua_langcodes['*']) ? $ua_langcodes['*'] : 0;
// Find the longest possible prefix of the user agent supplied language
// ('the language-range') that matches this site language ('the language
// tag').
$prefix = $langcode;
do {
if (isset($ua_langcodes[$prefix])) {
$qvalue = $ua_langcodes[$prefix];
break;
}
}
while ($prefix = substr($prefix, 0, strrpos($prefix, '-')));
// Find the best match.
if ($qvalue > $max_qvalue) {
$best_match_langcode = $langcode_case_sensitive;
$max_qvalue = $qvalue;
}
}
return $best_match_langcode;
}
}
......@@ -12,7 +12,7 @@
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
......@@ -37,7 +37,7 @@ class Date {
/**
* Language manager for retrieving the default langcode when none is specified.
*
* @var \Drupal\Core\Language\LanguageManager
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
......@@ -75,12 +75,14 @@ class Date {
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Language\LanguageManager $language_manager
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation
* The string translation.
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The configuration factory.
*/
public function __construct(EntityManagerInterface $entity_manager, LanguageManager $language_manager, TranslationInterface $translation, ConfigFactory $config_factory) {
public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, TranslationInterface $translation, ConfigFactory $config_factory) {
$this->dateFormatStorage = $entity_manager->getStorageController('date_format');
$this->languageManager = $language_manager;
$this->stringTranslation = $translation;
......@@ -128,7 +130,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N
}
if (empty($langcode)) {
$langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id;
$langcode = $this->languageManager->getCurrentLanguage()->id;
}
// Create a DrupalDateTime object from the timestamp and timezone.
......
......@@ -142,7 +142,7 @@ public function __construct(\Traversable $namespaces, ContainerInterface $contai
$this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
$this->discovery = new InfoHookDecorator($this->discovery, 'entity_info');
$this->discovery = new AlterDecorator($this->discovery, 'entity_info');
$this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
$this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getCurrentLanguage()->id, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
$this->factory = new DefaultFactory($this->discovery);
$this->container = $container;
}
......@@ -321,7 +321,7 @@ public function getAdminRouteInfo($entity_type, $bundle) {
public function getFieldDefinitions($entity_type, $bundle = NULL) {
if (!isset($this->entityFieldInfo[$entity_type])) {
// First, try to load from cache.
$cid = 'entity_field_definitions:' . $entity_type . ':' . $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id;
$cid = 'entity_field_definitions:' . $entity_type . ':' . $this->languageManager->getCurrentLanguage()->id;
if ($cache = $this->cache->get($cid)) {
$this->entityFieldInfo[$entity_type] = $cache->data;