Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. WidgetPluginManager.php

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 core/lib/Drupal/Core/Field/WidgetPluginManager.php
Overrides PluginManagerBase::getInstance().

File

core/lib/Drupal/Core/Field/WidgetPluginManager.php, line 140

Class

WidgetPluginManager
Plugin type manager for field widgets.

Namespace

Drupal\Core\Field

Code

public function prepareConfiguration($field_type, array $configuration) {
    // Fill in defaults for missing properties.
    $configuration += [
        'settings' => [],
        'third_party_settings' => [],
    ];
    // If no widget is specified, use the default widget.
    if (!isset($configuration['type'])) {
        $field_type = $this->fieldTypeManager
            ->getDefinition($field_type);
        $configuration['type'] = $field_type['default_widget'] ?? NULL;
    }
    // Filter out unknown settings, and fill in defaults for missing settings.
    $default_settings = $this->getDefaultSettings($configuration['type']);
    $configuration['settings'] = array_intersect_key($configuration['settings'], $default_settings) + $default_settings;
    return $configuration;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal