function ContextAwarePluginTrait::getCacheMaxAge
Same name in other branches
- 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getCacheMaxAge()
- 11.x core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getCacheMaxAge()
1 call to ContextAwarePluginTrait::getCacheMaxAge()
- TestCacheBlock::getCacheMaxAge in core/
modules/ block/ tests/ modules/ block_test/ src/ Plugin/ Block/ TestCacheBlock.php
6 methods override ContextAwarePluginTrait::getCacheMaxAge()
- AttachedRenderingBlock::getCacheMaxAge in core/
modules/ system/ tests/ modules/ render_attached_test/ src/ Plugin/ Block/ AttachedRenderingBlock.php - BookNavigationBlock::getCacheMaxAge in core/
modules/ book/ src/ Plugin/ Block/ BookNavigationBlock.php - @todo Make cacheable in https://www.drupal.org/node/2483181
- LanguageBlock::getCacheMaxAge in core/
modules/ language/ src/ Plugin/ Block/ LanguageBlock.php - @todo Make cacheable in https://www.drupal.org/node/2232375.
- SystemMessagesBlock::getCacheMaxAge in core/
modules/ system/ src/ Plugin/ Block/ SystemMessagesBlock.php - TestAccessBlock::getCacheMaxAge in core/
modules/ block/ tests/ modules/ block_test/ src/ Plugin/ Block/ TestAccessBlock.php
File
-
core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php, line 203
Class
- ContextAwarePluginTrait
- Provides a trait to add context-aware functionality to plugins.
Namespace
Drupal\Core\PluginCode
public function getCacheMaxAge() {
$max_age = Cache::PERMANENT;
// Applied contexts can affect the cache max age when this plugin is
// involved in caching, collect and return them.
foreach ($this->getContexts() as $context) {
/** @var \Drupal\Core\Cache\CacheableDependencyInterface $context */
if ($context instanceof CacheableDependencyInterface) {
$max_age = Cache::mergeMaxAges($max_age, $context->getCacheMaxAge());
}
}
return $max_age;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.