FieldInfo
class FieldInfo
Provides field and instance definitions for the current runtime environment.
A FieldInfo object is created and statically persisted through the request by the _field_info_field_cache() function. The object properties act as a "static cache" of fields and instances definitions.
The preferred way to access definitions is through the getBundleInstances() method, which keeps cache entries per bundle, storing both fields and instances for a given bundle. Fields used in multiple bundles are duplicated in several cache entries, and are merged into a single list in the memory cache. Cache entries are loaded for bundles as a whole, optimizing memory and CPU usage for the most common pattern of iterating over all instances of a bundle rather than accessing a single instance.
The getFields() and getInstances() methods, which return all existing field and instance definitions, are kept mainly for backwards compatibility, and should be avoided when possible, since they load and persist in memory a potentially large array of information. In many cases, the lightweight getFieldMap() method should be preferred.
Hierarchy
- class \FieldInfo
Expanded class hierarchy of FieldInfo
File
- modules/field/field.info.class.inc, line 29
Members
Name | Modifiers | Type | Description |
---|---|---|---|
FieldInfo::$bundleExtraFields | protected | property | Extra fields by bundle. |
FieldInfo::$bundleInstances | protected | property | Instance definitions by bundle. |
FieldInfo::$emptyBundles | protected | property | Separately tracks requested bundles that are empty (or do not exist). |
FieldInfo::$fieldIdsByName | protected | property | Mapping of field names to the ID of the corresponding non-deleted field. |
FieldInfo::$fieldMap | protected | property | Lightweight map of fields across entity types and bundles. |
FieldInfo::$fieldsById | protected | property | List of $field structures keyed by ID. Includes deleted fields. |
FieldInfo::$loadedAllFields | protected | property | Whether $fieldsById contains all field definitions or a subset. |
FieldInfo::$loadedAllInstances | protected | property | Whether $bundleInstances contains all instances definitions or a subset. |
FieldInfo::$unknownFields | protected | property | Separately tracks requested field names or IDs that do not exist. |
FieldInfo::flush | public | function | Clears the "static" and persistent caches. |
FieldInfo::getBundleExtraFields | public | function | Retrieves the "extra fields" for a bundle. |
FieldInfo::getBundleInstances | public | function | Retrieves the instances for a bundle. |
FieldInfo::getField | public | function | Returns a field definition from a field name. |
FieldInfo::getFieldById | public | function | Returns a field definition from a field ID. |
FieldInfo::getFieldMap | public | function | Collects a lightweight map of fields across bundles. |
FieldInfo::getFields | public | function | Returns all active fields, including deleted ones. |
FieldInfo::getInstances | public | function | Retrieves all active, non-deleted instances definitions. |
FieldInfo::prepareExtraFields | public | function | Prepares 'extra fields' for the current run-time context. |
FieldInfo::prepareField | public | function | Prepares a field definition for the current run-time context. |
FieldInfo::prepareInstance | public | function | Prepares an instance definition for the current run-time context. |
FieldInfo::prepareInstanceDisplay | public | function | Adapts display specifications to the current run-time context. |
FieldInfo::prepareInstanceWidget | public | function | Prepares widget properties for the current run-time context. |
© 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/class/FieldInfo/7.x