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

Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Persistence\Legacy\Content\ObjectState;
8
9 use eZ\Publish\SPI\Persistence\Content\ObjectState;
10 use eZ\Publish\SPI\Persistence\Content\ObjectState\Group;
11 use eZ\Publish\SPI\Persistence\Content\ObjectState\InputStruct;
12 use eZ\Publish\SPI\Persistence\Content\Language\Handler as LanguageHandler;
13
17 class Mapper
18 {
24 protected $languageHandler;
25
31 public function __construct(LanguageHandler $languageHandler)
32 {
33 $this->languageHandler = $languageHandler;
34 }
35
43 public function createObjectStateFromData(array $data)
44 {
45 $objectState = new ObjectState();
46
47 $languageIds = [(int)$data[0]['ezcobj_state_default_language_id']];
48 foreach ($data as $stateTranslation) {
49 $languageIds[] = (int)$stateTranslation['ezcobj_state_language_language_id'] & ~1;
50 }
51 $languages = $this->languageHandler->loadList($languageIds);
52
53 $objectState->id = (int)$data[0]['ezcobj_state_id'];
54 $objectState->groupId = (int)$data[0]['ezcobj_state_group_id'];
55 $objectState->identifier = $data[0]['ezcobj_state_identifier'];
56 $objectState->priority = (int)$data[0]['ezcobj_state_priority'];
57 $objectState->defaultLanguage = $languages[(int)$data[0]['ezcobj_state_default_language_id']]->languageCode;
58
59 $objectState->languageCodes = [];
60 $objectState->name = [];
61 $objectState->description = [];
62
63 foreach ($data as $stateTranslation) {
64 $languageCode = $languages[$stateTranslation['ezcobj_state_language_language_id'] & ~1]->languageCode;
65 $objectState->languageCodes[] = $languageCode;
66 $objectState->name[$languageCode] = $stateTranslation['ezcobj_state_language_name'];
67 $objectState->description[$languageCode] = $stateTranslation['ezcobj_state_language_description'];
68 }
69
70 return $objectState;
71 }
72
80 public function createObjectStateListFromData(array $data)
81 {
82 $objectStates = [];
83
84 foreach ($data as $objectStateData) {
85 $objectStates[] = $this->createObjectStateFromData($objectStateData);
86 }
87
88 return $objectStates;
89 }
90
98 public function createObjectStateGroupFromData(array $data)
99 {
100 $objectStateGroup = new Group();
101
102 $languageIds = [(int)$data[0]['ezcobj_state_group_default_language_id']];
103 foreach ($data as $groupTranslation) {
104 $languageIds[] = (int)$groupTranslation['ezcobj_state_group_language_real_language_id'];
105 }
106 $languages = $this->languageHandler->loadList($languageIds);
107
108 $objectStateGroup->id = (int)$data[0]['ezcobj_state_group_id'];
109 $objectStateGroup->identifier = $data[0]['ezcobj_state_group_identifier'];
110 $objectStateGroup->defaultLanguage = $languages[
111 (int)$data[0]['ezcobj_state_group_default_language_id']
112 ]->languageCode;
113
114 $objectStateGroup->languageCodes = [];
115 $objectStateGroup->name = [];
116 $objectStateGroup->description = [];
117
118 foreach ($data as $groupTranslation) {
119 $languageCode = $languages[(int)$groupTranslation['ezcobj_state_group_language_real_language_id']]->languageCode;
120 $objectStateGroup->languageCodes[] = $languageCode;
121 $objectStateGroup->name[$languageCode] = $groupTranslation['ezcobj_state_group_language_name'];
122 $objectStateGroup->description[$languageCode] = $groupTranslation['ezcobj_state_group_language_description'];
123 }
124
125 return $objectStateGroup;
126 }
127
135 public function createObjectStateGroupListFromData(array $data)
136 {
137 $objectStateGroups = [];
138
139 foreach ($data as $objectStateGroupData) {
140 $objectStateGroups[] = $this->createObjectStateGroupFromData($objectStateGroupData);
141 }
142
143 return $objectStateGroups;
144 }
145
153 public function createObjectStateGroupFromInputStruct(InputStruct $input)
154 {
155 $objectStateGroup = new Group();
156
157 $objectStateGroup->identifier = $input->identifier;
158 $objectStateGroup->defaultLanguage = $input->defaultLanguage;
159 $objectStateGroup->name = $input->name;
160 $objectStateGroup->description = $input->description;
161
162 $objectStateGroup->languageCodes = [];
163 foreach ($input->name as $languageCode => $name) {
164 $objectStateGroup->languageCodes[] = $languageCode;
165 }
166
167 return $objectStateGroup;
168 }
169
177 public function createObjectStateFromInputStruct(InputStruct $input)
178 {
179 $objectState = new ObjectState();
180
181 $objectState->identifier = $input->identifier;
182 $objectState->defaultLanguage = $input->defaultLanguage;
183 $objectState->name = $input->name;
184 $objectState->description = $input->description;
185
186 $objectState->languageCodes = [];
187 foreach ($input->name as $languageCode => $name) {
188 $objectState->languageCodes[] = $languageCode;
189 }
190
191 return $objectState;
192 }
193 }
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper
Mapper for ObjectState and object state Group objects.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:18
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\createObjectStateFromData
createObjectStateFromData(array $data)
Creates ObjectState object from provided $data.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:43
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\createObjectStateGroupListFromData
createObjectStateGroupListFromData(array $data)
Creates ObjectStateGroup array of objects from provided $data.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:135
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\__construct
__construct(LanguageHandler $languageHandler)
Creates a new mapper.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:31
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\createObjectStateGroupFromData
createObjectStateGroupFromData(array $data)
Creates ObjectStateGroup object from provided $data.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:98
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\$languageHandler
$languageHandler
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:24
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\createObjectStateFromInputStruct
createObjectStateFromInputStruct(InputStruct $input)
Creates an instance of ObjectState object from provided $input struct.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:177
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\createObjectStateGroupFromInputStruct
createObjectStateGroupFromInputStruct(InputStruct $input)
Creates an instance of ObjectStateGroup object from provided $input struct.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:153
eZ\Publish\Core\Persistence\Legacy\Content\ObjectState\Mapper\createObjectStateListFromData
createObjectStateListFromData(array $data)
Creates ObjectState array of objects from provided $data.
Definition: Publish/Core/Persistence/Legacy/Content/ObjectState/Mapper.php:80
eZ\Publish\SPI\Persistence\Content\ObjectState\Group
This class represents a persistent object state group.
Definition: ObjectState/Group.php:15
eZ\Publish\SPI\Persistence\Content\ObjectState\InputStruct
This class represents a value for creating and updating object states and groups.
Definition: InputStruct.php:15
eZ\Publish\SPI\Persistence\Content\ObjectState
This class represents a persistent object state.
Definition: SPI/Persistence/Content/ObjectState.php:15
eZ\Publish\SPI\Persistence\Content\Language\Handler
Language Handler interface.
Definition: SPI/Persistence/Content/Language/Handler.php:15
eZ\Publish\SPI\Persistence\Content\ObjectState
Definition: ObjectState/Group.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.