Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
18  protected $stateCollection;
19 
29  public function __construct(
30  \Magento\Framework\Mview\Config\Reader $reader,
31  \Magento\Framework\Config\CacheInterface $cache,
32  \Magento\Framework\Mview\View\State\CollectionInterface $stateCollection,
33  $cacheId = 'mview_config',
34  SerializerInterface $serializer = null
35  ) {
36  $this->stateCollection = $stateCollection;
37 
38  $isCacheExists = $cache->test($cacheId);
39 
40  parent::__construct($reader, $cache, $cacheId, $serializer);
41 
42  if (!$isCacheExists) {
43  $this->deleteNonexistentStates();
44  }
45  }
46 
52  protected function deleteNonexistentStates()
53  {
54  foreach ($this->stateCollection->getItems() as $state) {
56  if (!isset($this->_data[$state->getViewId()])) {
57  $state->delete();
58  }
59  }
60  }
61 }
__construct(\Magento\Framework\Mview\Config\Reader $reader, \Magento\Framework\Config\CacheInterface $cache, \Magento\Framework\Mview\View\State\CollectionInterface $stateCollection, $cacheId='mview_config', SerializerInterface $serializer=null)
Definition: Data.php:29