Retrieves the "extra fields" for a bundle.
$entity_type: The entity type.
$bundle: The bundle name.
The array of extra fields.
public function getBundleExtraFields($entity_type, $bundle) {
// Read from the "static" cache.
if (isset($this->bundleExtraFields[$entity_type][$bundle])) {
return $this->bundleExtraFields[$entity_type][$bundle];
}
// Read from the persistent cache.
if ($cached = $this->cacheBackend
->get("field_info:bundle_extra:{$entity_type}:{$bundle}")) {
$this->bundleExtraFields[$entity_type][$bundle] = $cached->data;
return $this->bundleExtraFields[$entity_type][$bundle];
}
// Cache miss: read from hook_field_extra_fields(). Note: given the current
// shape of the hook, we have no other way than collecting extra fields on
// all bundles.
$info = array();
$extra = $this->moduleHandler
->invokeAll('field_extra_fields');
drupal_alter('field_extra_fields', $extra);
// Merge in saved settings.
if (isset($extra[$entity_type][$bundle])) {
$info = $this
->prepareExtraFields($extra[$entity_type][$bundle], $entity_type, $bundle);
}
// Store in the 'static' and persistent caches.
$this->bundleExtraFields[$entity_type][$bundle] = $info;
$this->cacheBackend
->set("field_info:bundle_extra:{$entity_type}:{$bundle}", $info, CacheBackendInterface::CACHE_PERMANENT, array(
'field_info' => TRUE,
));
return $this->bundleExtraFields[$entity_type][$bundle];
}