public function Serialized::render in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/field/Serialized.php \Drupal\views\Plugin\views\field\Serialized::render()
- 10 core/modules/views/src/Plugin/views/field/Serialized.php \Drupal\views\Plugin\views\field\Serialized::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/ Serialized.php, line 69
Class
- Serialized
- Field handler to show data of serialized fields.
Namespace
Drupal\views\Plugin\views\fieldCode
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;
}