forked from ezsystems/ezpublish-kernel
/
SwitchableHttpCachePurger.php
46 lines (38 loc) · 1.15 KB
/
SwitchableHttpCachePurger.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
<?php
/**
* This file is part of the EzPublishLegacyBridge package
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Bundle\EzPublishLegacyBundle\Cache;
use eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger;
/**
* A GatewayCachePurger decorator that allows the actual purger to be switched on/off.
*/
class SwitchableHttpCachePurger implements GatewayCachePurger
{
use Switchable;
/** @var \eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger */
private $gatewayCachePurger;
public function __construct( GatewayCachePurger $gatewayCachePurger )
{
$this->gatewayCachePurger = $gatewayCachePurger;
}
public function purge( $cacheElements )
{
if ( $this->isSwitchedOff() )
{
return $cacheElements;
}
return $this->gatewayCachePurger->purge( $cacheElements );
}
public function purgeAll()
{
if ( $this->isSwitchedOff() )
{
return;
}
$this->gatewayCachePurger->purgeAll();
}
}