Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TagScope.php
Go to the documentation of this file.
1 <?php
8 
16 {
22  private $_tag;
23 
28  public function __construct(\Magento\Framework\Cache\FrontendInterface $frontend, $tag)
29  {
30  parent::__construct($frontend);
31  $this->_tag = $tag;
32  }
33 
39  public function getTag()
40  {
41  return $this->_tag;
42  }
43 
49  public function save($data, $identifier, array $tags = [], $lifeTime = null)
50  {
51  $tags[] = $this->getTag();
52  return parent::save($data, $identifier, $tags, $lifeTime);
53  }
54 
60  public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = [])
61  {
63  $result = false;
64  foreach ($tags as $tag) {
65  if (parent::clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [$tag, $this->getTag()])) {
66  $result = true;
67  }
68  }
69  } else {
72  $tags = [$this->getTag()];
73  } else {
74  $tags[] = $this->getTag();
75  }
76  $result = parent::clean($mode, $tags);
77  }
78  return $result;
79  }
80 }
clean($mode=\Zend_Cache::CLEANING_MODE_ALL, array $tags=[])
Definition: TagScope.php:60
save($data, $identifier, array $tags=[], $lifeTime=null)
Definition: TagScope.php:49
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
__construct(\Magento\Framework\Cache\FrontendInterface $frontend, $tag)
Definition: TagScope.php:28
const CLEANING_MODE_ALL
Definition: Cache.php:72
const CLEANING_MODE_MATCHING_ANY_TAG
Definition: Cache.php:76
const CLEANING_MODE_MATCHING_TAG
Definition: Cache.php:74