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

HttpCacheSlot   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A receive() 0 8 2
supports() 0 1 ?
purgeHttpCache() 0 1 ?
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