|
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\SignalSlot\Signal; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* An abstract HTTP Cache purging Slot that purges cache for a Content. |
|
15
|
|
|
* |
|
16
|
|
|
* Will by default use the contentId property of the signal object, as it is the most common. Set generateTags() |
|
17
|
|
|
* method in case of different signals or need to clear more then the defaults. |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractContentSlot extends AbstractSlot |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Purges relevant HTTP cache for $signal. |
|
23
|
|
|
* |
|
24
|
|
|
* @param \eZ\Publish\Core\SignalSlot\Signal $signal |
|
25
|
|
|
* |
|
26
|
|
|
* @return mixed |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function purgeHttpCache(Signal $signal) |
|
29
|
|
|
{ |
|
30
|
|
|
return $this->purgeClient->purge($this->generateTags($signal)); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Default provides tags to clear content, relation, location, parent and sibling cache. |
|
35
|
|
|
* |
|
36
|
|
|
* Overload for tree operations where you also need to clear whole path. |
|
37
|
|
|
* |
|
38
|
|
|
* @param \eZ\Publish\Core\SignalSlot\Signal $signal |
|
39
|
|
|
* |
|
40
|
|
|
* @return array |
|
41
|
|
|
*/ |
|
42
|
|
|
protected function generateTags(Signal $signal) |
|
43
|
|
|
{ |
|
44
|
|
|
$tags = []; |
|
45
|
|
|
|
|
46
|
|
|
if (isset($signal->contentId)) { |
|
47
|
|
|
// self in all forms (also withouth locations) |
|
48
|
|
|
$tags[] = 'content-' . $signal->contentId; |
|
|
|
|
|
|
49
|
|
|
// reverse relations |
|
50
|
|
|
$tags[] = 'relation-' . $signal->contentId; |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
View Code Duplication |
if (isset($signal->locationId)) { |
|
|
|
|
|
|
54
|
|
|
// self |
|
55
|
|
|
$tags[] = 'location-' . $signal->locationId; |
|
|
|
|
|
|
56
|
|
|
// direct children |
|
57
|
|
|
$tags[] = 'parent-' . $signal->locationId; |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
View Code Duplication |
if (isset($signal->parentLocationId)) { |
|
|
|
|
|
|
61
|
|
|
// direct parent |
|
62
|
|
|
$tags[] = 'location-' . $signal->parentLocationId; |
|
|
|
|
|
|
63
|
|
|
// direct siblings |
|
64
|
|
|
$tags[] = 'parent-' . $signal->parentLocationId; |
|
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return $tags; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
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@propertyannotation to your class or interface to document the existence of this variable.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.