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\Repository\Permission; |
8
|
|
|
|
9
|
|
|
use eZ\Publish\API\Repository\Repository as RepositoryInterface; |
10
|
|
|
use eZ\Publish\API\Repository\Values\ValueObject; |
11
|
|
|
use eZ\Publish\API\Repository\Values\User\UserReference; |
12
|
|
|
|
13
|
|
|
class Repository implements RepositoryInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var \eZ\Publish\API\Repository\Repository |
17
|
|
|
*/ |
18
|
|
|
protected $innerRepository; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param \eZ\Publish\API\Repository\Repository $innerRepository |
22
|
|
|
*/ |
23
|
|
|
public function __construct(RepositoryInterface $innerRepository) |
24
|
|
|
{ |
25
|
|
|
$this->innerRepository = $innerRepository; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getCurrentUser() |
29
|
|
|
{ |
30
|
|
|
return $this->innerRepository->getCurrentUser(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function getCurrentUserReference() |
34
|
|
|
{ |
35
|
|
|
return $this->innerRepository->getCurrentUserReference(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function setCurrentUser(UserReference $user) |
39
|
|
|
{ |
40
|
|
|
return $this->innerRepository->setCurrentUser($user); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function sudo(\Closure $callback) |
44
|
|
|
{ |
45
|
|
|
return $this->innerRepository->sudo($callback, $this); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function hasAccess($module, $function, UserReference $user = null) |
49
|
|
|
{ |
50
|
|
|
return $this->innerRepository->hasAccess($module, $function, $user); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function canUser($module, $function, ValueObject $object, $targets = null) |
54
|
|
|
{ |
55
|
|
|
return $this->innerRepository->canUser($module, $function, $object, $targets); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getContentService() |
59
|
|
|
{ |
60
|
|
|
return $this->innerRepository->getContentService(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getContentLanguageService() |
64
|
|
|
{ |
65
|
|
|
return $this->innerRepository->getContentLanguageService(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getContentTypeService() |
69
|
|
|
{ |
70
|
|
|
return $this->innerRepository->getContentTypeService(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getLocationService() |
74
|
|
|
{ |
75
|
|
|
return $this->innerRepository->getLocationService(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getTrashService() |
79
|
|
|
{ |
80
|
|
|
return $this->innerRepository->getTrashService(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getSectionService() |
84
|
|
|
{ |
85
|
|
|
return $this->innerRepository->getSectionService(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getUserService() |
89
|
|
|
{ |
90
|
|
|
return $this->innerRepository->getUserService(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getURLAliasService() |
94
|
|
|
{ |
95
|
|
|
return $this->innerRepository->getURLAliasService(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function getURLWildcardService() |
99
|
|
|
{ |
100
|
|
|
return $this->innerRepository->getURLWildcardService(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function getObjectStateService() |
104
|
|
|
{ |
105
|
|
|
return $this->innerRepository->getObjectStateService(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getRoleService() |
109
|
|
|
{ |
110
|
|
|
return $this->innerRepository->getRoleService(); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function getSearchService() |
114
|
|
|
{ |
115
|
|
|
return $this->innerRepository->getSearchService(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function getFieldTypeService() |
119
|
|
|
{ |
120
|
|
|
return $this->innerRepository->getFieldTypeService(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function beginTransaction() |
124
|
|
|
{ |
125
|
|
|
return $this->innerRepository->beginTransaction(); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function commit() |
129
|
|
|
{ |
130
|
|
|
return $this->innerRepository->commit(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function rollback() |
134
|
|
|
{ |
135
|
|
|
return $this->innerRepository->rollback(); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function commitEvent($event) |
139
|
|
|
{ |
140
|
|
|
return $this->innerRepository->commitEvent($event); |
|
|
|
|
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function createDateTime($timestamp = null) |
144
|
|
|
{ |
145
|
|
|
return $this->innerRepository->createDateTime($timestamp); |
|
|
|
|
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: