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

ContentProxy.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Repository\Values\Content;
8
9 use eZ\Publish\API\Repository\Values\Content\Content as APIContent;
10 use eZ\Publish\API\Repository\Values\ContentType\ContentType;
11 use eZ\Publish\Core\Repository\Values\GeneratorProxyTrait;
12
18 class ContentProxy extends APIContent
19 {
20 use GeneratorProxyTrait;
21
23 protected $object;
24
26 protected $contentInfoProxy;
27
28 public function __get($name)
29 {
30 if ($name === 'id') {
31 return $this->id;
32 }
33
34 if ($name === 'contentInfo') {
35 return $this->getContentInfo();
36 }
37
38 if ($this->object === null) {
39 $this->loadObject();
40 }
41
42 return $this->object->$name;
43 }
44
45 public function __isset($name)
46 {
47 if ($name === 'id' || $name === 'contentInfo') {
48 return true;
49 }
50
51 if ($this->object === null) {
52 $this->loadObject();
53 }
54
55 return isset($this->object->$name);
56 }
57
65 protected function getContentInfo()
66 {
67 if ($this->object === null) {
68 if ($this->contentInfoProxy === null) {
69 $this->contentInfoProxy = new ContentContentInfoProxy($this, $this->id);
70 }
71
72 return $this->contentInfoProxy;
73 } elseif ($this->contentInfoProxy !== null) {
74 // Remove ref when we no longer need the proxy
75 $this->contentInfoProxy = null;
76 }
77
78 return $this->object->getVersionInfo()->getContentInfo();
79 }
80
81 public function getVersionInfo()
82 {
83 if ($this->object === null) {
84 $this->loadObject();
85 }
86
87 return $this->object->getVersionInfo();
88 }
89
90 public function getContentType(): ContentType
91 {
92 if ($this->object === null) {
93 $this->loadObject();
94 }
95
96 return $this->object->getContentType();
97 }
98
99 public function getFieldValue($fieldDefIdentifier, $languageCode = null)
100 {
101 if ($this->object === null) {
102 $this->loadObject();
103 }
104
105 return $this->object->getFieldValue($fieldDefIdentifier, $languageCode);
106 }
107
108 public function getFields()
109 {
110 if ($this->object === null) {
111 $this->loadObject();
112 }
113
114 return $this->object->getFields();
115 }
116
117 public function getFieldsByLanguage($languageCode = null)
118 {
119 if ($this->object === null) {
120 $this->loadObject();
121 }
122
123 return $this->object->getFieldsByLanguage($languageCode);
124 }
125
126 public function getField($fieldDefIdentifier, $languageCode = null)
127 {
128 if ($this->object === null) {
129 $this->loadObject();
130 }
131
132 return $this->object->getField($fieldDefIdentifier, $languageCode);
133 }
134 }
eZ\Publish\Core\Repository\Values\loadObject
loadObject()
Loads the generator to object value and unset's generator.
Definition: GeneratorProxyTrait.php:150
eZ\Publish\Core\Repository\Values\GeneratorProxyTrait
trait GeneratorProxyTrait
Trait for proxies, covers all relevant magic methods and exposes private method to load object.
Definition: GeneratorProxyTrait.php:19
eZ\Publish\API\Repository\Values\ContentType\ContentType
Definition: API/Repository/Values/ContentType/ContentType.php:36
eZ\Publish\API\Repository\Values\Content\Content
Definition: Publish/API/Repository/Values/Content/Content.php:21
eZ\Publish\Core\Repository\Values\Content\ContentContentInfoProxy
This class represents a (lazy loaded) proxy for a content info value, for use by ContentProxy.
Definition: ContentContentInfoProxy.php:23
eZ\Publish\Core\Repository\Values\Content\ContentProxy
This class represents a (lazy loaded) proxy for a content value.
Definition: ContentProxy.php:19
eZ\Publish\Core\Repository\Values\Content\ContentProxy\getContentType
getContentType()
Returns the ContentType for this content.
Definition: ContentProxy.php:90
eZ\Publish\Core\Repository\Values\Content\ContentProxy\getField
getField($fieldDefIdentifier, $languageCode=null)
This method returns the field for a given field definition identifier and language.
Definition: ContentProxy.php:126
eZ\Publish\Core\Repository\Values\Content\ContentProxy\$object
$object
Definition: ContentProxy.php:23
eZ\Publish\Core\Repository\Values\Content\ContentProxy\__get
__get($name)
Magic get function handling read to non public properties.
Definition: ContentProxy.php:28
eZ\Publish\Core\Repository\Values\Content\ContentProxy\__isset
__isset($name)
Magic isset function handling isset() to non public properties.
Definition: ContentProxy.php:45
eZ\Publish\Core\Repository\Values\Content\ContentProxy\getVersionInfo
getVersionInfo()
Returns the VersionInfo for this version.
Definition: ContentProxy.php:81
eZ\Publish\Core\Repository\Values\Content\ContentProxy\$contentInfoProxy
$contentInfoProxy
Definition: ContentProxy.php:26
eZ\Publish\Core\Repository\Values\Content\ContentProxy\getContentInfo
getContentInfo()
Return content info, in proxy form if we have not loaded object yet.
Definition: ContentProxy.php:65
eZ\Publish\Core\Repository\Values\Content\ContentProxy\getFieldsByLanguage
getFieldsByLanguage($languageCode=null)
This method returns the fields for a given language and non translatable fields.
Definition: ContentProxy.php:117
eZ\Publish\Core\Repository\Values\Content\ContentProxy\getFieldValue
getFieldValue($fieldDefIdentifier, $languageCode=null)
Returns a field value for the given value.
Definition: ContentProxy.php:99
eZ\Publish\Core\Repository\Values\Content\ContentProxy\getFields
getFields()
This method returns the complete fields collection.
Definition: ContentProxy.php:108
eZ\Publish\Core\Repository\Values\Content
Definition: Publish/Core/Repository/Values/Content/Content.php:7
eZ\Publish\SPI\Persistence\Content\Type
Definition: SPI/Persistence/Content/Type/CreateStruct.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.