Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Publish/Core/REST/Client/Values/Content/Content.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Client\Values\Content;
8
9 use eZ\Publish\API\Repository\ContentService;
10 use eZ\Publish\Core\Repository\Values\Content\Content as APIContent;
11
25 class Content extends APIContent
26 {
28 protected $fields;
29
31 protected $versionInfo;
32
34 private $internalFields;
35
37 protected $contentService;
38
45 public function __construct(ContentService $contentService, array $data = array())
46 {
47 $this->contentService = $contentService;
48 foreach ($data as $propertyName => $propertyValue) {
49 $this->$propertyName = $propertyValue;
50 }
51 foreach ($this->internalFields as $field) {
52 $this->fields[$field->fieldDefIdentifier][$field->languageCode] = $field;
53 }
54 }
55
61 public function getVersionInfo()
62 {
63 return $this->versionInfo;
64 }
65
78 public function getFieldValue($fieldDefIdentifier, $languageCode = null)
79 {
80 if (null === $languageCode) {
81 $languageCode = $this->versionInfo->contentInfo->mainLanguageCode;
82 }
83
84 if (isset($this->fields[$fieldDefIdentifier][$languageCode])) {
85 return $this->fields[$fieldDefIdentifier][$languageCode]->value;
86 }
87
88 return null;
89 }
90
96 public function getFields()
97 {
98 return $this->internalFields;
99 }
100
110 public function getFieldsByLanguage($languageCode = null)
111 {
112 $fields = array();
113
114 if (null === $languageCode) {
115 $languageCode = $this->versionInfo->contentInfo->mainLanguageCode;
116 }
117
118 foreach ($this->getFields() as $field) {
119 if ($field->languageCode === $languageCode) {
120 $fields[$field->fieldDefIdentifier] = $field;
121 }
122 }
123
124 return $fields;
125 }
126
137 public function getField($fieldDefIdentifier, $languageCode = null)
138 {
139 if (null === $languageCode) {
140 $languageCode = $this->versionInfo->contentInfo->mainLanguageCode;
141 }
142
143 if (isset($this->fields[$fieldDefIdentifier][$languageCode])) {
144 return $this->fields[$fieldDefIdentifier][$languageCode];
145 }
146
147 return null;
148 }
149 }
eZ\Publish\Core\REST\Client\Values\Content\Content
Definition: Publish/Core/REST/Client/Values/Content/Content.php:26
eZ\Publish\Core\REST\Client\Values\Content\Content\getField
getField($fieldDefIdentifier, $languageCode=null)
This method returns the field for a given field definition identifier and language.
Definition: Publish/Core/REST/Client/Values/Content/Content.php:137
eZ\Publish\Core\REST\Client\Values\Content\Content\__construct
__construct(ContentService $contentService, array $data=array())
Creates a new struct from the given $data array.
Definition: Publish/Core/REST/Client/Values/Content/Content.php:45
eZ\Publish\Core\REST\Client\Values\Content\Content\$contentService
$contentService
Definition: Publish/Core/REST/Client/Values/Content/Content.php:37
eZ\Publish\Core\REST\Client\Values\Content\Content\getFields
getFields()
This method returns the complete fields collection.
Definition: Publish/Core/REST/Client/Values/Content/Content.php:96
eZ\Publish\Core\REST\Client\Values\Content\Content\$fields
$fields
Definition: Publish/Core/REST/Client/Values/Content/Content.php:28
eZ\Publish\Core\REST\Client\Values\Content\Content\getVersionInfo
getVersionInfo()
Returns the VersionInfo for this version.
Definition: Publish/Core/REST/Client/Values/Content/Content.php:61
eZ\Publish\Core\REST\Client\Values\Content\Content\getFieldsByLanguage
getFieldsByLanguage($languageCode=null)
This method returns the fields for a given language and non translatable fields.
Definition: Publish/Core/REST/Client/Values/Content/Content.php:110
eZ\Publish\Core\REST\Client\Values\Content\Content\$versionInfo
$versionInfo
Definition: Publish/Core/REST/Client/Values/Content/Content.php:31
eZ\Publish\Core\REST\Client\Values\Content\Content\getFieldValue
getFieldValue($fieldDefIdentifier, $languageCode=null)
Returns a field value for the given value $version->fields[$fieldDefId][$languageCode] is an equivale...
Definition: Publish/Core/REST/Client/Values/Content/Content.php:78
eZ\Publish\Core\REST\Client\Values\Content\Content\$internalFields
$internalFields
Definition: Publish/Core/REST/Client/Values/Content/Content.php:34
eZ\Publish\Core\Repository\Values\Content\Content
Definition: Publish/Core/Repository/Values/Content/Content.php:24
eZ\Publish\API\Repository\ContentService
Definition: API/Repository/ContentService.php:27
eZ\Publish\Core\REST\Client\Values\Content
Definition: Publish/Core/REST/Client/Values/Content/Content.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.