public function FieldInfo::prepareExtraFields

Prepares 'extra fields' for the current run-time context.

Parameters

$extra_fields: The array of extra fields, as collected in hook_field_extra_fields().

$entity_type: The entity type.

$bundle: The bundle name.

Return value

The list of extra fields completed for the current runtime context.

1 call to FieldInfo::prepareExtraFields()
FieldInfo::getBundleExtraFields in drupal/core/modules/field/lib/Drupal/field/FieldInfo.php
Retrieves the "extra fields" for a bundle.

File

drupal/core/modules/field/lib/Drupal/field/FieldInfo.php, line 577
Contains \Drupal\field\FieldInfo.

Class

FieldInfo
Provides field and instance definitions for the current runtime environment.

Namespace

Drupal\field

Code

public function prepareExtraFields($extra_fields, $entity_type, $bundle) {
  $entity_type_info = entity_get_info($entity_type);
  $bundle_settings = field_bundle_settings($entity_type, $bundle);
  $extra_fields += array(
    'form' => array(),
    'display' => array(),
  );
  $result = array();

  // Extra fields in forms.
  foreach ($extra_fields['form'] as $name => $field_data) {
    $settings = isset($bundle_settings['extra_fields']['form'][$name]) ? $bundle_settings['extra_fields']['form'][$name] : array();
    if (isset($settings['weight'])) {
      $field_data['weight'] = $settings['weight'];
    }
    $result['form'][$name] = $field_data;
  }

  // Extra fields in displayed entities.
  $result['display'] = $extra_fields['display'];
  return $result;
}