function field_read_fields

Reads in fields that match an array of conditions.

Parameters

array $conditions: An array of conditions to match against. Keys are names of properties found in field configuration files, and values are conditions to match.

array $include_additional: The default behavior of this function is to not return fields that are inactive or have been deleted. Setting $include_additional['include_inactive'] or $include_additional['include_deleted'] to TRUE will override this behavior.

Return value

An array of fields matching $params. If $include_additional['include_deleted'] is TRUE, the array is keyed by field ID, otherwise it is keyed by field name.

Related topics

12 calls to field_read_fields()
ActiveTest::_testActiveHelper in drupal/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php
Helper function for testActive().
BulkDeleteTest::testPurgeField in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that fields are preserved and purged correctly as multiple instances are deleted and purged.
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.
CrudTest::testReadFields in drupal/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
Tests reading field definitions.
FieldInfo::getFieldById in drupal/core/modules/field/lib/Drupal/field/FieldInfo.php
Returns a field definition from a field ID.

... See full list

File

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

Code

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

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

  // Include deleted fields 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_entity', $conditions);
}