Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Zend.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $_frontend;
17 
23  private $frontendFactory;
24 
30  private $pid;
31 
35  public function __construct(\Closure $frontendFactory)
36  {
37  $this->frontendFactory = $frontendFactory;
38  $this->_frontend = $frontendFactory();
39  $this->pid = getmypid();
40  }
41 
45  public function test($identifier)
46  {
47  return $this->getFrontEnd()->test($this->_unifyId($identifier));
48  }
49 
53  public function load($identifier)
54  {
55  return $this->getFrontEnd()->load($this->_unifyId($identifier));
56  }
57 
61  public function save($data, $identifier, array $tags = [], $lifeTime = null)
62  {
63  return $this->getFrontEnd()->save($data, $this->_unifyId($identifier), $this->_unifyIds($tags), $lifeTime);
64  }
65 
69  public function remove($identifier)
70  {
71  return $this->getFrontEnd()->remove($this->_unifyId($identifier));
72  }
73 
80  public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = [])
81  {
82  // Cleaning modes 'old' and 'notMatchingTag' are prohibited as a trade off for decoration reliability
83  if (!in_array(
84  $mode,
85  [
89  ]
90  )
91  ) {
92  throw new \InvalidArgumentException(
93  "Magento cache frontend does not support the cleaning mode '{$mode}'."
94  );
95  }
96  return $this->getFrontEnd()->clean($mode, $this->_unifyIds($tags));
97  }
98 
102  public function getBackend()
103  {
104  return $this->getFrontEnd()->getBackend();
105  }
106 
110  public function getLowLevelFrontend()
111  {
112  return $this->getFrontEnd();
113  }
114 
121  protected function _unifyId($identifier)
122  {
123  return strtoupper($identifier);
124  }
125 
132  protected function _unifyIds(array $ids)
133  {
134  foreach ($ids as $key => $value) {
135  $ids[$key] = $this->_unifyId($value);
136  }
137  return $ids;
138  }
139 
145  private function getFrontEnd()
146  {
147  if (getmypid() === $this->pid) {
148  return $this->_frontend;
149  }
150  $frontendFactory = $this->frontendFactory;
151  $this->_frontend = $frontendFactory();
152  $this->pid = getmypid();
153  return $this->_frontend;
154  }
155 }
clean($mode=\Zend_Cache::CLEANING_MODE_ALL, array $tags=[])
Definition: Zend.php:80
$value
Definition: gender.phtml:16
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
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
save($data, $identifier, array $tags=[], $lifeTime=null)
Definition: Zend.php:61
__construct(\Closure $frontendFactory)
Definition: Zend.php:35