You are here

public function Serialized::render in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/Serialized.php \Drupal\views\Plugin\views\field\Serialized::render()
  2. 9 core/modules/views/src/Plugin/views/field/Serialized.php \Drupal\views\Plugin\views\field\Serialized::render()

File

core/modules/views/src/Plugin/views/field/Serialized.php, line 69

Class

Serialized
Field handler to show data of serialized fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function render(ResultRow $values) {
  $value = $values->{$this->field_alias};
  if ($this->options['format'] == 'unserialized') {
    return $this
      ->sanitizeValue(print_r(unserialize($value), TRUE));
  }
  elseif ($this->options['format'] == 'key' && !empty($this->options['key'])) {
    $value = (array) unserialize($value);
    return $this
      ->sanitizeValue($value[$this->options['key']]);
  }
  return $value;
}