function field_read_fields

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 field.crud.inc field_read_fields($params = array(), $include_additional = array())
cle7 field.crud.inc field_read_fields($params = array(), $include_additional = array())
elmsmedia7 field.crud.inc field_read_fields($params = array(), $include_additional = array())
icor7 field.crud.inc field_read_fields($params = array(), $include_additional = array())
meedjum_blog7 field.crud.inc field_read_fields($params = array(), $include_additional = array())
mooc7 field.crud.inc field_read_fields($params = array(), $include_additional = array())

Reads in fields that match an array of conditions.

Parameters

array $params: An array of conditions to match against. Keys are columns from the 'field_config' table, values are conditions to match. Additionally, conditions on the 'entity_type' and 'bundle' columns from the 'field_config_instance' table are supported (select fields having an instance on a given bundle).

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

17 calls to field_read_fields()
FieldInfo::getBundleInstances in modules/field/field.info.class.inc
Retrieves the instances for a bundle.
FieldInfo::getFieldById in modules/field/field.info.class.inc
Returns a field definition from a field ID.
FieldInfo::getFields in modules/field/field.info.class.inc
Returns all active fields, including deleted ones.
field_collection_entity_info in sites/all/modules/ulmus/field_collection/field_collection.module
Implements hook_entity_info().
field_collection_update_7001 in sites/all/modules/ulmus/field_collection/field_collection.install
Add revision support.

... See full list

File

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

Code

function field_read_fields($params = array(), $include_additional = array()) {
  $query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC));
  $query->fields('fc');

  // Turn the conditions into a query.
  foreach ($params as $key => $value) {
    // Allow filtering on the 'entity_type' and 'bundle' columns of the
    // field_config_instance table.
    if ($key == 'entity_type' || $key == 'bundle') {
      if (empty($fci_join)) {
        $fci_join = $query->join('field_config_instance', 'fci', 'fc.id = fci.field_id');
      }
      $key = 'fci.' . $key;
    }
    else {
      $key = 'fc.' . $key;
    }

    $query->condition($key, $value);
  }

  if (!isset($include_additional['include_inactive']) || !$include_additional['include_inactive']) {
    $query->condition('fc.active', 1)->condition('fc.storage_active', 1);
  }
  $include_deleted = (isset($include_additional['include_deleted']) && $include_additional['include_deleted']);
  if (!$include_deleted) {
    $query->condition('fc.deleted', 0);
  }

  $fields = array();
  $results = $query->execute();
  foreach ($results as $record) {
    $field = unserialize($record['data']);
    $field['id'] = $record['id'];
    $field['field_name'] = $record['field_name'];
    $field['type'] = $record['type'];
    $field['module'] = $record['module'];
    $field['active'] = $record['active'];
    $field['storage']['type'] = $record['storage_type'];
    $field['storage']['module'] = $record['storage_module'];
    $field['storage']['active'] = $record['storage_active'];
    $field['locked'] = $record['locked'];
    $field['cardinality'] = $record['cardinality'];
    $field['translatable'] = $record['translatable'];
    $field['deleted'] = $record['deleted'];

    module_invoke_all('field_read_field', $field);

    // Populate storage information.
    module_load_install($field['module']);
    $schema = (array) module_invoke($field['module'], 'field_schema', $field);
    $schema += array(
      'columns' => array(),
      'indexes' => array(),
    );
    $field['columns'] = $schema['columns'];

    $field_name = $field['field_name'];
    if ($include_deleted) {
      $field_name = $field['id'];
    }
    $fields[$field_name] = $field;
  }
  return $fields;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.