Completed
Push — feature-EZP-25696 ( 52d929...5f47d3 )
by André
23:51
created

AbstractSlot::purgeHttpCache()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 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\PurgeClientInterface;
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 AbstractSlot extends Slot
21
{
22
    /**
23
     * @var \eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface
24
     */
25
    protected $purgeClient;
26
27
    /**
28
     * @param \eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface $purgeClient
29
     */
30
    public function __construct(PurgeClientInterface $purgeClient)
31
    {
32
        $this->purgeClient = $purgeClient;
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 relevant 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