protected function WebformConfigProcessor::convertElementsToData

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()

File

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

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;
}