public function FieldInfo::getBundleExtraFields
7.x field.info.class.inc | public FieldInfo::getBundleExtraFields($entity_type, $bundle) |
Retrieves the "extra fields" for a bundle.
Parameters
$entity_type: The entity type.
$bundle: The bundle name.
Return value
The array of extra fields.
File
- drupal-7.x/
modules/ field/ field.info.class.inc, line 438
Class
- FieldInfo
- Provides field and instance definitions for the current runtime environment.
Code
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 = cache_get("field_info:bundle_extra:$entity_type:$bundle", 'cache_field')) {
$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 = module_invoke_all('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;
cache_set("field_info:bundle_extra:$entity_type:$bundle", $info, 'cache_field');
return $this->bundleExtraFields[$entity_type][$bundle];
}