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

AbstractSlot::receive()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 9.4285
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
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