_field_invoke_get_instances
function _field_invoke_get_instances
_field_invoke_get_instances($entity_type, $bundle, $options)
Helper for _field_invoke(): retrieves a list of instances to operate on.
Parameters
$entity_type: The entity type.
$bundle: The bundle name.
$options: An associative array of options, as provided to _field_invoke(). Only the following keys are considered :
- deleted
- field_name
- field_id
See _field_invoke() for details.
Return value
The array of selected instance definitions.
Related topics
File
- modules/field/field.attach.inc, line 420
- Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'.
Code
function _field_invoke_get_instances($entity_type, $bundle, $options) { if ($options['deleted']) { // Deleted fields are not included in field_info_instances(), and need to // be fetched from the database with field_read_instances(). $params = array('entity_type' => $entity_type, 'bundle' => $bundle); if (isset($options['field_id'])) { // Single-field mode by field id: field_read_instances() does the filtering. // Single-field mode by field name is not compatible with the 'deleted' // option. $params['field_id'] = $options['field_id']; } $instances = field_read_instances($params, array('include_deleted' => TRUE)); } elseif (isset($options['field_name'])) { // Single-field mode by field name: field_info_instance() does the // filtering. $instances = array(field_info_instance($entity_type, $options['field_name'], $bundle)); } else { $instances = field_info_instances($entity_type, $bundle); if (isset($options['field_id'])) { // Single-field mode by field id: we need to loop on each instance to // find the right one. foreach ($instances as $instance) { if ($instance['field_id'] == $options['field_id']) { $instances = array($instance); break; } } } } return $instances; }
© 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.attach.inc/function/_field_invoke_get_instances/7.x