public function WidgetPluginManager::prepareConfiguration

Merges default values for widget configuration.

Parameters

string $field_type: The field type.

array $configuration: An array of widget configuration.

Return value

array The display properties with defaults added.

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

File

drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php, line 115
Definition of Drupal\field\Plugin\Type\Widget\WidgetPluginManager.

Class

WidgetPluginManager
Plugin type manager for field widgets.

Namespace

Drupal\field\Plugin\Type\Widget

Code

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

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

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

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