_field_info_collate_types

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

Collate all information on field types, widget types and related structures.

Ü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:

field types: array of hook_field_info() results, keyed by field_type.

  • label, description, settings, instance_settings, default_widget, default_formatter, behaviors: from hook_field_info()
  • module: the module that exposes the field type

widget types: array of hook_field_widget_info() results, keyed by widget_type.

  • label, field types, settings, behaviors: from hook_field_widget_info()
  • module: module that exposes the widget type

formatter types: array of hook_field_formatter_info() results, keyed by formatter_type.

fieldable types: array of hook_fieldable_info() results, keyed by entity_type.

  • name, id key, revision key, bundle key, cacheable, bundles: from hook_fieldable_info()
  • module: module that exposes the entity type

Verwandte Themen

▾ 7 functions call _field_info_collate_types()

field_cache_clear in modules/field/field.module
Clear the cached information; called in several places when field information is changed.
_field_info_bundles in modules/field/field.info.inc
Return an array of fieldable bundle names and labels, for an individual object type or for all object types.
_field_info_bundle_entity in modules/field/field.info.inc
Identity the type of entity that created a bundle. // TODO : might not be needed depending on how we solve // the 'namespace bundle names' issue
_field_info_fieldable_types in modules/field/field.info.inc
Return hook_fieldable_info() data.
_field_info_field_types in modules/field/field.info.inc
Return hook_field_info() data.
_field_info_formatter_types in modules/field/field.info.inc
Return hook_field_formatter_info() data.
_field_info_widget_types in modules/field/field.info.inc
Return hook_field_widget_info() data.

Code

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

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

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

  if (!isset($info)) {
    if ($cached = cache_get('field_info_types', 'cache_field')) {
      $info = $cached->data;
    }
    else {
      $info = array(
        'field types' => array(),
        'widget types' => array(),
        'formatter types' => array(),
        'fieldable types' => array(),
      );

      // Populate field types.
      foreach (module_implements('field_info') as $module) {
        $field_types = (array) module_invoke($module, 'field_info');
        foreach ($field_types as $name => $field_info) {
          $info['field types'][$name] = $field_info;
          $info['field types'][$name]['module'] = $module;
        }
      }

      // Populate widget types.
      foreach (module_implements('field_widget_info') as $module) {
        $widget_types = (array) module_invoke($module, 'field_widget_info');
        foreach ($widget_types as $name => $widget_info) {
          $info['widget types'][$name] = $widget_info;
          $info['widget types'][$name]['module'] = $module;
        }
      }

      // Populate formatters.
      foreach (module_implements('field_formatter_info') as $module) {
        $formatter_types = (array) module_invoke($module, 'field_formatter_info');
        foreach ($formatter_types as $name => $formatter_info) {
          $info['formatter types'][$name] = $formatter_info;
          $info['formatter types'][$name]['module'] = $module;
        }
      }

      // Populate information about 'fieldable' entities.
      foreach (module_implements('fieldable_info') as $module) {
        $fieldable_types = (array) module_invoke($module, 'fieldable_info');
        foreach ($fieldable_types as $name => $fieldable_info) {
          // Provide defaults.
          $fieldable_info += array(
            'revision key' => '',
            'bundle key' => '',
            'cacheable' => TRUE,
            'bundles' => array(),
          );
          // If no bundle key provided, then we assume a single bundle, named
          // after the type of the object. Make sure the bundle created
          // has the human-readable name we need for bundle messages.
          if (empty($fieldable_info['bundle key'])) {
            $fieldable_info['bundles'] = array($name => $fieldable_info['name']);
          }
          $info['fieldable types'][$name] = $fieldable_info;
          $info['fieldable types'][$name]['module'] = $module;
        }
      }

      cache_set('field_info_types', $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