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

PublishVersionSlot::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
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\SPI\Persistence\Content\Location\Handler;
14
15
/**
16
 * A slot handling PublishVersionSignal.
17
 */
18
class PublishVersionSlot extends AbstractContentSlot
19
{
20
    /**
21
     * @var \eZ\Publish\SPI\Persistence\Content\Location\Handler
22
     */
23
    private $locationHandler;
24
25
    /**
26
     * @param \eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface $purgeClient
27
     * @param \eZ\Publish\SPI\Persistence\Content\Location\Handler $spiLocationHandler
28
     */
29
    public function __construct(PurgeClientInterface $purgeClient, Handler $spiLocationHandler)
30
    {
31
        parent::__construct($purgeClient);
32
        $this->locationHandler = $spiLocationHandler;
33
    }
34
35
    /**
36
     * Default provides tags to clear content, relation, location, parent and sibling cache.
37
     *
38
     * Overload for tree operations where you also need to clear whole path.
39
     *
40
     * @param \eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal $signal
41
     *
42
     * @return array
43
     */
44
    protected function generateTags(Signal $signal)
45
    {
46
        $tags = parent::generateTags($signal);
47
        foreach ($this->locationHandler->loadLocationsByContent($signal->contentId) as $location) {
0 ignored issues
show
Documentation introduced by
The property contentId does not exist on object<eZ\Publish\Core\SignalSlot\Signal>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
48
            // self
49
            $tags[] = 'location-' . $location->id;
50
            // children
51
            $tags[] = 'parent-' . $location->id;
52
            // parent
53
            $tags[] = 'location-' . $location->parentId;
54
            // siblings
55
            $tags[] = 'parent-' . $location->parentId;
56
        }
57
58
        return $tags;
59
    }
60
61
    protected function supports(Signal $signal)
62
    {
63
        return $signal instanceof Signal\ContentService\PublishVersionSignal;
64
    }
65
}
66