1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the TrashHandler implementation. |
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\Persistence\Cache; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler as TrashHandlerInterface; |
12
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
13
|
|
|
use eZ\Publish\SPI\Persistence\Content\Relation; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @see \eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler |
17
|
|
|
*/ |
18
|
|
|
class TrashHandler extends AbstractHandler implements TrashHandlerInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
|
|
public function loadTrashItem($id) |
24
|
|
|
{ |
25
|
|
|
$this->logger->logCall(__METHOD__, array('id' => $id)); |
26
|
|
|
|
27
|
|
|
return $this->persistenceHandler->trashHandler()->loadTrashItem($id); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
View Code Duplication |
public function trashSubtree($locationId) |
34
|
|
|
{ |
35
|
|
|
$this->logger->logCall(__METHOD__, array('locationId' => $locationId)); |
36
|
|
|
|
37
|
|
|
$location = $this->persistenceHandler->locationHandler()->load($locationId); |
38
|
|
|
$reverseRelations = $this->persistenceHandler->contentHandler()->loadRelations($location->contentId); |
39
|
|
|
|
40
|
|
|
$return = $this->persistenceHandler->trashHandler()->trashSubtree($locationId); |
41
|
|
|
|
42
|
|
|
$tags = []; |
43
|
|
|
if (!empty($reverseRelations)) { |
44
|
|
|
$tags = array_map(function (Relation $relation) { |
45
|
|
|
return 'content-fields-' . $relation->destinationContentId; |
46
|
|
|
}, $reverseRelations); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$this->cache->invalidateTags([ |
50
|
|
|
'content-' . $location->contentId, |
51
|
|
|
'content-fields-' . $location->contentId, |
52
|
|
|
'location-' . $locationId, 'location-path-' . $locationId, |
53
|
|
|
] + $tags); |
54
|
|
|
|
55
|
|
|
return $return; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
|
View Code Duplication |
public function recover($trashedId, $newParentId) |
62
|
|
|
{ |
63
|
|
|
$this->logger->logCall(__METHOD__, array('id' => $trashedId, 'newParentId' => $newParentId)); |
64
|
|
|
|
65
|
|
|
$return = $this->persistenceHandler->trashHandler()->recover($trashedId, $newParentId); |
66
|
|
|
|
67
|
|
|
$location = $this->persistenceHandler->locationHandler()->load($return); |
68
|
|
|
$reverseRelations = $this->persistenceHandler->contentHandler()->loadRelations($location->contentId); |
69
|
|
|
|
70
|
|
|
$tags = []; |
71
|
|
|
if (!empty($reverseRelations)) { |
72
|
|
|
$tags = array_map(function (Relation $relation) { |
73
|
|
|
return 'content-fields-' . $relation->destinationContentId; |
74
|
|
|
}, $reverseRelations); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
$this->cache->invalidateTags([ |
78
|
|
|
'content-' . $location->contentId, |
79
|
|
|
'content-fields-' . $location->contentId, |
80
|
|
|
'location-' . $trashedId, 'location-path-' . $trashedId, |
81
|
|
|
] + $tags); |
82
|
|
|
|
83
|
|
|
return $return; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
|
|
public function findTrashItems(Criterion $criterion = null, $offset = 0, $limit = null, array $sort = null) |
90
|
|
|
{ |
91
|
|
|
$this->logger->logCall(__METHOD__, array('criterion' => $criterion ? get_class($criterion) : 'null')); |
92
|
|
|
|
93
|
|
|
return $this->persistenceHandler->trashHandler()->findTrashItems($criterion, $offset, $limit, $sort); |
|
|
|
|
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* {@inheritdoc} |
98
|
|
|
*/ |
99
|
|
|
public function emptyTrash() |
100
|
|
|
{ |
101
|
|
|
$this->logger->logCall(__METHOD__, array()); |
102
|
|
|
$this->persistenceHandler->trashHandler()->emptyTrash(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* {@inheritdoc} |
107
|
|
|
*/ |
108
|
|
|
public function deleteTrashItem($trashedId) |
109
|
|
|
{ |
110
|
|
|
$this->logger->logCall(__METHOD__, array('id' => $trashedId)); |
111
|
|
|
$this->persistenceHandler->trashHandler()->deleteTrashItem($trashedId); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.