Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getCacheMaxAge()
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;
}