You are here

protected function WebformConfigProcessor::convertElementsToData in Translation Management Tool 8

Converts the webform elements structure to translatable data.

Parameters

array $source_elements: A nested webform elements structure.

Return value

array The converted data structure.

1 call to WebformConfigProcessor::convertElementsToData()
WebformConfigProcessor::extractTranslatables in sources/tmgmt_config/src/WebformConfigProcessor.php

File

sources/tmgmt_config/src/WebformConfigProcessor.php, line 86

Class

WebformConfigProcessor

Namespace

Drupal\tmgmt_config

Code

protected function convertElementsToData(array $source_elements) {
  $data = [];
  foreach ($source_elements as $key => $value) {
    $safe_key = strtr($key, self::REPLACE_PAIRS);
    if (is_array($value)) {
      $data[$safe_key] = $this
        ->convertElementsToData($value);
      $data[$safe_key]['#label'] = $key;
    }
    else {
      $data[$safe_key] = [
        // @todo Is there a better label?
        '#label' => $key,
        '#text' => $value,
        '#translate' => $this
          ->isTranslatable($value),
      ];
    }
  }
  return $data;
}