You are here

protected function CartBlockBase::getCacheabilityMetadata in Commerce Cart Blocks 8

1 call to CartBlockBase::getCacheabilityMetadata()
CartBlockBase::buildCache in src/Plugin/Block/CartBlockBase.php

File

src/Plugin/Block/CartBlockBase.php, line 287

Class

CartBlockBase
CartBlockBase class.

Namespace

Drupal\commerce_cart_blocks\Plugin\Block

Code

protected function getCacheabilityMetadata() {
  $carts = $this
    ->getCarts();
  $cacheableMetadata = new CacheableMetadata();
  $cacheableMetadata
    ->addCacheContexts([
    'user',
    'session',
  ]);
  foreach ($carts as $cart) {
    $cacheableMetadata
      ->addCacheableDependency($cart);
  }
  return $cacheableMetadata;
}