1 field.module field_get_block_list()

Helper function to build a list of fields that have been made available as a block.

Return value

array: An array with all entity fields with known instances.

File

core/modules/field/field.module, line 1359
Attach custom data fields to Backdrop entities.

Code

function field_get_block_list() {
  $types = &backdrop_static(__FUNCTION__, array());
  if (!empty($types)) {
    return $types;
  }

  $cache_key = 'field_block_list';
  if ($cache = cache_get($cache_key)) {
    $types = $cache->data;
    if (!empty($types)) {
      return $types;
    }
  }

  // This will hold all the individual field content types.
  $all_entity_info = entity_get_info();
  $all_fields = array();
  foreach ($all_entity_info as $entity_type => $entity_info) {
    $description = t('Field from the available @type content.', array('@type' => backdrop_strtolower($entity_info['label'])));
    foreach ($entity_info['bundles'] as $type => $bundle) {
      foreach (field_info_instances($entity_type, $type) as $field_name => $field) {
        // Build an array of fields to run through entity_blocks_fields_get_field_formatter_info()
        // to get formatters.
        $field_info = field_info_field($field_name);
        $all_fields[$field_name] = $field_info;
        if (!isset($types[$entity_type . '-' . $field_name])) {
          $label = t($field['label']);
          $types[$entity_type . '-' . $field_name] = array(
            'info' => t('Field: @widget_label (@field_name)', array('@widget_label' => $label, '@field_name' => $field_name)),
            'description' => $description,
            'required contexts' => array($entity_type => $entity_type),
          );
        }
      }
    }
  }

  cache_set($cache_key, $types);

  return $types;
}