1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the eZ\Publish\Core\Repository\Values\User\UserGroup class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\Repository\Values\User; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Values\Content\Thumbnail; |
12
|
|
|
use eZ\Publish\API\Repository\Values\User\UserGroup as APIUserGroup; |
13
|
|
|
use eZ\Publish\API\Repository\Values\ContentType\ContentType; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* This class represents a user group. |
17
|
|
|
* |
18
|
|
|
* @internal Meant for internal use by Repository, type hint against API object instead. |
19
|
|
|
*/ |
20
|
|
|
class UserGroup extends APIUserGroup |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Internal content representation. |
24
|
|
|
* |
25
|
|
|
* @var \eZ\Publish\API\Repository\Values\Content\Content |
26
|
|
|
*/ |
27
|
|
|
protected $content; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Returns the VersionInfo for this version. |
31
|
|
|
* |
32
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
33
|
|
|
*/ |
34
|
|
|
public function getVersionInfo() |
35
|
|
|
{ |
36
|
|
|
return $this->content->getVersionInfo(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function getContentType(): ContentType |
40
|
|
|
{ |
41
|
|
|
return $this->content->getContentType(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Returns a field value for the given value |
46
|
|
|
* $version->fields[$fieldDefId][$languageCode] is an equivalent call |
47
|
|
|
* if no language is given on a translatable field this method returns |
48
|
|
|
* the value of the initial language of the version if present, otherwise null. |
49
|
|
|
* On non translatable fields this method ignores the languageCode parameter. |
50
|
|
|
* |
51
|
|
|
* @param string $fieldDefIdentifier |
52
|
|
|
* @param string $languageCode |
53
|
|
|
* |
54
|
|
|
* @return mixed a primitive type or a field type Value object depending on the field type. |
55
|
|
|
*/ |
56
|
|
|
public function getFieldValue($fieldDefIdentifier, $languageCode = null) |
57
|
|
|
{ |
58
|
|
|
return $this->content->getFieldValue($fieldDefIdentifier, $languageCode); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* This method returns the complete fields collection. |
63
|
|
|
* |
64
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field[] |
65
|
|
|
*/ |
66
|
|
|
public function getFields() |
67
|
|
|
{ |
68
|
|
|
return $this->content->getFields(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* This method returns the fields for a given language and non translatable fields. |
73
|
|
|
* |
74
|
|
|
* If note set the initialLanguage of the content version is used. |
75
|
|
|
* |
76
|
|
|
* @param string $languageCode |
77
|
|
|
* |
78
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field[] with field identifier as keys |
79
|
|
|
*/ |
80
|
|
|
public function getFieldsByLanguage($languageCode = null) |
81
|
|
|
{ |
82
|
|
|
return $this->content->getFieldsByLanguage($languageCode); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* This method returns the field for a given field definition identifier and language. |
87
|
|
|
* |
88
|
|
|
* If not set the initialLanguage of the content version is used. |
89
|
|
|
* |
90
|
|
|
* @param string $fieldDefIdentifier |
91
|
|
|
* @param string|null $languageCode |
92
|
|
|
* |
93
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field|null A {@link Field} or null if nothing is found |
94
|
|
|
*/ |
95
|
|
|
public function getField($fieldDefIdentifier, $languageCode = null) |
96
|
|
|
{ |
97
|
|
|
return $this->content->getField($fieldDefIdentifier, $languageCode); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Function where list of properties are returned. |
102
|
|
|
* |
103
|
|
|
* Override to add dynamic properties |
104
|
|
|
* |
105
|
|
|
* @uses \parent::getProperties() |
106
|
|
|
* |
107
|
|
|
* @param array $dynamicProperties |
108
|
|
|
* |
109
|
|
|
* @return array |
110
|
|
|
*/ |
111
|
|
|
protected function getProperties($dynamicProperties = ['id', 'contentInfo', 'versionInfo', 'fields']) |
112
|
|
|
{ |
113
|
|
|
return parent::getProperties($dynamicProperties); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Magic getter for retrieving convenience properties. |
118
|
|
|
* |
119
|
|
|
* @param string $property The name of the property to retrieve |
120
|
|
|
* |
121
|
|
|
* @return mixed |
122
|
|
|
*/ |
123
|
|
|
public function __get($property) |
124
|
|
|
{ |
125
|
|
|
switch ($property) { |
126
|
|
|
case 'contentInfo': |
127
|
|
|
return $this->getVersionInfo()->getContentInfo(); |
128
|
|
|
|
129
|
|
|
case 'id': |
130
|
|
|
return $this->getVersionInfo()->getContentInfo()->id; |
131
|
|
|
|
132
|
|
|
case 'versionInfo': |
133
|
|
|
return $this->getVersionInfo(); |
134
|
|
|
|
135
|
|
|
case 'fields': |
136
|
|
|
return $this->getFields(); |
137
|
|
|
|
138
|
|
|
case 'thumbnail': |
139
|
|
|
return $this->getThumbnail(); |
140
|
|
|
|
141
|
|
|
case 'content': |
142
|
|
|
// trigger error for this, but for BC let it pass on to normal __get lookup for now |
143
|
|
|
@trigger_error( |
|
|
|
|
144
|
|
|
sprintf('%s is an internal property, usage is deprecated as of 6.10. User Group itself exposes everything needed.', $property), |
145
|
|
|
E_USER_DEPRECATED |
146
|
|
|
); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
return parent::__get($property); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Magic isset for signaling existence of convenience properties. |
154
|
|
|
* |
155
|
|
|
* @param string $property |
156
|
|
|
* |
157
|
|
|
* @return bool |
158
|
|
|
*/ |
159
|
|
|
public function __isset($property) |
160
|
|
|
{ |
161
|
|
|
if ($property === 'contentInfo') { |
162
|
|
|
return true; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
if ($property === 'id') { |
166
|
|
|
return true; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
if ($property === 'versionInfo') { |
170
|
|
|
return true; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
if ($property === 'fields') { |
174
|
|
|
return true; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
if ($property === 'thumbnail') { |
178
|
|
|
return true; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
return parent::__isset($property); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function getThumbnail(): ?Thumbnail |
185
|
|
|
{ |
186
|
|
|
return $this->content->getThumbnail(); |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: