You are here

function multifield_get_fields in Multifield 7

Same name and namespace in other branches
  1. 7.2 multifield.module \multifield_get_fields()

Get all multifield fields.

Return value

array An array of multifield types, keyed by the respective field name.

8 calls to multifield_get_fields()
MultifieldEntityController::queryLoad in ./MultifieldEntityController.php
MultifieldUnitTestCase::testDeprecatedField in tests/MultifieldUnitTestCase.test
MultifieldUnitTestCase::testMultifieldField in tests/MultifieldUnitTestCase.test
multifield_field_attach_submit in ./multifield.field.inc
Implements hook_field_attach_submit().
multifield_form_field_ui_field_overview_form_alter in ./multifield.module
Implements hook_form_FORM_ID_alter() for field_ui_field_overview_form().

... See full list

1 string reference to 'multifield_get_fields'
multifield_cache_clear in ./multifield.module

File

./multifield.module, line 204

Code

function multifield_get_fields() {
  $fields =& drupal_static(__FUNCTION__);
  if (!isset($fields)) {

    // @todo Is caching really necessary here? It's just one query.
    if ($cached = cache_get('field_info:multifields', 'cache_field')) {
      $fields = $cached->data;
    }
    else {

      // This query is based from FieldInfo::getFieldMap().
      $fields = db_query("SELECT fc.field_name, fc.type FROM {field_config} fc WHERE fc.active = 1 AND fc.storage_active = 1 AND fc.deleted = 0 AND fc.module = 'multifield'")
        ->fetchAllKeyed();
      foreach ($fields as $field_name => $field_type) {
        if ($field_type == 'multifield') {
          $fields[$field_name] = $field_name;
        }
      }
      cache_set('field_info:multifields', $fields, 'cache_field');
    }
  }
  return $fields;
}