You are here

public function WebformOptions::getOptions in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Entity/WebformOptions.php \Drupal\webform\Entity\WebformOptions::getOptions()

Get options (YAML) as an associative array.

Return value

array|bool Options as an associative array. Returns FALSE if options YAML is invalid.

Overrides WebformOptionsInterface::getOptions

1 call to WebformOptions::getOptions()
WebformOptions::preSave in src/Entity/WebformOptions.php
Acts on an entity before the presave hook is invoked.

File

src/Entity/WebformOptions.php, line 133

Class

WebformOptions
Defines the webform options entity.

Namespace

Drupal\webform\Entity

Code

public function getOptions() {
  if (!isset($this->optionsDecoded)) {
    try {
      $options = WebformYaml::decode($this->options);

      // Since YAML supports simple values.
      $options = is_array($options) ? $options : [];
    } catch (\Exception $exception) {
      $link = $this
        ->toLink($this
        ->t('Edit'), 'edit-form')
        ->toString();
      \Drupal::logger('webform')
        ->notice('%title options are not valid. @message', [
        '%title' => $this
          ->label(),
        '@message' => $exception
          ->getMessage(),
        'link' => $link,
      ]);
      $options = FALSE;
    }
    $this->optionsDecoded = $options;
  }
  return $this->optionsDecoded;
}