You are here

public function FieldPluginBase::isValueEmpty in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::isValueEmpty()

Checks if a field value is empty.

Parameters

$value: The field value.

bool $empty_zero: Whether or not this field is configured to consider 0 as empty.

bool $no_skip_empty: Whether or not to use empty() to check the value.

Return value

bool TRUE if the value is considered empty, FALSE otherwise.

Overrides FieldHandlerInterface::isValueEmpty

2 calls to FieldPluginBase::isValueEmpty()
FieldPluginBase::advancedRender in core/modules/views/src/Plugin/views/field/FieldPluginBase.php
Renders a field using advanced settings.
FieldPluginBase::renderText in core/modules/views/src/Plugin/views/field/FieldPluginBase.php
Performs an advanced text render for the item.

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 1215

Class

FieldPluginBase
Base class for views fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE) {

  // Convert MarkupInterface to a string for checking.
  if ($value instanceof MarkupInterface) {
    $value = (string) $value;
  }
  if (!isset($value)) {
    $empty = TRUE;
  }
  else {
    $empty = $empty_zero || $value !== 0 && $value !== '0';
  }
  if ($no_skip_empty) {
    $empty = empty($value) && $empty;
  }
  return $empty;
}