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\SignalSlot\Signal; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* An abstract HTTP Cache purging Slot that purges cache for a Content. |
17
|
|
|
* |
18
|
|
|
* Will by default use the contentId property of the signal object, as it is the most common. Override the |
19
|
|
|
* extractContentId() method in your own signal to use a different property. |
20
|
|
|
*/ |
21
|
|
|
abstract class PurgeForContentHttpCacheSlot extends HttpCacheSlot |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Purges all caches. |
25
|
|
|
* |
26
|
|
|
* @param \eZ\Publish\Core\SignalSlot\Signal $signal |
27
|
|
|
* |
28
|
|
|
* @return mixed |
29
|
|
|
*/ |
30
|
|
|
protected function purgeHttpCache(Signal $signal) |
31
|
|
|
{ |
32
|
|
|
return $this->httpCacheClearer->purgeForContent($this->extractContentId($signal), $this->extractLocationIds($signal)); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Default implementation that returns the contentId property's value. |
37
|
|
|
* |
38
|
|
|
* @param \eZ\Publish\Core\SignalSlot\Signal $signal |
39
|
|
|
* |
40
|
|
|
* @return mixed Content ID |
41
|
|
|
*/ |
42
|
|
|
protected function extractContentId(Signal $signal) |
43
|
|
|
{ |
44
|
|
|
return $signal->contentId; |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Default implementation that returns the signal location property values. |
49
|
|
|
* |
50
|
|
|
* This is extracted and provided to purgeForContent in case content is trashed where affected location is no longer returned by API. |
51
|
|
|
* |
52
|
|
|
* @param \eZ\Publish\Core\SignalSlot\Signal $signal |
53
|
|
|
* |
54
|
|
|
* @return array Location ID's |
55
|
|
|
*/ |
56
|
|
|
protected function extractLocationIds(Signal $signal) |
57
|
|
|
{ |
58
|
|
|
$locationIds = []; |
59
|
|
|
if (isset($signal->locationId)) { |
60
|
|
|
$locationIds[] = $signal->locationId; |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (isset($signal->parentLocationId)) { |
64
|
|
|
$locationIds[] = $signal->parentLocationId; |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return $locationIds; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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.