You are here

public function FormElementBase::setConfig in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/config_translation/src/FormElement/FormElementBase.php \Drupal\config_translation\FormElement\FormElementBase::setConfig()
  2. 9 core/modules/config_translation/src/FormElement/FormElementBase.php \Drupal\config_translation\FormElement\FormElementBase::setConfig()

Sets configuration based on a nested form value array.

If the configuration values are the same as the source configuration, the override should be removed from the translation configuration.

Parameters

\Drupal\Core\Config\Config $base_config: Base configuration values, in the source language.

\Drupal\language\Config\LanguageConfigOverride $config_translation: Translation configuration override data.

mixed $config_values: The configuration value of the element taken from the form values.

string|null $base_key: (optional) The base key that the schema and the configuration values belong to. This should be NULL for the top-level configuration object and be populated consecutively when recursing into the configuration structure.

Overrides ElementInterface::setConfig

1 method overrides FormElementBase::setConfig()
PluralVariants::setConfig in core/modules/config_translation/src/FormElement/PluralVariants.php
Sets configuration based on a nested form value array.

File

core/modules/config_translation/src/FormElement/FormElementBase.php, line 174

Class

FormElementBase
Provides a common base class for form elements.

Namespace

Drupal\config_translation\FormElement

Code

public function setConfig(Config $base_config, LanguageConfigOverride $config_translation, $config_values, $base_key = NULL) {

  // Save the configuration values, if they are different from the source
  // values in the base configuration. Otherwise remove the override.
  if ($base_config
    ->get($base_key) !== $config_values) {
    $config_translation
      ->set($base_key, $config_values);
  }
  else {
    $config_translation
      ->clear($base_key);
  }
}