-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFlushAllCache.php
60 lines (49 loc) · 1.65 KB
/
FlushAllCache.php
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
<?php
/**
* LiteMage
* @package LiteSpeed_LiteMage
* @copyright Copyright (c) LiteSpeed Technologies, Inc. All rights reserved. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
namespace Litespeed\Litemage\Observer;
class FlushAllCache implements \Magento\Framework\Event\ObserverInterface
{
/**
* @var \Litespeed\Litemage\Model\Config
*/
protected $config;
private $enabled;
/** @var \Magento\Framework\Event\ManagerInterface */
protected $eventManager;
/**
* @param \Litespeed\Litemage\Model\Config $config,
* @param \Magento\Framework\Event\ManagerInterface $eventManager,
*/
public function __construct(\Litespeed\Litemage\Model\Config $config,
\Magento\Framework\Event\ManagerInterface $eventManager)
{
$this->config = $config;
$this->eventManager = $eventManager;
$this->enabled = $this->config->moduleEnabled();
}
/**
* Flush All Litemage cache
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->enabled) {
return;
}
$reason = 'FlushAllCache from ' . $observer->getEvent()->getName();
$param = ['tags' => ['*'], 'reason' => $reason];
if (PHP_SAPI == 'cli') {
// from command line
$this->eventManager->dispatch('litemage_cli_purge', $param);
} else {
$this->eventManager->dispatch('litemage_purge', $param);
}
}
}