Completed
Push — api_content_name_shorthand ( 929e38...fc49b1 )
by André
20:47
created

User::getVersionInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the User 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
10
namespace eZ\Publish\Core\REST\Client\Values\User;
11
12
use eZ\Publish\API\Repository\Values\User\User as APIUser;
13
14
/**
15
 * Implementation of the {@link \eZ\Publish\API\Repository\Values\User\User}
16
 * class.
17
 *
18
 * @see \eZ\Publish\API\Repository\Values\User\User
19
 */
20
class User extends APIUser
21
{
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
    public function __get($property)
94
    {
95
        switch ($property) {
96
            case 'contentInfo':
97
                return $this->content->contentInfo;
98
99
            case 'id':
100
                return $this->content->id;
101
102
            case 'versionInfo':
103
                return $this->getVersionInfo();
104
105
            case 'fields':
106
                return $this->getFields();
107
        }
108
109
        return parent::__get($property);
110
    }
111
}
112