Completed
Push — ezp26352-skip_csrf_check_on_re... ( 19f37a...6abe82 )
by
unknown
79:54 queued 33:48
created

HttpCacheSlot::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the eZ Publish Kernel package.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 *
9
 * @version //autogentag//
10
 */
11
namespace eZ\Publish\Core\MVC\Symfony\Cache\Http\SignalSlot;
12
13
use eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger;
14
use eZ\Publish\Core\SignalSlot\Signal;
15
use eZ\Publish\Core\SignalSlot\Slot;
16
17
/**
18
 * A abstract legacy slot covering common functions needed for legacy slots.
19
 */
20
abstract class HttpCacheSlot extends Slot
21
{
22
    /**
23
     * @var \eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger
24
     */
25
    protected $httpCacheClearer;
26
27
    /**
28
     * @param \eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger $httpCacheClearer
29
     */
30
    public function __construct(GatewayCachePurger $httpCacheClearer)
31
    {
32
        $this->httpCacheClearer = $httpCacheClearer;
33
    }
34
35
    public function receive(Signal $signal)
36
    {
37
        if (!$this->supports($signal)) {
38
            return;
39
        }
40
41
        $this->purgeHttpCache($signal);
42
    }
43
44
    /**
45
     * Checks if $signal is supported by this handler.
46
     *
47
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
48
     *
49
     * @return bool
50
     */
51
    abstract protected function supports(Signal $signal);
52
53
    /**
54
     * Purges the HTTP cache for $signal.
55
     *
56
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
57
     *
58
     * @return mixed
59
     */
60
    abstract protected function purgeHttpCache(Signal $signal);
61
}
62