public function FieldInfo::getFields
7.x field.info.class.inc | public FieldInfo::getFields() |
Returns all active fields, including deleted ones.
Return value
An array of field definitions, keyed by field ID.
1 call to FieldInfo::getFields()
- FieldInfo::getInstances in drupal-7.x/
modules/ field/ field.info.class.inc - Retrieves all active, non-deleted instances definitions.
File
- drupal-7.x/
modules/ field/ field.info.class.inc, line 160
Class
- FieldInfo
- Provides field and instance definitions for the current runtime environment.
Code
public function getFields() {
// Read from the "static" cache.
if ($this->loadedAllFields) {
return $this->fieldsById;
}
// Read from persistent cache.
if ($cached = cache_get('field_info:fields', 'cache_field')) {
$this->fieldsById = $cached->data;
}
else {
// Collect and prepare fields.
foreach (field_read_fields(array(), array('include_deleted' => TRUE)) as $field) {
$this->fieldsById[$field['id']] = $this->prepareField($field);
}
// Store in persistent cache.
cache_set('field_info:fields', $this->fieldsById, 'cache_field');
}
// Fill the name/ID map.
foreach ($this->fieldsById as $field) {
if (!$field['deleted']) {
$this->fieldIdsByName[$field['field_name']] = $field['id'];
}
}
$this->loadedAllFields = TRUE;
return $this->fieldsById;
}