FieldInfo::getFieldById
public function FieldInfo::getFieldById
public FieldInfo::getFieldById($field_id)
Returns a field definition from a field ID.
This method only retrieves active fields, deleted or not.
Parameters
$field_id: The field ID.
Return value
The field definition, or NULL if no field was found.
File
- modules/field/field.info.class.inc, line 306
Class
- FieldInfo
- Provides field and instance definitions for the current runtime environment.
Code
public function getFieldById($field_id) { // Read from the "static" cache. if (isset($this->fieldsById[$field_id])) { return $this->fieldsById[$field_id]; } if (isset($this->unknownFields[$field_id])) { return; } // No persistent cache, fields are only persistently cached as part of a // bundle. // Cache miss: read from definition. if ($fields = field_read_fields(array('id' => $field_id), array('include_deleted' => TRUE))) { $field = current($fields); $field = $this->prepareField($field); // Store in the static cache. $this->fieldsById[$field['id']] = $field; if (!$field['deleted']) { $this->fieldIdsByName[$field['field_name']] = $field['id']; } return $field; } else { $this->unknownFields[$field_id] = TRUE; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.info.class.inc/function/FieldInfo::getFieldById/7.x