Completed
Push — ezp-30616-follow-up ( 2e0607...b74676 )
by
unknown
35:08 queued 20:12
created

Repository::sudo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace eZ\Publish\Core\Event;
4
5
use eZ\Publish\API\Repository\BookmarkService as BookmarkServiceInterface;
6
use eZ\Publish\API\Repository\ContentService as ContentServiceInterface;
7
use eZ\Publish\API\Repository\ContentTypeService as ContentTypeServiceInterface;
8
use eZ\Publish\API\Repository\FieldTypeService as FieldTypeServiceInterface;
9
use eZ\Publish\API\Repository\LanguageService as LanguageServiceInterface;
10
use eZ\Publish\API\Repository\LocationService as LocationServiceInterface;
11
use eZ\Publish\API\Repository\NotificationService as NotificationServiceInterface;
12
use eZ\Publish\API\Repository\ObjectStateService as ObjectStateServiceInterface;
13
use eZ\Publish\API\Repository\PermissionResolver;
14
use eZ\Publish\API\Repository\Repository as RepositoryInterface;
15
use eZ\Publish\API\Repository\RoleService as RoleServiceInterface;
16
use eZ\Publish\API\Repository\SearchService as SearchServiceInterface;
17
use eZ\Publish\API\Repository\SectionService as SectionServiceInterface;
18
use eZ\Publish\API\Repository\TrashService as TrashServiceInterface;
19
use eZ\Publish\API\Repository\URLAliasService as URLAliasServiceInterface;
20
use eZ\Publish\API\Repository\URLService as URLServiceInterface;
21
use eZ\Publish\API\Repository\URLWildcardService as URLWildcardServiceInterface;
22
use eZ\Publish\API\Repository\UserPreferenceService as UserPreferenceServiceInterface;
23
use eZ\Publish\API\Repository\UserService as UserServiceInterface;
24
use eZ\Publish\API\Repository\Values\User\User;
25
use eZ\Publish\API\Repository\Values\User\UserReference;
26
use eZ\Publish\API\Repository\Values\ValueObject;
27
28
final class Repository implements RepositoryInterface
29
{
30
    /** @var \eZ\Publish\API\Repository\Repository */
31
    private $repository;
32
33
    /** @var \eZ\Publish\API\Repository\BookmarkService */
34
    private $bookmarkService;
35
36
    /** @var \eZ\Publish\API\Repository\ContentService */
37
    private $contentService;
38
39
    /** @var \eZ\Publish\API\Repository\ContentTypeService */
40
    private $contentTypeService;
41
42
    /** @var \eZ\Publish\API\Repository\FieldTypeService */
43
    private $fieldTypeService;
44
45
    /** @var \eZ\Publish\API\Repository\LanguageService */
46
    private $languageService;
47
48
    /** @var \eZ\Publish\API\Repository\LocationService */
49
    private $locationService;
50
51
    /** @var \eZ\Publish\API\Repository\NotificationService */
52
    private $notificationService;
53
54
    /** @var \eZ\Publish\API\Repository\ObjectStateService */
55
    private $objectStateService;
56
57
    /** @var \eZ\Publish\API\Repository\RoleService */
58
    private $roleService;
59
60
    /** @var \eZ\Publish\API\Repository\SearchService */
61
    private $searchService;
62
63
    /** @var \eZ\Publish\API\Repository\SectionService */
64
    private $sectionService;
65
66
    /** @var \eZ\Publish\API\Repository\TrashService */
67
    private $trashService;
68
69
    /** @var \eZ\Publish\API\Repository\URLAliasService */
70
    private $urlAliasService;
71
72
    /** @var \eZ\Publish\API\Repository\URLService */
73
    private $urlService;
74
75
    /** @var \eZ\Publish\API\Repository\URLWildcardService */
76
    private $urlWildcardService;
77
78
    /** @var \eZ\Publish\API\Repository\UserPreferenceService */
79
    private $userPreferenceService;
80
81
    /** @var \eZ\Publish\API\Repository\UserService */
82
    private $userService;
83
84 View Code Duplication
    public function __construct(
85
        RepositoryInterface $repository,
86
        BookmarkServiceInterface $bookmarkService,
87
        ContentServiceInterface $contentService,
88
        ContentTypeServiceInterface $contentTypeService,
89
        FieldTypeServiceInterface $fieldTypeService,
90
        LanguageServiceInterface $languageService,
91
        LocationServiceInterface $locationService,
92
        NotificationServiceInterface $notificationService,
93
        ObjectStateServiceInterface $objectStateService,
94
        RoleServiceInterface $roleService,
95
        SearchServiceInterface $searchService,
96
        SectionServiceInterface $sectionService,
97
        TrashServiceInterface $trashService,
98
        URLAliasServiceInterface $urlAliasService,
99
        URLServiceInterface $urlService,
100
        URLWildcardServiceInterface $urlWildcardService,
101
        UserPreferenceServiceInterface $userPreferenceService,
102
        UserServiceInterface $userService
103
    ) {
104
        $this->repository = $repository;
105
        $this->bookmarkService = $bookmarkService;
106
        $this->contentService = $contentService;
107
        $this->contentTypeService = $contentTypeService;
108
        $this->fieldTypeService = $fieldTypeService;
109
        $this->languageService = $languageService;
110
        $this->locationService = $locationService;
111
        $this->notificationService = $notificationService;
112
        $this->objectStateService = $objectStateService;
113
        $this->roleService = $roleService;
114
        $this->searchService = $searchService;
115
        $this->sectionService = $sectionService;
116
        $this->trashService = $trashService;
117
        $this->urlAliasService = $urlAliasService;
118
        $this->urlService = $urlService;
119
        $this->urlWildcardService = $urlWildcardService;
120
        $this->userPreferenceService = $userPreferenceService;
121
        $this->userService = $userService;
122
    }
123
124
    public function getCurrentUser(): User
125
    {
126
        return $this->repository->getCurrentUser();
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repositor...itory::getCurrentUser() has been deprecated with message: since 6.6, to be removed. Use PermissionResolver::getCurrentUserReference() instead. Get current user. Loads the full user object if not already loaded, if you only need to know user id use {@see getCurrentUserReference()}

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...
127
    }
128
129
    public function getCurrentUserReference(): UserReference
130
    {
131
        return $this->repository->getCurrentUserReference();
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repositor...tCurrentUserReference() has been deprecated with message: since 6.6, to be removed. Use PermissionResolver::getCurrentUserReference() instead. Get current user reference.

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...
132
    }
133
134
    public function setCurrentUser(UserReference $user): void
135
    {
136
        $this->repository->setCurrentUser($user);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repositor...itory::setCurrentUser() has been deprecated with message: since 6.6, to be removed. Use PermissionResolver::setCurrentUserReference() instead. Sets the current user to the given $user.

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...
137
    }
138
139
    public function hasAccess($module, $function, UserReference $user = null)
140
    {
141
        return $this->repository->hasAccess($module, $function, $user);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repository\Repository::hasAccess() has been deprecated with message: since 6.6, to be removed. Use PermissionResolver::hasAccess() instead.

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...
142
    }
143
144
    public function canUser($module, $function, ValueObject $object, $targets = null): bool
145
    {
146
        return $this->repository->canUser($module, $function, $object, $targets);
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repository\Repository::canUser() has been deprecated with message: since 6.6, to be removed. Use PermissionResolver::canUser() instead. Indicates if the current user is allowed to perform an action given by the function on the given
objects. Example: canUser( 'content', 'edit', $content, $location ); This will check edit permission on content given the specific location, if skipped if will check on all locations. Example2: canUser( 'section', 'assign', $content, $section ); Check if user has access to assign $content to $section.

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...
147
    }
148
149
    public function sudo(callable $callback, RepositoryInterface $outerRepository = null)
150
    {
151
        return $this->repository->sudo($callback, $outerRepository);
152
    }
153
154
    public function beginTransaction(): void
155
    {
156
        $this->repository->beginTransaction();
157
    }
158
159
    public function commit(): void
160
    {
161
        $this->repository->commit();
162
    }
163
164
    public function rollback(): void
165
    {
166
        $this->repository->rollback();
167
    }
168
169
    public function getPermissionResolver(): PermissionResolver
170
    {
171
        return $this->repository->getPermissionResolver();
172
    }
173
174
    public function getBookmarkService(): BookmarkServiceInterface
175
    {
176
        return $this->bookmarkService;
177
    }
178
179
    public function getContentService(): ContentServiceInterface
180
    {
181
        return $this->contentService;
182
    }
183
184
    public function getContentTypeService(): ContentTypeServiceInterface
185
    {
186
        return $this->contentTypeService;
187
    }
188
189
    public function getFieldTypeService(): FieldTypeServiceInterface
190
    {
191
        return $this->fieldTypeService;
192
    }
193
194
    public function getContentLanguageService(): LanguageServiceInterface
195
    {
196
        return $this->languageService;
197
    }
198
199
    public function getLocationService(): LocationServiceInterface
200
    {
201
        return $this->locationService;
202
    }
203
204
    public function getNotificationService(): NotificationServiceInterface
205
    {
206
        return $this->notificationService;
207
    }
208
209
    public function getObjectStateService(): ObjectStateServiceInterface
210
    {
211
        return $this->objectStateService;
212
    }
213
214
    public function getRoleService(): RoleServiceInterface
215
    {
216
        return $this->roleService;
217
    }
218
219
    public function getSearchService(): SearchServiceInterface
220
    {
221
        return $this->searchService;
222
    }
223
224
    public function getSectionService(): SectionServiceInterface
225
    {
226
        return $this->sectionService;
227
    }
228
229
    public function getTrashService(): TrashServiceInterface
230
    {
231
        return $this->trashService;
232
    }
233
234
    public function getURLAliasService(): URLAliasServiceInterface
235
    {
236
        return $this->urlAliasService;
237
    }
238
239
    public function getURLService(): URLServiceInterface
240
    {
241
        return $this->urlService;
242
    }
243
244
    public function getURLWildcardService(): URLWildcardServiceInterface
245
    {
246
        return $this->urlWildcardService;
247
    }
248
249
    public function getUserPreferenceService(): UserPreferenceServiceInterface
250
    {
251
        return $this->userPreferenceService;
252
    }
253
254
    public function getUserService(): UserServiceInterface
255
    {
256
        return $this->userService;
257
    }
258
}
259