You are here

protected function WebformTranslationConfigManager::alterSchemaElementsRecursive in Webform 6.x

Alter schema elements.

Parameters

array $elements: An array of form elements.

array $schema_mapping: Schema mapping.

1 call to WebformTranslationConfigManager::alterSchemaElementsRecursive()
WebformTranslationConfigManager::alterTypedConfigElements in src/WebformTranslationConfigManager.php
Alter the webform configuration form using type config schema.

File

src/WebformTranslationConfigManager.php, line 851

Class

WebformTranslationConfigManager
Defines a class to translate webform config.

Namespace

Drupal\webform

Code

protected function alterSchemaElementsRecursive(array &$elements, array $schema_mapping) {
  foreach (Element::children($elements) as $element_key) {
    if (!isset($schema_mapping[$element_key])) {
      continue;
    }
    $element =& $elements[$element_key];
    $schema =& $schema_mapping[$element_key];
    if (isset($schema['type']) && $schema['type'] === 'mapping') {
      $this
        ->alterSchemaElementsRecursive($element, $schema['mapping']);
    }
    elseif (isset($schema['webform_type'])) {
      switch ($schema['webform_type']) {
        case 'html':
          $this
            ->alterHtmlEditorElement($element);
          break;
        case 'yaml':
        case 'twig':
        case 'text':
          $this
            ->alterTextareaElement($element, $schema['webform_type']);
          break;
      }
    }
  }
}