function Serialized::render

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

Overrides FieldPluginBase::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;
}

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