You are here

protected function WebformUiElementTestForm::convertTranslatableMarkupToStringRecursive in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_ui/src/Form/WebformUiElementTestForm.php \Drupal\webform_ui\Form\WebformUiElementTestForm::convertTranslatableMarkupToStringRecursive()

Convert all translatable markup to strings.

This allows element to be serialized.

Parameters

array $element: An element.

Return value

array The element with all translatable markup converted to strings.

1 call to WebformUiElementTestForm::convertTranslatableMarkupToStringRecursive()
WebformUiElementTestForm::buildForm in modules/webform_ui/src/Form/WebformUiElementTestForm.php
Form constructor.

File

modules/webform_ui/src/Form/WebformUiElementTestForm.php, line 227

Class

WebformUiElementTestForm
Provides a test webform for webform elements.

Namespace

Drupal\webform_ui\Form

Code

protected function convertTranslatableMarkupToStringRecursive(array $element) {
  foreach ($element as $key => $value) {
    if ($value instanceof TranslatableMarkup) {
      $element[$key] = (string) $value;
    }
    elseif (is_array($value)) {
      $element[$key] = $this
        ->convertTranslatableMarkupToStringRecursive($value);
    }
  }
  return $element;
}