You are here

protected function OptionsShsWidget::settingToString in Simple hierarchical select 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldWidget/OptionsShsWidget.php \Drupal\shs\Plugin\Field\FieldWidget\OptionsShsWidget::settingToString()

Return string representation of a setting.

Parameters

string $key: Name of the setting.

Return value

string Value of the setting. If boolean, the value is "translated" to 'true' or 'false'.

File

src/Plugin/Field/FieldWidget/OptionsShsWidget.php, line 310

Class

OptionsShsWidget
Plugin implementation of the 'options_shs' widget.

Namespace

Drupal\shs\Plugin\Field\FieldWidget

Code

protected function settingToString($key) {
  $options = [
    FALSE => t('false'),
    TRUE => t('true'),
  ];
  $value = $this
    ->getSetting($key);
  if (!is_bool($value)) {
    return $value;
  }
  return $options[$value];
}