Prepares 'extra fields' for the current run-time context.
$extra_fields: The array of extra fields, as collected in hook_field_extra_fields().
$entity_type: The entity type.
$bundle: The bundle name.
The list of extra fields completed for the current runtime context.
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;
}