function Boolean::render

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::render()
  2. 8.9.x core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::render()
  3. 11.x core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::render()

Overrides FieldPluginBase::render

File

core/modules/views/src/Plugin/views/field/Boolean.php, line 115

Class

Boolean
A handler to provide proper displays for booleans.

Namespace

Drupal\views\Plugin\views\field

Code

public function render(ResultRow $values) {
    $value = $this->getValue($values);
    if (!empty($this->options['not'])) {
        $value = !$value;
    }
    if ($this->options['type'] == 'custom') {
        $custom_value = $value ? $this->options['type_custom_true'] : $this->options['type_custom_false'];
        return ViewsRenderPipelineMarkup::create(UtilityXss::filterAdmin($custom_value));
    }
    elseif (isset($this->formats[$this->options['type']])) {
        return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1];
    }
    else {
        return $value ? $this->formats['yes-no'][0] : $this->formats['yes-no'][1];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.