function FieldPluginBase::advancedRender
Same name in other branches
- 9 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::advancedRender()
- 8.9.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::advancedRender()
- 10 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::advancedRender()
Overrides FieldHandlerInterface::advancedRender
File
-
core/
modules/ views/ src/ Plugin/ views/ field/ FieldPluginBase.php, line 1189
Class
- FieldPluginBase
- Base class for views fields.
Namespace
Drupal\views\Plugin\views\fieldCode
public function advancedRender(ResultRow $values) {
// Clean up values from previous render calls.
if ($this->lastRenderIndex != $values->index) {
$this->last_render_text = '';
}
if ($this->allowAdvancedRender() && $this instanceof MultiItemsFieldHandlerInterface) {
$raw_items = $this->getItems($values);
// If there are no items, set the original value to NULL.
if (empty($raw_items)) {
$this->original_value = NULL;
}
}
else {
$value = $this->render($values);
if (is_array($value)) {
$value = $this->getRenderer()
->render($value);
}
$this->last_render = $value;
$this->original_value = $value;
}
if ($this->allowAdvancedRender()) {
if ($this instanceof MultiItemsFieldHandlerInterface) {
$items = [];
foreach ($raw_items as $count => $item) {
$value = $this->render_item($count, $item);
if (is_array($value)) {
$value = (string) $this->getRenderer()
->render($value);
}
$this->last_render = $value;
$this->original_value = $this->last_render;
$alter = $item + $this->options['alter'];
$alter['phase'] = static::RENDER_TEXT_PHASE_SINGLE_ITEM;
$items[] = $this->renderText($alter);
}
$value = $this->renderItems($items);
}
else {
$alter = [
'phase' => static::RENDER_TEXT_PHASE_COMPLETELY,
] + $this->options['alter'];
$value = $this->renderText($alter);
}
if (is_array($value)) {
$value = $this->getRenderer()
->render($value);
}
// This happens here so that renderAsLink can get the unaltered value of
// this field as a token rather than the altered value.
$this->last_render = $value;
}
// String cast is necessary to test emptiness of MarkupInterface
// objects.
if (empty((string) $this->last_render)) {
if ($this->isValueEmpty($this->last_render, $this->options['empty_zero'], FALSE)) {
$alter = $this->options['alter'];
$alter['alter_text'] = 1;
$alter['text'] = $this->options['empty'];
$alter['phase'] = static::RENDER_TEXT_PHASE_EMPTY;
$this->last_render = $this->renderText($alter);
}
}
// If we rendered something, update the last render index.
if ((string) $this->last_render !== '') {
$this->lastRenderIndex = $values->index;
}
return $this->last_render;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.