You are here

public function Boolean::render in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::render()

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldPluginBase::render

File

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

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