Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FlushAllCache.php
Go to the documentation of this file.
1 <?php
8 
11 
13 {
19  protected $_cache;
20 
26  protected $_config;
27 
31  private $fullPageCache;
32 
37  public function __construct(\Magento\PageCache\Model\Config $config, \Magento\Framework\App\PageCache\Cache $cache)
38  {
39  $this->_config = $config;
40  $this->_cache = $cache;
41  }
42 
49  public function execute(\Magento\Framework\Event\Observer $observer)
50  {
51  if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) {
52  $this->getCache()->clean();
53  }
54  }
55 
61  private function getCache()
62  {
63  if (!$this->fullPageCache) {
64  $this->fullPageCache = ObjectManager::getInstance()->get(\Magento\PageCache\Model\Cache\Type::class);
65  }
66  return $this->fullPageCache;
67  }
68 }
$config
Definition: fraud_order.php:17
execute(\Magento\Framework\Event\Observer $observer)
__construct(\Magento\PageCache\Model\Config $config, \Magento\Framework\App\PageCache\Cache $cache)