Completed
Push — http_cache_slots ( c4b669 )
by
unknown
13:55
created

AbstractSlot   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
namespace eZ\Publish\Core\MVC\Symfony\Cache\Http\SignalSlot;
10
11
use eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface;
12
use eZ\Publish\Core\SignalSlot\Signal;
13
use eZ\Publish\Core\SignalSlot\Slot;
14
15
/**
16
 * A abstract legacy slot covering common functions needed for legacy slots.
17
 */
18
abstract class AbstractSlot extends Slot
19
{
20
    /**
21
     * @var \eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface
22
     */
23
    protected $purgeClient;
24
25
    /**
26
     * @param \eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface $purgeClient
27
     */
28
    public function __construct(PurgeClientInterface $purgeClient)
29
    {
30
        $this->purgeClient = $purgeClient;
31
    }
32
33
    public function receive(Signal $signal)
34
    {
35
        if (!$this->supports($signal)) {
36
            return;
37
        }
38
39
        $this->purgeHttpCache($signal);
40
    }
41
42
    /**
43
     * Checks if $signal is supported by this handler.
44
     *
45
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
46
     *
47
     * @return bool
48
     */
49
    abstract protected function supports(Signal $signal);
50
51
    /**
52
     * Purges relevant HTTP cache for $signal.
53
     *
54
     * @param \eZ\Publish\Core\SignalSlot\Signal $signal
55
     *
56
     * @return mixed
57
     */
58
    abstract protected function purgeHttpCache(Signal $signal);
59
}
60