本文整理汇总了PHP中Drupal\Core\Block\BlockBase::getCacheContexts方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockBase::getCacheContexts方法的具体用法?PHP BlockBase::getCacheContexts怎么用?PHP BlockBase::getCacheContexts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Block\BlockBase
的用法示例。
在下文中一共展示了BlockBase::getCacheContexts方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCacheContexts
/**
* {@inheritdoc}
*/
public function getCacheContexts()
{
// The block by itself doesn't really vary by user, but some of its
// implementations are (collection module, I'm looking at you). For the sake
// of semplicity, we add the user context here already.
$contexts = parent::getCacheContexts();
return Cache::mergeContexts($contexts, ['user']);
}
示例2: getCacheContexts
/**
* {@inheritdoc}
*/
public function getCacheContexts()
{
return Cache::mergeContexts(parent::getCacheContexts(), ['route.book_navigation']);
}
示例3: getCacheContexts
/**
* {@inheritdoc}
*/
public function getCacheContexts()
{
// ::build() uses MenuLinkTreeInterface::getCurrentRouteMenuTreeParameters()
// to generate menu tree parameters, and those take the active menu trail
// into account. Therefore, we must vary the rendered menu by the active
// trail of the rendered menu.
// Additional cache contexts, e.g. those that determine link text or
// accessibility of a menu, will be bubbled automatically.
$menu_name = $this->getDerivativeId();
return Cache::mergeContexts(parent::getCacheContexts(), ['route.menu_active_trails:' . $menu_name]);
}
示例4: getCacheContexts
/**
* {@inheritdoc}
*/
public function getCacheContexts()
{
$context = parent::getCacheContexts();
// The links are only visible for certain roles on certain collections.
// Normally cache contexts are added automatically but these links depend on
// an optional context which we manage ourselves.
return Cache::mergeContexts($context, ['user', 'user.roles', 'collection', 'asset_release', 'solution', 'url.path']);
}
示例5: getCacheContexts
/**
* Implements \Drupal\Core\Entity\Entity::getCacheContexts().
*/
public function getCacheContexts()
{
return Cache::mergeContexts(parent::getCacheContexts(), array('route'));
}
示例6: getCacheContexts
/**
* {@inheritdoc}
*/
public function getCacheContexts()
{
$parent_context = parent::getCacheContexts();
return Cache::mergeContexts($parent_context, $this->ivwTracker->getCacheContexts());
}