function FieldPluginBase::getRenderTokens
Same name in other branches
- 9 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::getRenderTokens()
- 8.9.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::getRenderTokens()
- 11.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::getRenderTokens()
Overrides FieldHandlerInterface::getRenderTokens
3 calls to FieldPluginBase::getRenderTokens()
- ContextualLinks::render in core/
modules/ contextual/ src/ Plugin/ views/ field/ ContextualLinks.php - Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
- FieldPluginBase::renderText in core/
modules/ views/ src/ Plugin/ views/ field/ FieldPluginBase.php - Performs an advanced text render for the item.
- Links::getLinks in core/
modules/ views/ src/ Plugin/ views/ field/ Links.php - Gets the list of links used by this field.
File
-
core/
modules/ views/ src/ Plugin/ views/ field/ FieldPluginBase.php, line 1639
Class
- FieldPluginBase
- Base class for views fields.
Namespace
Drupal\views\Plugin\views\fieldCode
public function getRenderTokens($item) {
$tokens = [];
if (!empty($this->view->build_info['substitutions'])) {
$tokens = $this->view->build_info['substitutions'];
}
$count = 0;
foreach ($this->displayHandler
->getHandlers('argument') as $arg => $handler) {
$token = "{{ arguments.{$arg} }}";
if (!isset($tokens[$token])) {
$tokens[$token] = '';
}
// Use strip tags as there should never be HTML in the path.
// However, we need to preserve special characters like " that
// were removed by Html::escape().
$tokens["{{ raw_arguments.{$arg} }}"] = isset($this->view->args[$count]) ? strip_tags(Html::decodeEntities($this->view->args[$count])) : '';
$count++;
}
// Get flattened set of tokens for any array depth in query parameters.
if ($request = $this->view
->getRequest()) {
$tokens += $this->getTokenValuesRecursive($request->query
->all());
}
// Now add replacements for our fields.
foreach ($this->displayHandler
->getHandlers('field') as $field => $handler) {
/** @var static $handler */
$placeholder = $handler->getFieldTokenPlaceholder();
if (isset($handler->last_render)) {
$tokens[$placeholder] = $handler->last_render;
}
else {
$tokens[$placeholder] = '';
}
// We only use fields up to (and including) this one.
if ($field == $this->options['id']) {
break;
}
}
// Store the tokens for the row so we can reference them later if necessary.
$this->view->style_plugin->render_tokens[$this->view->row_index] = $tokens;
$this->last_tokens = $tokens;
if (!empty($item)) {
$this->addSelfTokens($tokens, $item);
}
return $tokens;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.