function field_read_instances

Reads in field instances that match an array of conditions.

Parameters

$param: An array of properties to use in selecting a field instance. Keys are names of properties found in field instance configuration files, and values are conditions to match.

$include_additional: The default behavior of this function is to not return field instances that have been marked deleted, or whose field is inactive. Setting $include_additional['include_inactive'] or $include_additional['include_deleted'] to TRUE will override this behavior.

Return value

An array of instances matching the arguments.

Related topics

12 calls to field_read_instances()
BulkDeleteTest::testDeleteFieldInstance in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that deleting an instance leaves the field data items in the database and that the appropriate Field API functions can operate on the deleted data and instance.
BulkDeleteTest::testPurgeInstance in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that field data items and instances are purged when an instance is deleted.
FieldInfo::getInstances in drupal/core/modules/field/lib/Drupal/field/FieldInfo.php
Retrieves all active, non-deleted instances definitions.
field_entity_bundle_delete in drupal/core/modules/field/field.attach.inc
Implements hook_entity_bundle_delete().
field_entity_bundle_rename in drupal/core/modules/field/field.attach.inc
Implements hook_entity_bundle_rename().

... See full list

File

drupal/core/modules/field/field.crud.inc, line 304
Field CRUD API, handling field and field instance creation and deletion.

Code

function field_read_instances($conditions = array(), $include_additional = array()) {

  // Include instances of inactive fields if specified in the
  // $include_additional parameter.
  $include_inactive = isset($include_additional['include_inactive']) && $include_additional['include_inactive'];

  // Include deleted instances if specified either in the $include_additional
  // or the $conditions parameters.
  $include_deleted = isset($include_additional['include_deleted']) && $include_additional['include_deleted'] || isset($conditions['deleted']) && $conditions['deleted'];

  // Pass include_inactive and include_deleted to the $conditions array.
  $conditions['include_inactive'] = $include_inactive;
  $conditions['include_deleted'] = $include_deleted;
  return entity_load_multiple_by_properties('field_instance', $conditions);
}