You are here

public function WishlistBlock::getCacheTags in Commerce Wishlist 8.3

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

src/Plugin/Block/WishlistBlock.php, line 90

Class

WishlistBlock
Provides a wishlist block.

Namespace

Drupal\commerce_wishlist\Plugin\Block

Code

public function getCacheTags() {
  $cache_tags = parent::getCacheTags();
  $wishlist_cache_tags = [];

  /** @var \Drupal\commerce_wishlist\Entity\WishlistInterface[] $wishlists */
  $wishlists = $this->wishlistProvider
    ->getWishlists();
  foreach ($wishlists as $wishlist) {

    // Add tags for all wishlists regardless items.
    $wishlist_cache_tags = Cache::mergeTags($wishlist_cache_tags, $wishlist
      ->getCacheTags());
  }
  return Cache::mergeTags($cache_tags, $wishlist_cache_tags);
}