public ListElement::getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL)
Builds a render array containg the source and translation form elements.
Parameters
\Drupal\Core\Language\LanguageInterface $source_language: The source language of the configuration object.
\Drupal\Core\Language\LanguageInterface $translation_language: The language to display the translation form for.
mixed $source_config: The configuration value of the element in the source language.
mixed $translation_config: The configuration value of the element in the language to translate to.
array $parents: Parents array for the element in the form.
string|null $base_key: (optional) Base key to be used for the elements in the form. NULL for top-level form elements.
Return value
array A render array consisting of the source and translation elements for the source value.
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 = array(); foreach ($this->element as $key => $element) { $sub_build = array(); $element_key = isset($base_key) ? "$base_key.$key" : $key; $definition = $element->getDataDefinition(); if ($form_element = ConfigTranslationFormBase::createFormElement($element)) { $element_parents = array_merge($parents, array($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] = array(); if ($element instanceof TraversableTypedDataInterface) { $build[$key] = array( '#type' => 'details', '#title' => $this->getGroupTitle($definition, $sub_build), '#open' => empty($base_key), ); } $build[$key] += $sub_build; } } return $build; }
Please login to continue.