1 | <?php |
||
18 | class Repository implements RepositoryInterface |
||
19 | { |
||
20 | /** |
||
21 | * Repository Handler object. |
||
22 | * |
||
23 | * @var \eZ\Publish\API\Repository\Repository |
||
24 | */ |
||
25 | protected $repository; |
||
26 | |||
27 | /** |
||
28 | * SignalDispatcher. |
||
29 | * |
||
30 | * @var \eZ\Publish\Core\SignalSlot\SignalDispatcher |
||
31 | */ |
||
32 | protected $signalDispatcher; |
||
33 | |||
34 | /** |
||
35 | * Instance of content service. |
||
36 | * |
||
37 | * @var \eZ\Publish\API\Repository\ContentService |
||
38 | */ |
||
39 | protected $contentService; |
||
40 | |||
41 | /** |
||
42 | * Instance of section service. |
||
43 | * |
||
44 | * @var \eZ\Publish\API\Repository\SectionService |
||
45 | */ |
||
46 | protected $sectionService; |
||
47 | |||
48 | /** |
||
49 | * Instance of role service. |
||
50 | * |
||
51 | * @var \eZ\Publish\API\Repository\RoleService |
||
52 | */ |
||
53 | protected $roleService; |
||
54 | |||
55 | /** |
||
56 | * Instance of search service. |
||
57 | * |
||
58 | * @var \eZ\Publish\API\Repository\SearchService |
||
59 | */ |
||
60 | protected $searchService; |
||
61 | |||
62 | /** |
||
63 | * Instance of user service. |
||
64 | * |
||
65 | * @var \eZ\Publish\API\Repository\UserService |
||
66 | */ |
||
67 | protected $userService; |
||
68 | |||
69 | /** |
||
70 | * Instance of language service. |
||
71 | * |
||
72 | * @var \eZ\Publish\API\Repository\LanguageService |
||
73 | */ |
||
74 | protected $languageService; |
||
75 | |||
76 | /** |
||
77 | * Instance of location service. |
||
78 | * |
||
79 | * @var \eZ\Publish\API\Repository\LocationService |
||
80 | */ |
||
81 | protected $locationService; |
||
82 | |||
83 | /** |
||
84 | * Instance of Trash service. |
||
85 | * |
||
86 | * @var \eZ\Publish\API\Repository\TrashService |
||
87 | */ |
||
88 | protected $trashService; |
||
89 | |||
90 | /** |
||
91 | * Instance of content type service. |
||
92 | * |
||
93 | * @var \eZ\Publish\API\Repository\ContentTypeService |
||
94 | */ |
||
95 | protected $contentTypeService; |
||
96 | |||
97 | /** |
||
98 | * Instance of object state service. |
||
99 | * |
||
100 | * @var \eZ\Publish\API\Repository\ObjectStateService |
||
101 | */ |
||
102 | protected $objectStateService; |
||
103 | |||
104 | /** |
||
105 | * Instance of field type service. |
||
106 | * |
||
107 | * @var \eZ\Publish\API\Repository\FieldTypeService |
||
108 | */ |
||
109 | protected $fieldTypeService; |
||
110 | |||
111 | /** |
||
112 | * Instance of URL alias service. |
||
113 | * |
||
114 | * @var \eZ\Publish\Core\Repository\URLAliasService |
||
115 | */ |
||
116 | protected $urlAliasService; |
||
117 | |||
118 | /** |
||
119 | * Instance of URL wildcard service. |
||
120 | * |
||
121 | * @var \eZ\Publish\Core\Repository\URLWildcardService |
||
122 | */ |
||
123 | protected $urlWildcardService; |
||
124 | |||
125 | /** |
||
126 | * Instance of URL service. |
||
127 | * |
||
128 | * @var \eZ\Publish\API\Repository\URLService |
||
129 | */ |
||
130 | protected $urlService; |
||
131 | |||
132 | /** |
||
133 | * Instance of Bookmark service. |
||
134 | * |
||
135 | * @var \eZ\Publish\API\Repository\BookmarkService |
||
136 | */ |
||
137 | protected $bookmarkService; |
||
138 | |||
139 | /** |
||
140 | * Instance of Notification service. |
||
141 | * |
||
142 | * @var \eZ\Publish\API\Repository\NotificationService |
||
143 | */ |
||
144 | protected $notificationService; |
||
145 | |||
146 | /** |
||
147 | * Instance of UserPreference service. |
||
148 | * |
||
149 | * @var \eZ\Publish\API\Repository\UserPreferenceService |
||
150 | */ |
||
151 | protected $userPreferenceService; |
||
152 | |||
153 | /** |
||
154 | * Construct repository object from aggregated repository and signal dispatcher. |
||
155 | * |
||
156 | * @param \eZ\Publish\API\Repository\Repository $repository |
||
157 | * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher |
||
158 | * @param \eZ\Publish\Core\SignalSlot\ContentService $contentService |
||
159 | * @param \eZ\Publish\Core\SignalSlot\ContentTypeService $contentTypeService |
||
160 | * @param \eZ\Publish\Core\SignalSlot\FieldTypeService $fieldTypeService |
||
161 | * @param \eZ\Publish\Core\SignalSlot\RoleService $roleService |
||
162 | * @param \eZ\Publish\Core\SignalSlot\ObjectStateService $objectStateService |
||
163 | * @param \eZ\Publish\Core\SignalSlot\URLWildcardService $urlWildcardService |
||
164 | * @param \eZ\Publish\Core\SignalSlot\URLAliasService $urlAliasService |
||
165 | * @param \eZ\Publish\Core\SignalSlot\UserService $userService |
||
166 | * @param \eZ\Publish\Core\SignalSlot\SearchService $searchService |
||
167 | * @param \eZ\Publish\Core\SignalSlot\SectionService $sectionService |
||
168 | * @param \eZ\Publish\Core\SignalSlot\TrashService $trashService |
||
169 | * @param \eZ\Publish\Core\SignalSlot\LocationService $locationService |
||
170 | * @param \eZ\Publish\Core\SignalSlot\LanguageService $languageService |
||
171 | * @param \eZ\Publish\Core\SignalSlot\URLService $urlService |
||
172 | * @param \eZ\Publish\Core\SignalSlot\BookmarkService $bookmarkService |
||
173 | * @param \eZ\Publish\API\Repository\NotificationService $notificationService |
||
174 | * @param \eZ\Publish\Core\SignalSlot\UserPreferenceService $userPreferenceService |
||
175 | */ |
||
176 | public function __construct( |
||
217 | |||
218 | /** |
||
219 | * @deprecated since 6.6, to be removed. Use PermissionResolver::getCurrentUserReference() instead. |
||
220 | * |
||
221 | * Get current user. |
||
222 | * |
||
223 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
224 | */ |
||
225 | public function getCurrentUser() |
||
229 | |||
230 | /** |
||
231 | * @deprecated since 6.6, to be removed. Use PermissionResolver::getCurrentUserReference() instead. |
||
232 | * |
||
233 | * Get current user ref. |
||
234 | * |
||
235 | * @return \eZ\Publish\API\Repository\Values\User\UserReference |
||
236 | */ |
||
237 | public function getCurrentUserReference() |
||
241 | |||
242 | /** |
||
243 | * @deprecated since 6.6, to be removed. Use PermissionResolver::setCurrentUserReference() instead. |
||
244 | * |
||
245 | * Sets the current user to the given $user. |
||
246 | * |
||
247 | * @param \eZ\Publish\API\Repository\Values\User\UserReference $user |
||
248 | */ |
||
249 | public function setCurrentUser(UserReference $user) |
||
253 | |||
254 | /** |
||
255 | * {@inheritdoc} |
||
256 | */ |
||
257 | public function sudo(callable $callback, RepositoryInterface $outerRepository = null) |
||
261 | |||
262 | /** |
||
263 | * @deprecated since 6.6, to be removed. Use PermissionResolver::hasAccess() instead. |
||
264 | * |
||
265 | * Check if user has access to a given module / function. |
||
266 | * |
||
267 | * Low level function, use canUser instead if you have objects to check against. |
||
268 | * |
||
269 | * @param string $module |
||
270 | * @param string $function |
||
271 | * @param \eZ\Publish\API\Repository\Values\User\UserReference $user |
||
272 | * |
||
273 | * @return bool|array Bool if user has full or no access, array if limitations if not |
||
274 | */ |
||
275 | public function hasAccess($module, $function, UserReference $user = null) |
||
279 | |||
280 | /** |
||
281 | * @deprecated since 6.6, to be removed. Use PermissionResolver::canUser() instead. |
||
282 | * |
||
283 | * Check if user has access to a given action on a given value object. |
||
284 | * |
||
285 | * Indicates if the current user is allowed to perform an action given by the function on the given |
||
286 | * objects. |
||
287 | * |
||
288 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If any of the arguments are invalid |
||
289 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If value of the LimitationValue is unsupported |
||
290 | * |
||
291 | * @param string $module The module, aka controller identifier to check permissions on |
||
292 | * @param string $function The function, aka the controller action to check permissions on |
||
293 | * @param \eZ\Publish\API\Repository\Values\ValueObject $object The object to check if the user has access to |
||
294 | * @param mixed $targets The location, parent or "assignment" value object, or an array of the same |
||
295 | * |
||
296 | * @return bool |
||
297 | */ |
||
298 | public function canUser($module, $function, ValueObject $object, $targets = null) |
||
302 | |||
303 | /** |
||
304 | * Get Content Service. |
||
305 | * |
||
306 | * Get service object to perform operations on Content objects and it's aggregate members. |
||
307 | * |
||
308 | * @return \eZ\Publish\API\Repository\ContentService |
||
309 | */ |
||
310 | public function getContentService() |
||
314 | |||
315 | /** |
||
316 | * Get Content Language Service. |
||
317 | * |
||
318 | * Get service object to perform operations on Content language objects |
||
319 | * |
||
320 | * @return \eZ\Publish\API\Repository\LanguageService |
||
321 | */ |
||
322 | public function getContentLanguageService() |
||
326 | |||
327 | /** |
||
328 | * Get Content Type Service. |
||
329 | * |
||
330 | * Get service object to perform operations on Content Type objects and it's aggregate members. |
||
331 | * ( Group, Field & FieldCategory ) |
||
332 | * |
||
333 | * @return \eZ\Publish\API\Repository\ContentTypeService |
||
334 | */ |
||
335 | public function getContentTypeService() |
||
339 | |||
340 | /** |
||
341 | * Get Content Location Service. |
||
342 | * |
||
343 | * Get service object to perform operations on Location objects and subtrees |
||
344 | * |
||
345 | * @return \eZ\Publish\API\Repository\LocationService |
||
346 | */ |
||
347 | public function getLocationService() |
||
351 | |||
352 | /** |
||
353 | * Get Content Trash service. |
||
354 | * |
||
355 | * Trash service allows to perform operations related to location trash |
||
356 | * (trash/untrash, load/list from trash...) |
||
357 | * |
||
358 | * @return \eZ\Publish\API\Repository\TrashService |
||
359 | */ |
||
360 | public function getTrashService() |
||
364 | |||
365 | /** |
||
366 | * Get Content Section Service. |
||
367 | * |
||
368 | * Get Section service that lets you manipulate section objects |
||
369 | * |
||
370 | * @return \eZ\Publish\API\Repository\SectionService |
||
371 | */ |
||
372 | public function getSectionService() |
||
376 | |||
377 | /** |
||
378 | * Get User Service. |
||
379 | * |
||
380 | * Get service object to perform operations on Users and UserGroup |
||
381 | * |
||
382 | * @return \eZ\Publish\API\Repository\UserService |
||
383 | */ |
||
384 | public function getUserService() |
||
388 | |||
389 | /** |
||
390 | * Get URLAliasService. |
||
391 | * |
||
392 | * @return \eZ\Publish\API\Repository\URLAliasService |
||
393 | */ |
||
394 | public function getURLAliasService() |
||
398 | |||
399 | /** |
||
400 | * Get URLWildcardService. |
||
401 | * |
||
402 | * @return \eZ\Publish\API\Repository\URLWildcardService |
||
403 | */ |
||
404 | public function getURLWildcardService() |
||
408 | |||
409 | /** |
||
410 | * Get URLService. |
||
411 | * |
||
412 | * @return \eZ\Publish\API\Repository\URLService |
||
413 | */ |
||
414 | public function getURLService() |
||
418 | |||
419 | /** |
||
420 | * Get BookmarkService. |
||
421 | * |
||
422 | * @return \eZ\Publish\API\Repository\BookmarkService |
||
423 | */ |
||
424 | public function getBookmarkService() |
||
428 | |||
429 | /** |
||
430 | * Get NotificationService. |
||
431 | * |
||
432 | * @return \eZ\Publish\API\Repository\NotificationService |
||
433 | */ |
||
434 | public function getNotificationService() |
||
438 | |||
439 | /** |
||
440 | * Get UserPreferenceService. |
||
441 | * |
||
442 | * @return \eZ\Publish\API\Repository\UserPreferenceService |
||
443 | */ |
||
444 | public function getUserPreferenceService() |
||
448 | |||
449 | /** |
||
450 | * Get ObjectStateService. |
||
451 | * |
||
452 | * @return \eZ\Publish\API\Repository\ObjectStateService |
||
453 | */ |
||
454 | public function getObjectStateService() |
||
458 | |||
459 | /** |
||
460 | * Get RoleService. |
||
461 | * |
||
462 | * @return \eZ\Publish\API\Repository\RoleService |
||
463 | */ |
||
464 | public function getRoleService() |
||
468 | |||
469 | /** |
||
470 | * Get SearchService. |
||
471 | * |
||
472 | * @return \eZ\Publish\API\Repository\SearchService |
||
473 | */ |
||
474 | public function getSearchService() |
||
478 | |||
479 | /** |
||
480 | * Get FieldTypeService. |
||
481 | * |
||
482 | * @return \eZ\Publish\API\Repository\FieldTypeService |
||
483 | */ |
||
484 | public function getFieldTypeService() |
||
488 | |||
489 | /** |
||
490 | * Get PermissionResolver. |
||
491 | * |
||
492 | * @return \eZ\Publish\API\Repository\PermissionResolver |
||
493 | */ |
||
494 | public function getPermissionResolver() |
||
498 | |||
499 | /** |
||
500 | * Begin transaction. |
||
501 | * |
||
502 | * Begins an transaction, make sure you'll call commit or rollback when done, |
||
503 | * otherwise work will be lost. |
||
504 | */ |
||
505 | public function beginTransaction() |
||
515 | |||
516 | /** |
||
517 | * Commit transaction. |
||
518 | * |
||
519 | * Commit transaction, or throw exceptions if no transactions has been started. |
||
520 | * |
||
521 | * @throws \RuntimeException If no transaction has been started |
||
522 | */ |
||
523 | public function commit() |
||
533 | |||
534 | /** |
||
535 | * Rollback transaction. |
||
536 | * |
||
537 | * Rollback transaction, or throw exceptions if no transactions has been started. |
||
538 | * |
||
539 | * @throws \RuntimeException If no transaction has been started |
||
540 | */ |
||
541 | public function rollback() |
||
549 | } |
||
550 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: