public function NextPreviousBlock::getCacheTags in Next Previous Post Block (Node or Page Pagination) 1.0.x
Same name and namespace in other branches
- 8.5 src/Plugin/Block/NextPreviousBlock.php \Drupal\nextpre\Plugin\Block\NextPreviousBlock::getCacheTags()
- 8 src/Plugin/Block/NextPreviousBlock.php \Drupal\nextpre\Plugin\Block\NextPreviousBlock::getCacheTags()
- 9.0.x src/Plugin/Block/NextPreviousBlock.php \Drupal\nextpre\Plugin\Block\NextPreviousBlock::getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
Return value
string[] A set of cache tags.
Overrides ContextAwarePluginTrait::getCacheTags
File
- src/
Plugin/ Block/ NextPreviousBlock.php, line 157
Class
- NextPreviousBlock
- Provides a 'Next Previous' block.
Namespace
Drupal\nextpre\Plugin\BlockCode
public function getCacheTags() {
// Get the created time of the current node.
$node = $this->routeMatch
->getParameter('node');
if (!empty($node) && $node instanceof NodeInterface) {
// If there is node add its cachetag.
return Cache::mergeTags(parent::getCacheTags(), [
'node:*',
]);
}
else {
// Return default tags instead.
return parent::getCacheTags();
}
}