欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

function field_info_fields

7.x field.info.incfield_info_fields()

Returns all field definitions.

Use of this function should be avoided when possible, since it loads and statically caches a potentially large array of information. Use field_info_field_map() instead.

When iterating over the fields present in a given bundle after a call tofield_info_instances($entity_type, $bundle), it is recommended to use field_info_field() on each individual field instead.

Return value

An array of field definitions, keyed by field name. Each field has an additional property, 'bundles', which is an array of all the bundles to which this field belongs keyed by entity type.

See also

field_info_field_map()

Related topics

3 calls to field_info_fields()

File


  • modules/

    field/

    field.info.inc, line 491

  • Field Info API, providing information about available fields and field types.


Code

function field_info_fields() {  $cache = _field_info_field_cache();  $info = $cache->getFields();  $fields = array();  foreach ($info as $key => $field) {    if (!$field['deleted']) {      $fields[$field['field_name']] = $field;
    }
  }  return $fields;
}

Comments

qqboy’s picture

good code

alberto56’s picture

I've successfully used \Drupal::entityManager()->getFieldMap() in Drupal 8.

Arne Slabbinck’s picture

Nice thx!

impol’s picture

entityManager is deprecated, use entityTypeManager instead

sinn’s picture

Would be better use \Drupal::service('entity_field.manager')->getFieldMap();

来自 https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_fields/7.x

普通分类: