public function FormatterPluginManager::prepareConfiguration

Merges default values for formatter configuration.

Parameters

string $field_type: The field type.

array $properties: An array of formatter configuration.

Return value

array The display properties with defaults added.

1 call to FormatterPluginManager::prepareConfiguration()
FormatterPluginManager::getInstance in drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php
Overrides PluginManagerBase::getInstance().

File

drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php, line 117
Definition of Drupal\field\Plugin\Type\Formatter\FormatterPluginManager..

Class

FormatterPluginManager
Plugin type manager for field formatters.

Namespace

Drupal\field\Plugin\Type\Formatter

Code

public function prepareConfiguration($field_type, array $configuration) {

  // Fill in defaults for missing properties.
  $configuration += array(
    'label' => 'above',
    'settings' => array(),
  );

  // If no formatter is specified, use the default formatter.
  if (!isset($configuration['type'])) {
    $field_type = field_info_field_types($field_type);
    $configuration['type'] = $field_type['default_formatter'];
  }

  // Fill in default settings values for the formatter.
  $configuration['settings'] += field_info_formatter_settings($configuration['type']);
  return $configuration;
}