本文整理汇总了PHP中Drupal\views\ViewExecutable::getCacheTags方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewExecutable::getCacheTags方法的具体用法?PHP ViewExecutable::getCacheTags怎么用?PHP ViewExecutable::getCacheTags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\ViewExecutable
的用法示例。
在下文中一共展示了ViewExecutable::getCacheTags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* {@inheritdoc}
*/
public function render()
{
$rows = !empty($this->view->result) || $this->view->style_plugin->evenEmpty() ? $this->view->style_plugin->render($this->view->result) : array();
$element = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#pre_render' => [[$this, 'elementPreRender']], '#rows' => $rows, '#attached' => &$this->view->element['#attached'], '#cache' => &$this->view->element['#cache'], '#post_render_cache' => &$this->view->element['#post_render_cache']);
if (!isset($element['#cache'])) {
$element['#cache'] = [];
}
$element['#cache'] += ['tags' => []];
// If the output is a render array, add cache tags, regardless of whether
// caching is enabled or not; cache tags must always be set.
$element['#cache']['tags'] = Cache::mergeTags($element['#cache']['tags'], $this->view->getCacheTags());
return $element;
}
示例2: applyDisplayCachablityMetadata
/**
* Applies the cacheability of the current display to the given render array.
*
* @param array $element
* The render array with updated cacheability metadata.
*/
protected function applyDisplayCachablityMetadata(array &$element)
{
/** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */
$cache = $this->getPlugin('cache');
(new CacheableMetadata())->setCacheTags(Cache::mergeTags($this->view->getCacheTags(), isset($this->display['cache_metadata']['tags']) ? $this->display['cache_metadata']['tags'] : []))->setCacheContexts(isset($this->display['cache_metadata']['contexts']) ? $this->display['cache_metadata']['contexts'] : [])->setCacheMaxAge(Cache::mergeMaxAges($cache->getCacheMaxAge(), isset($this->display['cache_metadata']['max-age']) ? $this->display['cache_metadata']['max-age'] : Cache::PERMANENT))->merge(CacheableMetadata::createFromRenderArray($element))->applyTo($element);
}
示例3: calculateXmlCacheTags
/**
* {@inheritdoc}
*/
protected function calculateXmlCacheTags()
{
// Pull the tags directly out of the view object.
return $this->view->getCacheTags();
}