You are here

public static function DoubleField::fieldSettingsToConfigData 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::fieldSettingsToConfigData()

Returns a settings array that can be stored as a configuration value.

Same as static::storageSettingsToConfigData(), but for the field's settings.

Parameters

array $settings: The field's settings in the field type's canonical representation.

Return value

array An array (either the unmodified $settings or a modified representation) that is suitable for storing as a deployable configuration value.

Overrides FieldItemBase::fieldSettingsToConfigData

See also

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

File

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

Class

DoubleField
Plugin implementation of the 'double_field' field type.

Namespace

Drupal\double_field\Plugin\Field\FieldType

Code

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