You are here

public static function DoubleField::fieldSettingsFromConfigData in Double Field 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldType/DoubleField.php \Drupal\double_field\Plugin\Field\FieldType\DoubleField::fieldSettingsFromConfigData()

Returns a settings array in the field type's canonical representation.

This function does the inverse of static::fieldSettingsToConfigData(). It's called when loading a field's settings from a configuration object.

Parameters

array $settings: The field's settings, as it is stored within a configuration object.

Return value

array The field settings, in the representation expected by the field type and code that interacts with it.

Overrides FieldItemBase::fieldSettingsFromConfigData

See also

\Drupal\Core\Field\FieldItemInterface::fieldSettingsToConfigData()

File

src/Plugin/Field/FieldType/DoubleField.php, line 613

Class

DoubleField
Plugin implementation of the 'double_field' field type.

Namespace

Drupal\double_field\Plugin\Field\FieldType

Code

public static function fieldSettingsFromConfigData(array $settings) : array {
  foreach ([
    'first',
    'second',
  ] as $subfield) {
    $structured_values = [];
    foreach ($settings[$subfield]['allowed_values'] as $item) {
      $structured_values[$item['value']] = $item['label'];
    }
    $settings[$subfield]['allowed_values'] = $structured_values;
  }
  return $settings;
}