Completed
Push — feature-EZP-25696 ( 605ead...1ad329 )
by André
28:10
created

PublishVersionSlot::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
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\Core\MVC\Symfony\Cache\PurgeClientInterface;
14
use eZ\Publish\Core\SignalSlot\Signal;
15
use eZ\Publish\SPI\Persistence\Content\Location\Handler;
16
17
18
/**
19
 * A slot handling PublishVersionSignal.
20
 */
21
class PublishVersionSlot extends AbstractContentSlot
22
{
23
    /**
24
     * @var \eZ\Publish\SPI\Persistence\Content\Location\Handler
25
     */
26
    private $locationHandler;
27
28
    /**
29
     * @param \eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface $purgeClient
30
     * @param \eZ\Publish\SPI\Persistence\Content\Location\Handler $spiLocationHandler
31
     */
32
    public function __construct(PurgeClientInterface $purgeClient, Handler $spiLocationHandler)
33
    {
34
        parent::__construct($purgeClient);
35
        $this->locationHandler = $spiLocationHandler;
36
    }
37
38
    /**
39
     * Default provides tags to clear content, relation, location, parent and sibling cache.
40
     *
41
     * Overload for tree operations where you also need to clear whole path.
42
     *
43
     * @param \eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal $signal
44
     *
45
     * @return array
46
     */
47
    protected function generateTags(Signal $signal)
48
    {
49
        $tags = parent::generateTags($signal);
50
        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...
51
            // self
52
            $tags[] = 'location-'.$location->id;
53
            // children
54
            $tags[] = 'parent-'.$location->id;
55
            // parent
56
            $tags[] = 'location-'.$location->parentId;
57
            // siblings
58
            $tags[] = 'parent-'.$location->parentId;
59
        }
60
61
        return $tags;
62
    }
63
64
    protected function supports(Signal $signal)
65
    {
66
        return $signal instanceof Signal\ContentService\PublishVersionSignal;
67
    }
68
}
69