public function CartBlock::getCacheTags in Commerce Core 8.2
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 ContextAwarePluginBase::getCacheTags
File
- modules/
cart/ src/ Plugin/ Block/ CartBlock.php, line 216
Class
- CartBlock
- Provides a cart block.
Namespace
Drupal\commerce_cart\Plugin\BlockCode
public function getCacheTags() {
$cache_tags = parent::getCacheTags();
$cart_cache_tags = [];
/** @var \Drupal\commerce_order\Entity\OrderInterface[] $carts */
$carts = $this->cartProvider
->getCarts();
foreach ($carts as $cart) {
// Add tags for all carts regardless items or cart flag.
$cart_cache_tags = Cache::mergeTags($cart_cache_tags, $cart
->getCacheTags());
}
return Cache::mergeTags($cache_tags, $cart_cache_tags);
}