function ListElement::getTranslationBuild

Same name in other branches
  1. 9 core/modules/config_translation/src/FormElement/ListElement.php \Drupal\config_translation\FormElement\ListElement::getTranslationBuild()
  2. 8.9.x core/modules/config_translation/src/FormElement/ListElement.php \Drupal\config_translation\FormElement\ListElement::getTranslationBuild()
  3. 11.x core/modules/config_translation/src/FormElement/ListElement.php \Drupal\config_translation\FormElement\ListElement::getTranslationBuild()

Overrides ElementInterface::getTranslationBuild

File

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

Class

ListElement
Defines the list element for the configuration translation interface.

Namespace

Drupal\config_translation\FormElement

Code

public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL) {
    $build = [];
    foreach ($this->element as $key => $element) {
        $sub_build = [];
        $element_key = isset($base_key) ? "{$base_key}.{$key}" : $key;
        $definition = $element->getDataDefinition();
        if ($form_element = ConfigTranslationFormBase::createFormElement($element)) {
            $element_parents = array_merge($parents, [
                $key,
            ]);
            $sub_build += $form_element->getTranslationBuild($source_language, $translation_language, $source_config[$key], $translation_config[$key], $element_parents, $element_key);
            if (empty($sub_build)) {
                continue;
            }
            // Build the sub-structure and include it with a wrapper in the form if
            // there are any translatable elements there.
            $build[$key] = [];
            if ($element instanceof TraversableTypedDataInterface) {
                $build[$key] = [
                    '#type' => 'details',
                    '#title' => $this->getGroupTitle($definition, $sub_build),
                    '#open' => empty($base_key),
                ];
            }
            $build[$key] += $sub_build;
        }
    }
    return $build;
}

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