You are here

protected function WebformTranslationConfigManager::alterElements in Webform 6.x

Alter form elements recursively.

Parameters

array $elements: An associative array of form elements.

array $element_alterations: An associative array of element alterations.

1 call to WebformTranslationConfigManager::alterElements()
WebformTranslationConfigManager::alterConfigWebformForm in src/WebformTranslationConfigManager.php
Alter the webform configuration form.

File

src/WebformTranslationConfigManager.php, line 807

Class

WebformTranslationConfigManager
Defines a class to translate webform config.

Namespace

Drupal\webform

Code

protected function alterElements(array &$elements, array $element_alterations) {
  foreach ($elements as $key => &$element) {

    // Make sure the element key is a string.
    $key = (string) $key;
    if (Element::property($key) || !is_array($element)) {
      continue;
    }

    // Override/alter translation element.
    if (array_key_exists($key, $element_alterations) && isset($element['translation']) && isset($element['translation']['#type'])) {
      $element['translation'] = $element_alterations[$key] + $element['translation'];
    }
    $this
      ->alterElements($element, $element_alterations);
  }
}