1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\PageCache\Observer;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Event\ObserverInterface;
class FlushAllCache implements ObserverInterface
{
/**
* @var \Magento\Framework\App\PageCache\Cache
*
* @deprecated 100.1.0
*/
protected $_cache;
/**
* Application config object
*
* @var \Magento\PageCache\Model\Config
*/
protected $_config;
/**
* @var \Magento\PageCache\Model\Cache\Type
*/
private $fullPageCache;
/**
* @param \Magento\PageCache\Model\Config $config
* @param \Magento\Framework\App\PageCache\Cache $cache
*/
public function __construct(\Magento\PageCache\Model\Config $config, \Magento\Framework\App\PageCache\Cache $cache)
{
$this->_config = $config;
$this->_cache = $cache;
}
/**
* Flash Built-In cache
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) {
$this->getCache()->clean();
}
}
/**
* TODO: Workaround to support backwards compatibility, will rework to use Dependency Injection in MAGETWO-49547
*
* @return \Magento\PageCache\Model\Cache\Type
*/
private function getCache()
{
if (!$this->fullPageCache) {
$this->fullPageCache = ObjectManager::getInstance()->get(\Magento\PageCache\Model\Cache\Type::class);
}
return $this->fullPageCache;
}
}