function EntityFieldManager::loadExtraFields

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/EntityFieldManager.php \Drupal\Core\Entity\EntityFieldManager::loadExtraFields()

Loads extra fields from cache, or rebuilds them.

Return value

array[][][][] Extra fields by entity type, bundle name, type (form/display) and extra field name.

1 call to EntityFieldManager::loadExtraFields()
EntityFieldManager::getExtraFields in core/lib/Drupal/Core/Entity/EntityFieldManager.php
Gets the "extra fields" for a bundle.

File

core/lib/Drupal/Core/Entity/EntityFieldManager.php, line 666

Class

EntityFieldManager
Manages the discovery of entity fields.

Namespace

Drupal\Core\Entity

Code

protected function loadExtraFields() : array {
  // 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_extra_field_info:' . $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  $cached = $this->cacheGet($cache_id);
  if ($cached) {
    return $cached->data;
  }
  $extra = $this->moduleHandler
    ->invokeAll('entity_extra_field_info');
  $this->moduleHandler
    ->alter('entity_extra_field_info', $extra);
  // Apply default values to each bundle.
  foreach ($extra as $entity_type_id => $extra_fields_by_bundle) {
    foreach ($extra_fields_by_bundle as $bundle => $bundle_extra_fields) {
      $extra[$entity_type_id][$bundle] += [
        'form' => [],
        'display' => [],
      ];
    }
  }
  $this->cacheSet($cache_id, $extra, Cache::PERMANENT, [
    'entity_field_info',
  ]);
  return $extra;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.