function _field_invoke_get_instances
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
3 calls to _field_invoke_get_instances()
- field_attach_load in modules/
field/ field.attach.inc - Loads fields for the current revisions of a group of entities.
- _field_invoke in modules/
field/ field.attach.inc - Invoke a field hook.
- _field_invoke_multiple in modules/
field/ field.attach.inc - Invoke a field hook across fields on multiple entities.
File
-
modules/
field/ field.attach.inc, line 420
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.