You are here

protected function WebformTranslationConfigManager::buildConfigWebformFormCompositePropertyElement in Webform 6.x

Build config webform form composite property element.

Parameters

array $element: The Webform element.

array $translation_element: The Webform element's translated properties.

array $source_element: The Webform element's source properties.

array $parents: The Webform element's parents.

Return value

array A render array containing config webform form composite property element.

1 call to WebformTranslationConfigManager::buildConfigWebformFormCompositePropertyElement()
WebformTranslationConfigManager::buildConfigWebformFormElements in src/WebformTranslationConfigManager.php
Build config webform form elements.

File

src/WebformTranslationConfigManager.php, line 669

Class

WebformTranslationConfigManager
Defines a class to translate webform config.

Namespace

Drupal\webform

Code

protected function buildConfigWebformFormCompositePropertyElement(array $element, array $translation_element, array $source_element, $property_parents) {
  $property_key = end($property_parents);
  $property_name = '#' . $property_key;
  $webform_element = $this->elementManager
    ->getElementInstance($element);

  /** @var \Drupal\webform\Plugin\WebformElement\WebformCustomComposite $webform_element */
  $webform_element
    ->initializeCompositeElements($element);
  $composite_elements = $element['#webform_composite_elements'];
  $property_value = $translation_element[$property_name];
  $property_element = [
    '#type' => 'details',
    '#title' => $this
      ->t('Composite elements'),
    '#open' => TRUE,
  ];
  foreach ($property_value as $composite_element_key => $translation_composite_element) {
    $composite_element = $composite_elements[$composite_element_key];
    $composite_parents = array_merge($property_parents, [
      $composite_element_key,
    ]);
    $source_composite_element = $source_element[$property_name][$composite_element_key];
    $property_element[$composite_element_key] = $this
      ->buildConfigWebformFormElements($composite_element, $translation_composite_element, $source_composite_element, $composite_parents);
  }
  return $property_element;
}