You are here

public static function YamlFormOptionsHelper::convertOptionsToString in YAML Form 8

Convert options with TranslatableMarkup into strings.

Parameters

array $options: An associative array of options with TranslatableMarkup.

Return value

string An associative array of options of strings

2 calls to YamlFormOptionsHelper::convertOptionsToString()
YamlFormOptions::preSave in src/Entity/YamlFormOptions.php
Acts on an entity before the presave hook is invoked.
YamlFormOptionsForm::getOptions in src/YamlFormOptionsForm.php
Get options.

File

src/Utility/YamlFormOptionsHelper.php, line 87

Class

YamlFormOptionsHelper
Helper class form options based methods.

Namespace

Drupal\yamlform\Utility

Code

public static function convertOptionsToString(array $options) {
  $string = [];
  foreach ($options as $option_value => $option_text) {
    if (is_array($option_text)) {
      $string[(string) $option_value] = self::toStringOption($option_text);
    }
    else {
      $string[(string) $option_value] = (string) $option_text;
    }
  }
  return $string;
}