You are here

protected function OptionsShsWidget::settingToString in Simple hierarchical select 2.0.x

Same name and namespace in other branches
  1. 8 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 368

Class

OptionsShsWidget
Plugin implementation of the 'options_shs' widget.

Namespace

Drupal\shs\Plugin\Field\FieldWidget

Code

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