本文整理匯總了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());
}