_field_info_collate_fields

  1. drupal
    1. drupal7
Versionen
drupal7 _field_info_collate_fields($reset = FALSE)

Collate all information on existing fields and instances.

Übergabeparameter

$reset If TRUE, clear the cache. The information will be rebuilt from the database next time it is needed. Defaults to FALSE.

Rückgabewert

If $reset is TRUE, nothing. If $reset is FALSE, an array containing the following elements:

  • fields: array of all defined Field objects, keyed by field name. Each field has an additional element, bundles, which is an array of all bundles to which the field is assigned.
  • instances: array whose keys are bundle names and whose values are an array, keyed by field name, of all Instance objects in that bundle.

Verwandte Themen

▾ 5 functions call _field_info_collate_fields()

field_cache_clear in modules/field/field.module
Clear the cached information; called in several places when field information is changed.
_field_info_field in modules/field/field.info.inc
Return data about an individual field.
_field_info_fields in modules/field/field.info.inc
Return array of all field data, keyed by field name.
_field_info_instance in modules/field/field.info.inc
Return an array of instance data for a specific field and bundle.
_field_info_instances in modules/field/field.info.inc
Return an array of instance data for a given bundle, or for all known bundles, keyed by bundle name and field name.

Code

modules/field/field.info.inc, line 166

<?php
function _field_info_collate_fields($reset = FALSE) {
  static $info;

  if ($reset) {
    $info = NULL;
    cache_clear_all('field_info_fields', 'cache_field');
    return;
  }

  if (!isset($info)) {
    if ($cached = cache_get('field_info_fields', 'cache_field')) {
      $info = $cached->data;
    }
    else {
      $info = array(
        'fields' => field_read_fields(),
        'instances' => array_fill_keys(array_keys(field_info_bundles()), array()),
      );

      // Populate instances.
      $instances = field_read_instances();
      foreach ($instances as $instance) {
        $info['instances'][$instance['bundle']][$instance['field_name']] = $instance;
        $info['fields'][$instance['field_name']]['bundles'][] = $instance['bundle'];
      }

      cache_set('field_info_fields', $info, 'cache_field');
    }
  }

  return $info;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen