public function EntityFieldManager::getExtraFields in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/EntityFieldManager.php \Drupal\Core\Entity\EntityFieldManager::getExtraFields()
- 9 core/lib/Drupal/Core/Entity/EntityFieldManager.php \Drupal\Core\Entity\EntityFieldManager::getExtraFields()
File
- core/
lib/ Drupal/ Core/ Entity/ EntityFieldManager.php, line 640
Class
- EntityFieldManager
- Manages the discovery of entity fields.
Namespace
Drupal\Core\EntityCode
public function getExtraFields($entity_type_id, $bundle) {
// Read from the "static" cache.
if (isset($this->extraFields[$entity_type_id][$bundle])) {
return $this->extraFields[$entity_type_id][$bundle];
}
// Read from the persistent cache. Since hook_entity_extra_field_info() and
// hook_entity_extra_field_info_alter() might contain t() calls, we cache
// per language.
$cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager
->getCurrentLanguage()
->getId();
$cached = $this
->cacheGet($cache_id);
if ($cached) {
$this->extraFields[$entity_type_id][$bundle] = $cached->data;
return $this->extraFields[$entity_type_id][$bundle];
}
$extra = $this->moduleHandler
->invokeAll('entity_extra_field_info');
$this->moduleHandler
->alter('entity_extra_field_info', $extra);
$info = $extra[$entity_type_id][$bundle] ?? [];
$info += [
'form' => [],
'display' => [],
];
// Store in the 'static' and persistent caches.
$this->extraFields[$entity_type_id][$bundle] = $info;
$this
->cacheSet($cache_id, $info, Cache::PERMANENT, [
'entity_field_info',
]);
return $this->extraFields[$entity_type_id][$bundle];
}