FieldInfo::getField
public function FieldInfo::getField
public FieldInfo::getField($field_name)
Returns a field definition from a field name.
This method only retrieves active, non-deleted fields.
Parameters
$field_name: The field name.
Return value
The field definition, or NULL if no field was found.
File
- modules/field/field.info.class.inc, line 268
Class
- FieldInfo
- Provides field and instance definitions for the current runtime environment.
Code
public function getField($field_name) { // Read from the "static" cache. if (isset($this->fieldIdsByName[$field_name])) { $field_id = $this->fieldIdsByName[$field_name]; return $this->fieldsById[$field_id]; } if (isset($this->unknownFields[$field_name])) { return; } // Do not check the (large) persistent cache, but read the definition. // Cache miss: read from definition. if ($field = field_read_field($field_name)) { $field = $this->prepareField($field); // Save in the "static" cache. $this->fieldsById[$field['id']] = $field; $this->fieldIdsByName[$field['field_name']] = $field['id']; return $field; } else { $this->unknownFields[$field_name] = 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::getField/7.x