Completed
Push — ezp25003-trash_subitems_count_... ( 8a8898 )
by André
34:44
created

DeleteLocationSlot::purgeHttpCache()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 6
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 11
rs 9.4285
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\API\Repository\Exceptions\NotFoundException;
14
use eZ\Publish\Core\SignalSlot\Signal;
15
16
/**
17
 * A slot handling DeleteLocationSignal.
18
 */
19
class DeleteLocationSlot extends PurgeForContentHttpCacheSlot
20
{
21
    protected function supports(Signal $signal)
22
    {
23
        return $signal instanceof Signal\LocationService\DeleteLocationSignal;
24
    }
25
26
    /**
27
     * Purges relevant location cache.
28
     *
29
     * @todo Change to be able to clear relations, siblings, ... cache, even when content is already deleted.
30
     *
31
     * @param \eZ\Publish\Core\SignalSlot\Signal\LocationService\DeleteLocationSignal $signal
32
     *
33
     * @return mixed
34
     */
35
    protected function purgeHttpCache(Signal $signal)
36
    {
37
        try {
38
            $locationIds = $this->extractLocationIds($signal);
39
40
            return $this->httpCacheClearer->purgeForContent($this->extractContentId($signal), $locationIds);
41
        } catch (NotFoundException $e) {
42
            // if content was deleted as well by this operation then fall back to clear location and parent location cache.
43
            $this->httpCacheClearer->purge($locationIds);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\MVC\Symf...wayCachePurger::purge() has been deprecated with message: as of 6.0. Will be removed in 7.0. Use purgeForContent() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44
        }
45
    }
46
}
47