Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Boolean.php

function 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];
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal