function ContextAwarePluginTrait::getCacheMaxAge
2 methods override ContextAwarePluginTrait::getCacheMaxAge()
- 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
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;
}