Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FlushCacheByProductIds.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
12 
17 {
21  private $cacheContext;
22 
26  private $eventManager;
27 
31  private $productCacheTag;
32 
38  public function __construct(
39  CacheContext $cacheContext,
40  EventManager $eventManager,
41  string $productCacheTag
42  ) {
43  $this->cacheContext = $cacheContext;
44  $this->eventManager = $eventManager;
45  $this->productCacheTag = $productCacheTag;
46  }
47 
54  public function execute(array $productIds)
55  {
56  if ($productIds) {
57  $this->cacheContext->registerEntities($this->productCacheTag, $productIds);
58  $this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
59  }
60  }
61 }
__construct(CacheContext $cacheContext, EventManager $eventManager, string $productCacheTag)