|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
4
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace eZ\Publish\Core\REST\Server\HttpCache\Controller; |
|
7
|
|
|
|
|
8
|
|
|
use eZ\Publish\Core\REST\Server\Values\CachedValue; |
|
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
10
|
|
|
|
|
11
|
|
|
class ContentController extends AbstractController |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var \eZ\Publish\Core\REST\Server\Controller\Content |
|
15
|
|
|
*/ |
|
16
|
|
|
private $innerController; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param \eZ\Publish\Core\REST\Server\Controller\Content|\eZ\Publish\Core\REST\Server\HttpCache\Controller\CachedValueUnwrapperController $contentController |
|
20
|
|
|
*/ |
|
21
|
|
|
public function __construct($contentController) |
|
22
|
|
|
{ |
|
23
|
|
|
$this->innerController = $contentController; |
|
|
|
|
|
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function redirectContent(Request $request) |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->innerController->redirectContent($request); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function loadContent($contentId, Request $request) |
|
32
|
|
|
{ |
|
33
|
|
|
$value = $this->innerController->loadContent($contentId, $request); |
|
34
|
|
|
|
|
35
|
|
|
return new CachedValue( |
|
36
|
|
|
$value, |
|
37
|
|
|
$this->getCacheTagsForContentInfo($value->contentInfo) |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function updateContentMetadata($contentId, Request $request) |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->innerController->updateContentMetadata($contentId, $request); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function redirectCurrentVersion($contentId) |
|
47
|
|
|
{ |
|
48
|
|
|
return new CachedValue( |
|
49
|
|
|
$this->innerController->redirectCurrentVersion($contentId), |
|
50
|
|
|
['content' => $contentId] |
|
51
|
|
|
); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function loadContentInVersion($contentId, $versionNumber, Request $request) |
|
55
|
|
|
{ |
|
56
|
|
|
$value = $this->innerController->loadContentInVersion($contentId, $versionNumber, $request); |
|
57
|
|
|
|
|
58
|
|
|
return new CachedValue( |
|
59
|
|
|
$value, |
|
60
|
|
|
$this->getCacheTagsForContentInfo($value->content->contentInfo) |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function createContent(Request $request) |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->innerController->createContent($request); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function deleteContent($contentId) |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->innerController->deleteContent($contentId); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function copyContent($contentId, Request $request) |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->innerController->copyContent($contentId, $request); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function loadContentVersions($contentId, Request $request) |
|
80
|
|
|
{ |
|
81
|
|
|
return new CachedValue( |
|
82
|
|
|
$this->innerController->loadContentVersions($contentId, $request), |
|
83
|
|
|
['content' => $contentId] |
|
84
|
|
|
); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function deleteContentVersion($contentId, $versionNumber) |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->innerController->deleteContentVersion($contentId, $versionNumber); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function createDraftFromVersion($contentId, $versionNumber) |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->innerController->createDraftFromVersion($contentId, $versionNumber); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function createDraftFromCurrentVersion($contentId) |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->innerController->createDraftFromCurrentVersion($contentId); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function updateVersion($contentId, $versionNumber, Request $request) |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->innerController->updateVersion($contentId, $versionNumber, $request); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function publishVersion($contentId, $versionNumber) |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->innerController->publishVersion($contentId, $versionNumber); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function redirectCurrentVersionRelations($contentId) |
|
113
|
|
|
{ |
|
114
|
|
|
return new CachedValue( |
|
115
|
|
|
$this->innerController->redirectCurrentVersionRelations($contentId), |
|
116
|
|
|
['content' => $contentId] |
|
117
|
|
|
); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function loadVersionRelations($contentId, $versionNumber, Request $request) |
|
121
|
|
|
{ |
|
122
|
|
|
return new CachedValue( |
|
123
|
|
|
$this->innerController->loadVersionRelations($contentId, $versionNumber, $request), |
|
124
|
|
|
['content' => $contentId] |
|
125
|
|
|
); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
public function loadVersionRelation($contentId, $versionNumber, $relationId, Request $request) |
|
129
|
|
|
{ |
|
130
|
|
|
return new CachedValue( |
|
131
|
|
|
$this->innerController->loadVersionRelation($contentId, $versionNumber, $relationId, $request), |
|
132
|
|
|
['content' => $contentId] |
|
133
|
|
|
); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function removeRelation($contentId, $versionNumber, $relationId, Request $request) |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->innerController->removeRelation($contentId, $versionNumber, $relationId, $request); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function createRelation($contentId, $versionNumber, Request $request) |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->innerController->createRelation($contentId, $versionNumber, $request); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public function createView() |
|
147
|
|
|
{ |
|
148
|
|
|
return $this->innerController->createView(); |
|
|
|
|
|
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.