1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
namespace eZ\Publish\Core\SignalSlot; |
8
|
|
|
|
9
|
|
|
use eZ\Publish\API\Repository\BookmarkService; |
|
|
|
|
10
|
|
|
use eZ\Publish\API\Repository\Repository as RepositoryInterface; |
11
|
|
|
use eZ\Publish\API\Repository\Values\ValueObject; |
12
|
|
|
use eZ\Publish\API\Repository\Values\User\UserReference; |
13
|
|
|
use eZ\Publish\SPI\Persistence\TransactionHandler; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Repository class. |
17
|
|
|
*/ |
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( |
177
|
|
|
RepositoryInterface $repository, |
178
|
|
|
SignalDispatcher $signalDispatcher, |
179
|
|
|
ContentService $contentService, |
180
|
|
|
ContentTypeService $contentTypeService, |
181
|
|
|
FieldTypeService $fieldTypeService, |
182
|
|
|
RoleService $roleService, |
183
|
|
|
ObjectStateService $objectStateService, |
184
|
|
|
URLWildcardService $urlWildcardService, |
185
|
|
|
URLAliasService $urlAliasService, |
186
|
|
|
UserService $userService, |
187
|
|
|
SearchService $searchService, |
188
|
|
|
SectionService $sectionService, |
189
|
|
|
TrashService $trashService, |
190
|
|
|
LocationService $locationService, |
191
|
|
|
LanguageService $languageService, |
192
|
|
|
URLService $urlService, |
193
|
|
|
BookmarkService $bookmarkService, |
194
|
|
|
NotificationService $notificationService, |
195
|
|
|
UserPreferenceService $userPreferenceService |
196
|
|
|
) { |
197
|
|
|
$this->signalDispatcher = $signalDispatcher; |
198
|
|
|
$this->repository = $repository; |
199
|
|
|
$this->contentService = $contentService; |
200
|
|
|
$this->contentTypeService = $contentTypeService; |
201
|
|
|
$this->fieldTypeService = $fieldTypeService; |
202
|
|
|
$this->roleService = $roleService; |
203
|
|
|
$this->objectStateService = $objectStateService; |
204
|
|
|
$this->urlWildcardService = $urlWildcardService; |
|
|
|
|
205
|
|
|
$this->urlAliasService = $urlAliasService; |
|
|
|
|
206
|
|
|
$this->userService = $userService; |
207
|
|
|
$this->searchService = $searchService; |
208
|
|
|
$this->sectionService = $sectionService; |
209
|
|
|
$this->trashService = $trashService; |
210
|
|
|
$this->locationService = $locationService; |
211
|
|
|
$this->languageService = $languageService; |
212
|
|
|
$this->urlService = $urlService; |
213
|
|
|
$this->bookmarkService = $bookmarkService; |
214
|
|
|
$this->notificationService = $notificationService; |
215
|
|
|
$this->userPreferenceService = $userPreferenceService; |
216
|
|
|
} |
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() |
226
|
|
|
{ |
227
|
|
|
return $this->repository->getCurrentUser(); |
|
|
|
|
228
|
|
|
} |
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() |
238
|
|
|
{ |
239
|
|
|
return $this->repository->getCurrentUserReference(); |
|
|
|
|
240
|
|
|
} |
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) |
250
|
|
|
{ |
251
|
|
|
return $this->repository->setCurrentUser($user); |
|
|
|
|
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* {@inheritdoc} |
256
|
|
|
*/ |
257
|
|
|
public function sudo(callable $callback, RepositoryInterface $outerRepository = null) |
258
|
|
|
{ |
259
|
|
|
return $this->repository->sudo($callback, $outerRepository ?? $this); |
260
|
|
|
} |
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) |
276
|
|
|
{ |
277
|
|
|
return $this->repository->hasAccess($module, $function, $user); |
|
|
|
|
278
|
|
|
} |
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) |
299
|
|
|
{ |
300
|
|
|
return $this->repository->canUser($module, $function, $object, $targets); |
|
|
|
|
301
|
|
|
} |
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() |
311
|
|
|
{ |
312
|
|
|
return $this->contentService; |
313
|
|
|
} |
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() |
323
|
|
|
{ |
324
|
|
|
return $this->languageService; |
325
|
|
|
} |
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() |
336
|
|
|
{ |
337
|
|
|
return $this->contentTypeService; |
338
|
|
|
} |
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() |
348
|
|
|
{ |
349
|
|
|
return $this->locationService; |
350
|
|
|
} |
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() |
361
|
|
|
{ |
362
|
|
|
return $this->trashService; |
363
|
|
|
} |
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() |
373
|
|
|
{ |
374
|
|
|
return $this->sectionService; |
375
|
|
|
} |
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() |
385
|
|
|
{ |
386
|
|
|
return $this->userService; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Get URLAliasService. |
391
|
|
|
* |
392
|
|
|
* @return \eZ\Publish\API\Repository\URLAliasService |
393
|
|
|
*/ |
394
|
|
|
public function getURLAliasService() |
395
|
|
|
{ |
396
|
|
|
return $this->urlAliasService; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* Get URLWildcardService. |
401
|
|
|
* |
402
|
|
|
* @return \eZ\Publish\API\Repository\URLWildcardService |
403
|
|
|
*/ |
404
|
|
|
public function getURLWildcardService() |
405
|
|
|
{ |
406
|
|
|
return $this->urlWildcardService; |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* Get URLService. |
411
|
|
|
* |
412
|
|
|
* @return \eZ\Publish\API\Repository\URLService |
413
|
|
|
*/ |
414
|
|
|
public function getURLService() |
415
|
|
|
{ |
416
|
|
|
return $this->urlService; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Get BookmarkService. |
421
|
|
|
* |
422
|
|
|
* @return \eZ\Publish\API\Repository\BookmarkService |
423
|
|
|
*/ |
424
|
|
|
public function getBookmarkService() |
425
|
|
|
{ |
426
|
|
|
return $this->bookmarkService; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Get NotificationService. |
431
|
|
|
* |
432
|
|
|
* @return \eZ\Publish\API\Repository\NotificationService |
433
|
|
|
*/ |
434
|
|
|
public function getNotificationService() |
435
|
|
|
{ |
436
|
|
|
return $this->notificationService; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
/** |
440
|
|
|
* Get UserPreferenceService. |
441
|
|
|
* |
442
|
|
|
* @return \eZ\Publish\API\Repository\UserPreferenceService |
443
|
|
|
*/ |
444
|
|
|
public function getUserPreferenceService() |
445
|
|
|
{ |
446
|
|
|
return $this->userPreferenceService; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* Get ObjectStateService. |
451
|
|
|
* |
452
|
|
|
* @return \eZ\Publish\API\Repository\ObjectStateService |
453
|
|
|
*/ |
454
|
|
|
public function getObjectStateService() |
455
|
|
|
{ |
456
|
|
|
return $this->objectStateService; |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* Get RoleService. |
461
|
|
|
* |
462
|
|
|
* @return \eZ\Publish\API\Repository\RoleService |
463
|
|
|
*/ |
464
|
|
|
public function getRoleService() |
465
|
|
|
{ |
466
|
|
|
return $this->roleService; |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* Get SearchService. |
471
|
|
|
* |
472
|
|
|
* @return \eZ\Publish\API\Repository\SearchService |
473
|
|
|
*/ |
474
|
|
|
public function getSearchService() |
475
|
|
|
{ |
476
|
|
|
return $this->searchService; |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
/** |
480
|
|
|
* Get FieldTypeService. |
481
|
|
|
* |
482
|
|
|
* @return \eZ\Publish\API\Repository\FieldTypeService |
483
|
|
|
*/ |
484
|
|
|
public function getFieldTypeService() |
485
|
|
|
{ |
486
|
|
|
return $this->fieldTypeService; |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Get PermissionResolver. |
491
|
|
|
* |
492
|
|
|
* @return \eZ\Publish\API\Repository\PermissionResolver |
493
|
|
|
*/ |
494
|
|
|
public function getPermissionResolver() |
495
|
|
|
{ |
496
|
|
|
return $this->repository->getPermissionResolver(); |
497
|
|
|
} |
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() |
506
|
|
|
{ |
507
|
|
|
$return = $this->repository->beginTransaction(); |
508
|
|
|
|
509
|
|
|
if ($this->signalDispatcher instanceof TransactionHandler) { |
510
|
|
|
$this->signalDispatcher->beginTransaction(); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
return $return; |
514
|
|
|
} |
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() |
524
|
|
|
{ |
525
|
|
|
$return = $this->repository->commit(); |
526
|
|
|
|
527
|
|
|
if ($this->signalDispatcher instanceof TransactionHandler) { |
528
|
|
|
$this->signalDispatcher->commit(); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
return $return; |
532
|
|
|
} |
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() |
542
|
|
|
{ |
543
|
|
|
if ($this->signalDispatcher instanceof TransactionHandler) { |
544
|
|
|
$this->signalDispatcher->rollback(); |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
return $this->repository->rollback(); |
548
|
|
|
} |
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: