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\User\UserGroup as APIUserGroup; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This class represents a user group. |
15
|
|
|
* |
16
|
|
|
* @internal Meant for internal use by Repository, type hint against API object instead. |
17
|
|
|
*/ |
18
|
|
|
class UserGroup extends APIUserGroup |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Internal content representation. |
22
|
|
|
* |
23
|
|
|
* @var \eZ\Publish\API\Repository\Values\Content\Content |
24
|
|
|
*/ |
25
|
|
|
protected $content; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Returns the VersionInfo for this version. |
29
|
|
|
* |
30
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
31
|
|
|
*/ |
32
|
|
|
public function getVersionInfo() |
33
|
|
|
{ |
34
|
|
|
return $this->content->getVersionInfo(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns a field value for the given value |
39
|
|
|
* $version->fields[$fieldDefId][$languageCode] is an equivalent call |
40
|
|
|
* if no language is given on a translatable field this method returns |
41
|
|
|
* the value of the initial language of the version if present, otherwise null. |
42
|
|
|
* On non translatable fields this method ignores the languageCode parameter. |
43
|
|
|
* |
44
|
|
|
* @param string $fieldDefIdentifier |
45
|
|
|
* @param string $languageCode |
46
|
|
|
* |
47
|
|
|
* @return mixed a primitive type or a field type Value object depending on the field type. |
48
|
|
|
*/ |
49
|
|
|
public function getFieldValue($fieldDefIdentifier, $languageCode = null) |
50
|
|
|
{ |
51
|
|
|
return $this->content->getFieldValue($fieldDefIdentifier, $languageCode); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* This method returns the complete fields collection. |
56
|
|
|
* |
57
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field[] |
58
|
|
|
*/ |
59
|
|
|
public function getFields() |
60
|
|
|
{ |
61
|
|
|
return $this->content->getFields(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* This method returns the fields for a given language and non translatable fields. |
66
|
|
|
* |
67
|
|
|
* If note set the initialLanguage of the content version is used. |
68
|
|
|
* |
69
|
|
|
* @param string $languageCode |
70
|
|
|
* |
71
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field[] with field identifier as keys |
72
|
|
|
*/ |
73
|
|
|
public function getFieldsByLanguage($languageCode = null) |
74
|
|
|
{ |
75
|
|
|
return $this->content->getFieldsByLanguage($languageCode); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* This method returns the field for a given field definition identifier and language. |
80
|
|
|
* |
81
|
|
|
* If not set the initialLanguage of the content version is used. |
82
|
|
|
* |
83
|
|
|
* @param string $fieldDefIdentifier |
84
|
|
|
* @param string|null $languageCode |
85
|
|
|
* |
86
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\Field|null A {@link Field} or null if nothing is found |
87
|
|
|
*/ |
88
|
|
|
public function getField($fieldDefIdentifier, $languageCode = null) |
89
|
|
|
{ |
90
|
|
|
return $this->content->getField($fieldDefIdentifier, $languageCode); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Function where list of properties are returned. |
95
|
|
|
* |
96
|
|
|
* Override to add dynamic properties |
97
|
|
|
* |
98
|
|
|
* @uses \parent::getProperties() |
99
|
|
|
* |
100
|
|
|
* @param array $dynamicProperties |
101
|
|
|
* |
102
|
|
|
* @return array |
103
|
|
|
*/ |
104
|
|
|
protected function getProperties($dynamicProperties = array('id', 'contentInfo')) |
105
|
|
|
{ |
106
|
|
|
return parent::getProperties($dynamicProperties); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Magic getter for retrieving convenience properties. |
111
|
|
|
* |
112
|
|
|
* @param string $property The name of the property to retrieve |
113
|
|
|
* |
114
|
|
|
* @return mixed |
115
|
|
|
*/ |
116
|
|
View Code Duplication |
public function __get($property) |
117
|
|
|
{ |
118
|
|
|
switch ($property) { |
119
|
|
|
case 'contentInfo': |
120
|
|
|
return $this->getVersionInfo()->getContentInfo(); |
121
|
|
|
|
122
|
|
|
case 'id': |
123
|
|
|
$versionInfo = $this->getVersionInfo(); |
124
|
|
|
if (empty($versionInfo)) { |
125
|
|
|
return null; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
return $versionInfo->getContentInfo()->id; |
129
|
|
|
|
130
|
|
|
case 'versionInfo': |
131
|
|
|
return $this->getVersionInfo(); |
132
|
|
|
|
133
|
|
|
case 'fields': |
134
|
|
|
return $this->getFields(); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return parent::__get($property); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Magic isset for signaling existence of convenience properties. |
142
|
|
|
* |
143
|
|
|
* @param string $property |
144
|
|
|
* |
145
|
|
|
* @return bool |
146
|
|
|
*/ |
147
|
|
View Code Duplication |
public function __isset($property) |
148
|
|
|
{ |
149
|
|
|
if ($property === 'contentInfo') { |
150
|
|
|
return true; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
if ($property === 'id') { |
154
|
|
|
return true; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
if ($property === 'versionInfo') { |
158
|
|
|
return true; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
if ($property === 'fields') { |
162
|
|
|
return true; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
return parent::__isset($property); |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|