public function YamlFormOptions::getOptions in YAML Form 8
Get options (YAML) as an associative array.
Return value
array|bool Elements as an associative array. Returns FALSE is options YAML is invalid.
Overrides YamlFormOptionsInterface::getOptions
1 call to YamlFormOptions::getOptions()
- YamlFormOptions::preSave in src/
Entity/ YamlFormOptions.php - Acts on an entity before the presave hook is invoked.
File
- src/
Entity/ YamlFormOptions.php, line 84
Class
- YamlFormOptions
- Defines the form options entity.
Namespace
Drupal\yamlform\EntityCode
public function getOptions() {
if (!isset($this->optionsDecoded)) {
try {
$options = Yaml::decode($this->options);
// Since YAML supports simple values.
$options = is_array($options) ? $options : [];
} catch (\Exception $exception) {
$link = $this
->link(t('Edit'), 'edit-form');
\Drupal::logger('yamlform')
->notice('%title options are not valid. @message', [
'%title' => $this
->label(),
'@message' => $exception
->getMessage(),
'link' => $link,
]);
$options = FALSE;
}
$this->optionsDecoded = $options;
}
return $this->optionsDecoded;
}