public function DisplayPluginBase::calculateCacheMetadata in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::calculateCacheMetadata()
Calculates the display's cache metadata by inspecting each handler/plugin.
Return value
\Drupal\Core\Cache\CacheableMetadata The cache metadata.
Overrides DisplayPluginInterface::calculateCacheMetadata
1 call to DisplayPluginBase::calculateCacheMetadata()
- DisplayPluginBase::getCacheMetadata in core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php - Gets the cache metadata.
File
- core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php, line 2334
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
public function calculateCacheMetadata() {
$cache_metadata = new CacheableMetadata();
// Iterate over ordinary views plugins.
foreach (Views::getPluginTypes('plugin') as $plugin_type) {
$plugin = $this
->getPlugin($plugin_type);
if ($plugin instanceof CacheableDependencyInterface) {
$cache_metadata = $cache_metadata
->merge(CacheableMetadata::createFromObject($plugin));
}
}
// Iterate over all handlers. Note that at least the argument handler will
// need to ask all its subplugins.
foreach (array_keys(Views::getHandlerTypes()) as $handler_type) {
$handlers = $this
->getHandlers($handler_type);
foreach ($handlers as $handler) {
if ($handler instanceof CacheableDependencyInterface) {
$cache_metadata = $cache_metadata
->merge(CacheableMetadata::createFromObject($handler));
}
}
}
/** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */
if ($cache_plugin = $this
->getPlugin('cache')) {
$cache_plugin
->alterCacheMetadata($cache_metadata);
}
return $cache_metadata;
}