Completed
Push — ezp26297-rest_embedding_http_c... ( 123323 )
by
unknown
80:28 queued 54:58
created

ContentController::createDraftFromVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
Documentation Bug introduced by
It seems like $contentController can also be of type object<eZ\Publish\Core\R...lueUnwrapperController>. However, the property $innerController is declared as type object<eZ\Publish\Core\R...ver\Controller\Content>. Maybe add an additional type check?

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 $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. 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.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
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();
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\REST\Ser...r\Content::createView() has been deprecated with message: Since platform 1.0. Forwards the request to the new /views location, but returns a 301.

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.

Loading history...
149
    }
150
}
151