You are here

public static function FieldItemBase::storageSettingsToConfigData in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::storageSettingsToConfigData()

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

For all use cases where field settings are stored and managed as configuration, this method is used to map from the field type's representation of its settings to a representation compatible with deployable configuration. This includes:

  • Array keys at any depth must not contain a ".".
  • Ideally, array keys at any depth are either numeric or can be enumerated as a "mapping" within the configuration schema. While not strictly required, this simplifies configuration translation UIs, configuration migrations between Drupal versions, and other use cases.
  • To support configuration deployments, references to content entities must use UUIDs rather than local IDs.

An example of a conversion between representations might be an "allowed_values" setting that's structured by the field type as a \Drupal\Core\TypedData\OptionsProviderInterface::getPossibleOptions() result (i.e., values as keys and labels as values). For such a use case, in order to comply with the above, this method could convert that representation to a numerically indexed array whose values are sub-arrays with the schema definable keys of "value" and "label".

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 FieldItemInterface::storageSettingsToConfigData

See also

\Drupal\Core\Config\Config::set()

2 methods override FieldItemBase::storageSettingsToConfigData()
ListItemBase::storageSettingsToConfigData in core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
Returns a settings array that can be stored as a configuration value.
TestItem::storageSettingsToConfigData in core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php
Returns a settings array that can be stored as a configuration value.

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 233

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

public static function storageSettingsToConfigData(array $settings) {
  return $settings;
}