function ListElement::setConfig

Same name and namespace in other branches
  1. 8.9.x core/modules/config_translation/src/FormElement/ListElement.php \Drupal\config_translation\FormElement\ListElement::setConfig()
  2. 10 core/modules/config_translation/src/FormElement/ListElement.php \Drupal\config_translation\FormElement\ListElement::setConfig()
  3. 11.x core/modules/config_translation/src/FormElement/ListElement.php \Drupal\config_translation\FormElement\ListElement::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

File

core/modules/config_translation/src/FormElement/ListElement.php, line 83

Class

ListElement
Defines the list element for the configuration translation interface.

Namespace

Drupal\config_translation\FormElement

Code

public function setConfig(Config $base_config, LanguageConfigOverride $config_translation, $config_values, $base_key = NULL) {
    foreach ($this->element as $key => $element) {
        $element_key = isset($base_key) ? "{$base_key}.{$key}" : $key;
        if ($form_element = ConfigTranslationFormBase::createFormElement($element)) {
            // Traverse into the next level of the configuration.
            $value = $config_values[$key] ?? NULL;
            $form_element->setConfig($base_config, $config_translation, $value, $element_key);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.