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

UserController::loadUserGroupsAssignedToRole()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 14
loc 14
rs 9.4285
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\API\Repository\Values\Content\ContentInfo;
9
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
10
use eZ\Publish\API\Repository\Values\User\User;
11
use eZ\Publish\API\Repository\Values\User\UserGroup;
12
use eZ\Publish\Core\REST\Server\Values\CachedValue;
13
use Symfony\Component\HttpFoundation\Request;
14
15
class UserController extends AbstractController
16
{
17
    /**
18
     * @var \eZ\Publish\Core\REST\Server\Controller\User
19
     */
20
    private $innerController;
21
22
    public function __construct($innerController)
23
    {
24
        $this->innerController = $innerController;
25
    }
26
27
    public function loadRootUserGroup()
28
    {
29
        $group = $this->innerController->loadRootUserGroup();
30
31
        return new CachedValue(
32
            $group,
33
            ['path' => 5, 'location' => 5]
34
        );
35
    }
36
37 View Code Duplication
    public function loadUserGroup($groupPath)
38
    {
39
        $group = $this->innerController->loadUserGroup($groupPath);
40
41
        return new CachedValue(
42
            $group,
43
            array_merge(
44
                $this->getCacheTagsForContentInfo($group->contentInfo),
0 ignored issues
show
Bug introduced by
The property contentInfo does not seem to exist in eZ\Publish\Core\REST\Server\Values\CachedValue.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
45
                ['path' => $group->mainLocation->path]
0 ignored issues
show
Bug introduced by
The property mainLocation does not seem to exist in eZ\Publish\Core\REST\Server\Values\CachedValue.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
46
            )
47
        );
48
    }
49
50 View Code Duplication
    public function loadUser($userId)
51
    {
52
        $user = $this->innerController->loadUser($userId);
53
54
        return new CachedValue(
55
            $user,
56
            array_merge(
57
                $this->getCacheTagsForContentInfo($user->contentInfo),
0 ignored issues
show
Bug introduced by
The property contentInfo does not seem to exist in eZ\Publish\Core\REST\Server\Values\CachedValue.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
58
                ['path' => $user->mainLocation->path]
0 ignored issues
show
Bug introduced by
The property mainLocation does not seem to exist in eZ\Publish\Core\REST\Server\Values\CachedValue.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
59
            )
60
        );
61
    }
62
63
    public function createUserGroup($groupPath, Request $request)
64
    {
65
        return $this->innerController->createUserGroup($groupPath, $request);
66
    }
67
68
    public function createUser($groupPath, Request $request)
69
    {
70
        return $this->innerController->createUser($groupPath, $request);
71
    }
72
73
    public function updateUserGroup($groupPath, Request $request)
74
    {
75
        return $this->innerController->updateUserGroup($groupPath, $request);
76
    }
77
78
    public function updateUser($userId, Request $request)
79
    {
80
        return $this->innerController->updateUser($userId, $request);
81
    }
82
83
    public function deleteUserGroup($groupPath)
84
    {
85
        return $this->innerController->deleteUserGroup($groupPath);
86
    }
87
88
    public function deleteUser($userId)
89
    {
90
        return $this->innerController->deleteUser($userId);
91
    }
92
93 View Code Duplication
    public function loadUsers(Request $request)
94
    {
95
        $usersList = $this->innerController->loadUsers($request);
96
97
        $tags = [];
98
        foreach ($usersList->users as $user) {
99
            $tags = array_merge_recursive(
100
                $tags,
101
                $this->getCacheTagsForContentInfo($user->contentInfo)
102
            );
103
        }
104
105
        return new CachedValue($usersList, $tags);
106
    }
107
108 View Code Duplication
    public function verifyUsers(Request $request)
109
    {
110
        $users = $this->innerController->verifyUsers($request);
111
112
        $tags = [];
113
        foreach ($users as $user) {
0 ignored issues
show
Bug introduced by
The expression $users of type object<eZ\Publish\Core\REST\Server\Values\OK> is not traversable.
Loading history...
114
            $tags = array_merge_recursive(
115
                $tags,
116
                $this->getCacheTagsForContentInfo($user->contentInfo)
117
            );
118
        }
119
120
        return new CachedValue($users, $tags);
121
    }
122
123 View Code Duplication
    public function loadUsersAssignedToRole($roleId)
124
    {
125
        $users = $this->innerController->loadUsersAssignedToRole($roleId);
126
127
        $tags = [];
128
        foreach ($users as $user) {
129
            $tags = array_merge_recursive(
130
                $tags,
131
                $this->getCacheTagsForContentInfo($user->contentInfo)
132
            );
133
        }
134
135
        return new CachedValue($users, $tags);
136
    }
137
138 View Code Duplication
    public function loadUserGroups(Request $request)
139
    {
140
        $groups = $this->innerController->loadUserGroups($request);
141
142
        $tags = [];
143
        foreach ($groups->userGroups as $userGroup) {
144
            $tags = array_merge_recursive(
145
                $tags,
146
                $this->getCacheTagsForContentInfo($userGroup->contentInfo)
147
            );
148
        }
149
150
        return new CachedValue($groups, $tags);
151
    }
152
153
    public function loadUserGroupByRemoteId(Request $request)
154
    {
155
        $group = $this->innerController->loadUserGroupByRemoteId($request); // TODO: Change the autogenerated stub
156
157
        return new CachedValue(
158
            $group,
159
            $this->getCacheTagsForContentInfo($group->contentInfo)
160
        );
161
    }
162
163 View Code Duplication
    public function loadUserGroupsAssignedToRole($roleId)
164
    {
165
        $groups = $this->innerController->loadUserGroupsAssignedToRole($roleId);
166
167
        $tags = [];
168
        foreach ($groups->userGroups as $userGroup) {
169
            $tags = array_merge_recursive(
170
                $tags,
171
                $this->getCacheTagsForContentInfo($userGroup->contentInfo)
172
            );
173
        }
174
175
        return new CachedValue($groups, $tags);
176
    }
177
178 View Code Duplication
    public function loadUserDrafts($userId, Request $request)
179
    {
180
        $versionsList = $this->innerController->loadUserDrafts($userId, $request);
181
182
        $tags = [];
183
        foreach ($versionsList->versions as $versionInfo) {
184
            $tags = array_merge_recursive(
185
                $tags,
186
                $this->getCacheTagsForContentInfo($versionInfo->contentInfo)
187
            );
188
        }
189
190
        return new CachedValue($versionsList, $tags);
191
    }
192
193
    public function moveUserGroup($groupPath, Request $request)
194
    {
195
        return $this->innerController->moveUserGroup($groupPath, $request);
196
    }
197
198 View Code Duplication
    public function loadSubUserGroups($groupPath, Request $request)
199
    {
200
        $userGroups = $this->innerController->loadSubUserGroups($groupPath, $request);
201
202
        $tags = [];
203
        foreach ($userGroups->userGroups as $userGroup) {
0 ignored issues
show
Bug introduced by
The property userGroups does not seem to exist in eZ\Publish\Core\REST\Server\Values\CachedValue.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
204
            $tags = array_merge_recursive(
205
                $tags,
206
                $this->getCacheTagsForContentInfo($userGroup->contentInfo)
207
            );
208
        }
209
210
        return new CachedValue($userGroups, $tags);
211
    }
212
213 View Code Duplication
    public function loadUserGroupsOfUser($userId, Request $request)
214
    {
215
        $userGroups = $this->innerController->loadUserGroupsOfUser($userId, $request);
216
217
        $tags = [];
218
        foreach ($userGroups->userGroups as $userGroup) {
0 ignored issues
show
Bug introduced by
The property userGroups does not seem to exist in eZ\Publish\Core\REST\Server\Values\CachedValue.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
219
            $tags = array_merge_recursive(
220
                $tags,
221
                $this->getCacheTagsForContentInfo($userGroup->contentInfo)
222
            );
223
        }
224
225
        return new CachedValue($userGroups, $tags);
226
    }
227
228 View Code Duplication
    public function loadUsersFromGroup($groupPath, Request $request)
229
    {
230
        $users = $this->innerController->loadUsersFromGroup($groupPath, $request);
231
232
        $tags = [];
233
        foreach ($users->users as $user) {
0 ignored issues
show
Bug introduced by
The property users does not seem to exist in eZ\Publish\Core\REST\Server\Values\CachedValue.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
234
            $tags = array_merge_recursive(
235
                $tags,
236
                $this->getCacheTagsForContentInfo($user->contentInfo)
237
            );
238
        }
239
240
        return new CachedValue($users, $tags);
241
242
    }
243
244
    public function unassignUserFromUserGroup($userId, $groupPath)
245
    {
246
        return $this->innerController->unassignUserFromUserGroup($userId, $groupPath);
247
    }
248
249
    public function assignUserToUserGroup($userId, Request $request)
250
    {
251
        return $this->innerController->assignUserToUserGroup($userId, $request);
252
    }
253
254
    public function createSession(Request $request)
255
    {
256
        return $this->innerController->createSession($request);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\REST\Ser...r\User::createSession() has been deprecated with message: Deprecated since 6.5. Use SessionController::refreshSessionAction().

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...
257
    }
258
259
    public function refreshSession($sessionId, Request $request)
260
    {
261
        return $this->innerController->refreshSession($sessionId, $request);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\REST\Ser...\User::refreshSession() has been deprecated with message: Deprecated since 6.5. Use SessionController::refreshSessionAction().

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...
262
    }
263
264
    public function deleteSession($sessionId, Request $request)
265
    {
266
        return $this->innerController->deleteSession($sessionId, $request);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\Core\REST\Ser...r\User::deleteSession() has been deprecated with message: Deprecated since 6.5. Use SessionController::refreshSessionAction().

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...
267
    }
268
}
269