function DisplayPluginBase::buildRenderable
Same name in other branches
- 9 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::buildRenderable()
- 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::buildRenderable()
- 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::buildRenderable()
Overrides DisplayPluginInterface::buildRenderable
1 call to DisplayPluginBase::buildRenderable()
- Embed::buildRenderable in core/
modules/ views/ src/ Plugin/ views/ display/ Embed.php - Builds a renderable array of the view.
1 method overrides DisplayPluginBase::buildRenderable()
- Embed::buildRenderable in core/
modules/ views/ src/ Plugin/ views/ display/ Embed.php - Builds a renderable array of the view.
File
-
core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php, line 2398
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
public function buildRenderable(array $args = [], $cache = TRUE) {
$this->view->element += [
'#type' => 'view',
'#name' => $this->view->storage
->id(),
'#display_id' => $this->display['id'],
'#arguments' => $args,
'#embed' => FALSE,
'#view' => $this->view,
'#cache_properties' => [
'#view_id',
'#view_display_show_admin_links',
'#view_display_plugin_id',
],
];
// When something passes $cache = FALSE, they're asking us not to create our
// own render cache for it. However, we still need to include certain pieces
// of cacheability metadata (e.g.: cache contexts), so they can bubble up.
// Thus, we add the cacheability metadata first, then modify / remove the
// cache keys depending on the $cache argument.
$this->applyDisplayCacheabilityMetadata($this->view->element);
if ($cache) {
$this->view->element['#cache'] += [
'keys' => [],
];
// Places like \Drupal\views\ViewExecutable::setCurrentPage() set up an
// additional cache context.
$this->view->element['#cache']['keys'] = array_merge([
'views',
'display',
$this->view->element['#name'],
$this->view->element['#display_id'],
], $this->view->element['#cache']['keys']);
// Add arguments to the cache key.
if ($args) {
$this->view->element['#cache']['keys'][] = 'args';
$this->view->element['#cache']['keys'][] = implode(',', $args);
}
}
else {
// Remove the cache keys, to ensure render caching is not triggered. We
// don't unset the other #cache values, to allow cacheability metadata to
// still be bubbled.
unset($this->view->element['#cache']['keys']);
}
return $this->view->element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.