Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheInvalidate.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\App\Cache\Type\Block;
9 use \Magento\Framework\App\Cache\Type\Collection;
10 
12 {
16  private $typeList;
17 
21  private $swatchHelper;
22 
27  public function __construct(
28  \Magento\Framework\App\Cache\TypeListInterface $typeList,
29  \Magento\Swatches\Helper\Data $swatchHelper
30  ) {
31  $this->typeList = $typeList;
32  $this->swatchHelper = $swatchHelper;
33  }
34 
40  public function afterSave(
41  \Magento\Catalog\Model\ResourceModel\Eav\Attribute $subject,
42  \Magento\Catalog\Model\ResourceModel\Eav\Attribute $result
43  ) {
44  if ($this->swatchHelper->isSwatchAttribute($subject)) {
45  $this->typeList->invalidate(Block::TYPE_IDENTIFIER);
46  $this->typeList->invalidate(Collection::TYPE_IDENTIFIER);
47  }
48  return $result;
49  }
50 }
__construct(\Magento\Framework\App\Cache\TypeListInterface $typeList, \Magento\Swatches\Helper\Data $swatchHelper)
afterSave(\Magento\Catalog\Model\ResourceModel\Eav\Attribute $subject, \Magento\Catalog\Model\ResourceModel\Eav\Attribute $result)