Skip to content
Snippets Groups Projects

Draft: EntityTypeBundleInfo returns wrong language

@@ -85,34 +85,36 @@ public function getBundleInfo($entity_type_id) {
* {@inheritdoc}
*/
public function getAllBundleInfo() {
if (empty($this->bundleInfo)) {
$langcode = $this->languageManager->getCurrentLanguage()->getId();
$langcode = $this->languageManager->getConfigOverrideLanguage()?->getId()
?? $this->languageManager->getCurrentLanguage()->getId();
// @fixme Replace self::bundleInfo with a proper memory cache backend.
if (!isset($this->bundleInfo[$langcode])) {
if ($cache = $this->cacheGet("entity_bundle_info:$langcode")) {
$this->bundleInfo = $cache->data;
$this->bundleInfo[$langcode] = $cache->data;
}
else {
$this->bundleInfo = $this->moduleHandler->invokeAll('entity_bundle_info');
$this->bundleInfo[$langcode] = $this->moduleHandler->invokeAll('entity_bundle_info');
foreach ($this->entityTypeManager->getDefinitions() as $type => $entity_type) {
// First look for entity types that act as bundles for others, load them
// and add them as bundles.
if ($bundle_entity_type = $entity_type->getBundleEntityType()) {
foreach ($this->entityTypeManager->getStorage($bundle_entity_type)->loadMultiple() as $entity) {
$this->bundleInfo[$type][$entity->id()]['label'] = $entity->label();
$this->bundleInfo[$langcode][$type][$entity->id()]['label'] = $entity->label();
}
}
// If entity type bundles are not supported and
// hook_entity_bundle_info() has not already set up bundle
// information, use the entity type name and label.
elseif (!isset($this->bundleInfo[$type])) {
$this->bundleInfo[$type][$type]['label'] = $entity_type->getLabel();
elseif (!isset($this->bundleInfo[$langcode][$type])) {
$this->bundleInfo[$langcode][$type][$type]['label'] = $entity_type->getLabel();
}
}
$this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo);
$this->cacheSet("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, ['entity_types', 'entity_bundles']);
$this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo[$langcode]);
$this->cacheSet("entity_bundle_info:$langcode", $this->bundleInfo[$langcode], Cache::PERMANENT, ['entity_types', 'entity_bundles']);
}
}
return $this->bundleInfo;
return $this->bundleInfo[$langcode];
}
/**
Loading