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

Core/Repository/ObjectStateService.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Repository;
8
9 use eZ\Publish\API\Repository\ObjectStateService as ObjectStateServiceInterface;
10 use eZ\Publish\API\Repository\Repository as RepositoryInterface;
11 use eZ\Publish\SPI\Persistence\Content\ObjectState\Handler;
12 use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateCreateStruct;
13 use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateUpdateStruct;
14 use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupCreateStruct;
15 use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupUpdateStruct;
16 use eZ\Publish\API\Repository\Values\Content\ContentInfo;
17 use eZ\Publish\API\Repository\Values\ObjectState\ObjectState as APIObjectState;
18 use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup as APIObjectStateGroup;
19 use eZ\Publish\Core\Repository\Values\ObjectState\ObjectState;
20 use eZ\Publish\Core\Repository\Values\ObjectState\ObjectStateGroup;
21 use eZ\Publish\SPI\Persistence\Content\ObjectState as SPIObjectState;
22 use eZ\Publish\SPI\Persistence\Content\ObjectState\Group as SPIObjectStateGroup;
23 use eZ\Publish\SPI\Persistence\Content\ObjectState\InputStruct;
24 use eZ\Publish\Core\Base\Exceptions\NotFoundException;
25 use eZ\Publish\API\Repository\Exceptions\NotFoundException as APINotFoundException;
26 use eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue;
27 use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException;
28 use eZ\Publish\Core\Base\Exceptions\UnauthorizedException;
29 use Exception;
30
36 class ObjectStateService implements ObjectStateServiceInterface
37 {
39 protected $repository;
40
42 protected $objectStateHandler;
43
45 protected $settings;
46
54 public function __construct(RepositoryInterface $repository, Handler $objectStateHandler, array $settings = [])
55 {
56 $this->repository = $repository;
57 $this->objectStateHandler = $objectStateHandler;
58 // Union makes sure default settings are ignored if provided in argument
59 $this->settings = $settings + [
60 //'defaultSetting' => array(),
61 ];
62 }
63
74 public function createObjectStateGroup(ObjectStateGroupCreateStruct $objectStateGroupCreateStruct)
75 {
76 if (!$this->repository->canUser('state', 'administrate', $objectStateGroupCreateStruct)) {
77 throw new UnauthorizedException('state', 'administrate');
78 }
79
80 $inputStruct = $this->buildCreateInputStruct(
81 $objectStateGroupCreateStruct->identifier,
82 $objectStateGroupCreateStruct->defaultLanguageCode,
83 $objectStateGroupCreateStruct->names,
84 $objectStateGroupCreateStruct->descriptions
85 );
86
87 try {
88 $this->objectStateHandler->loadGroupByIdentifier($inputStruct->identifier);
89 throw new InvalidArgumentException(
90 'objectStateGroupCreateStruct',
91 'Object state group with provided identifier already exists'
92 );
93 } catch (APINotFoundException $e) {
94 // Do nothing
95 }
96
97 $this->repository->beginTransaction();
98 try {
99 $spiObjectStateGroup = $this->objectStateHandler->createGroup($inputStruct);
100 $this->repository->commit();
101 } catch (Exception $e) {
102 $this->repository->rollback();
103 throw $e;
104 }
105
106 return $this->buildDomainObjectStateGroupObject($spiObjectStateGroup);
107 }
108
112 public function loadObjectStateGroup($objectStateGroupId, array $prioritizedLanguages = [])
113 {
114 $spiObjectStateGroup = $this->objectStateHandler->loadGroup($objectStateGroupId);
115
116 return $this->buildDomainObjectStateGroupObject($spiObjectStateGroup, $prioritizedLanguages);
117 }
118
122 public function loadObjectStateGroups($offset = 0, $limit = -1, array $prioritizedLanguages = [])
123 {
124 $spiObjectStateGroups = $this->objectStateHandler->loadAllGroups($offset, $limit);
125
126 $objectStateGroups = [];
127 foreach ($spiObjectStateGroups as $spiObjectStateGroup) {
128 $objectStateGroups[] = $this->buildDomainObjectStateGroupObject(
129 $spiObjectStateGroup,
130 $prioritizedLanguages
131 );
132 }
133
134 return $objectStateGroups;
135 }
136
145 public function loadObjectStates(
146 APIObjectStateGroup $objectStateGroup,
147 array $prioritizedLanguages = []
148 ) {
149 $spiObjectStates = $this->objectStateHandler->loadObjectStates($objectStateGroup->id);
150
151 $objectStates = [];
152 foreach ($spiObjectStates as $spiObjectState) {
153 $objectStates[] = $this->buildDomainObjectStateObject(
154 $spiObjectState,
155 $objectStateGroup,
156 $prioritizedLanguages
157 );
158 }
159
160 return $objectStates;
161 }
162
174 public function updateObjectStateGroup(APIObjectStateGroup $objectStateGroup, ObjectStateGroupUpdateStruct $objectStateGroupUpdateStruct)
175 {
176 if (!$this->repository->canUser('state', 'administrate', $objectStateGroup)) {
177 throw new UnauthorizedException('state', 'administrate');
178 }
179
180 $loadedObjectStateGroup = $this->loadObjectStateGroup($objectStateGroup->id);
181
182 $inputStruct = $this->buildObjectStateGroupUpdateInputStruct(
183 $loadedObjectStateGroup,
184 $objectStateGroupUpdateStruct->identifier,
185 $objectStateGroupUpdateStruct->defaultLanguageCode,
186 $objectStateGroupUpdateStruct->names,
187 $objectStateGroupUpdateStruct->descriptions
188 );
189
190 if ($objectStateGroupUpdateStruct->identifier !== null) {
191 try {
192 $existingObjectStateGroup = $this->objectStateHandler->loadGroupByIdentifier($inputStruct->identifier);
193 if ($existingObjectStateGroup->id != $loadedObjectStateGroup->id) {
194 throw new InvalidArgumentException(
195 'objectStateGroupUpdateStruct',
196 'Object state group with provided identifier already exists'
197 );
198 }
199 } catch (APINotFoundException $e) {
200 // Do nothing
201 }
202 }
203
204 $this->repository->beginTransaction();
205 try {
206 $spiObjectStateGroup = $this->objectStateHandler->updateGroup(
207 $loadedObjectStateGroup->id,
208 $inputStruct
209 );
210 $this->repository->commit();
211 } catch (Exception $e) {
212 $this->repository->rollback();
213 throw $e;
214 }
215
216 return $this->buildDomainObjectStateGroupObject($spiObjectStateGroup);
217 }
218
226 public function deleteObjectStateGroup(APIObjectStateGroup $objectStateGroup)
227 {
228 if (!$this->repository->canUser('state', 'administrate', $objectStateGroup)) {
229 throw new UnauthorizedException('state', 'administrate');
230 }
231
232 $loadedObjectStateGroup = $this->loadObjectStateGroup($objectStateGroup->id);
233
234 $this->repository->beginTransaction();
235 try {
236 $this->objectStateHandler->deleteGroup($loadedObjectStateGroup->id);
237 $this->repository->commit();
238 } catch (Exception $e) {
239 $this->repository->rollback();
240 throw $e;
241 }
242 }
243
258 public function createObjectState(APIObjectStateGroup $objectStateGroup, ObjectStateCreateStruct $objectStateCreateStruct)
259 {
260 if (!$this->repository->canUser('state', 'administrate', $objectStateCreateStruct, [$objectStateGroup])) {
261 throw new UnauthorizedException('state', 'administrate');
262 }
263
264 $inputStruct = $this->buildCreateInputStruct(
265 $objectStateCreateStruct->identifier,
266 $objectStateCreateStruct->defaultLanguageCode,
267 $objectStateCreateStruct->names,
268 $objectStateCreateStruct->descriptions
269 );
270
271 try {
272 $this->objectStateHandler->loadByIdentifier($inputStruct->identifier, $objectStateGroup->id);
273 throw new InvalidArgumentException(
274 'objectStateCreateStruct',
275 'Object state with provided identifier already exists in provided object state group'
276 );
277 } catch (APINotFoundException $e) {
278 // Do nothing
279 }
280
281 $this->repository->beginTransaction();
282 try {
283 $spiObjectState = $this->objectStateHandler->create($objectStateGroup->id, $inputStruct);
284
285 if (is_int($objectStateCreateStruct->priority)) {
286 $this->objectStateHandler->setPriority(
287 $spiObjectState->id,
288 $objectStateCreateStruct->priority
289 );
290
291 // Reload the object state to have the updated priority,
292 // considering that priorities are always incremental within a group
293 $spiObjectState = $this->objectStateHandler->load($spiObjectState->id);
294 }
295
296 $this->repository->commit();
297 } catch (Exception $e) {
298 $this->repository->rollback();
299 throw $e;
300 }
301
302 return $this->buildDomainObjectStateObject($spiObjectState);
303 }
304
308 public function loadObjectState($stateId, array $prioritizedLanguages = [])
309 {
310 $spiObjectState = $this->objectStateHandler->load($stateId);
311
312 return $this->buildDomainObjectStateObject($spiObjectState, null, $prioritizedLanguages);
313 }
314
326 public function updateObjectState(APIObjectState $objectState, ObjectStateUpdateStruct $objectStateUpdateStruct)
327 {
328 if (!$this->repository->canUser('state', 'administrate', $objectState)) {
329 throw new UnauthorizedException('state', 'administrate');
330 }
331
332 $loadedObjectState = $this->loadObjectState($objectState->id);
333
334 $inputStruct = $this->buildObjectStateUpdateInputStruct(
335 $loadedObjectState,
336 $objectStateUpdateStruct->identifier,
337 $objectStateUpdateStruct->defaultLanguageCode,
338 $objectStateUpdateStruct->names,
339 $objectStateUpdateStruct->descriptions
340 );
341
342 if ($objectStateUpdateStruct->identifier !== null) {
343 try {
344 $existingObjectState = $this->objectStateHandler->loadByIdentifier(
345 $inputStruct->identifier,
346 $loadedObjectState->getObjectStateGroup()->id
347 );
348
349 if ($existingObjectState->id != $loadedObjectState->id) {
350 throw new InvalidArgumentException(
351 'objectStateUpdateStruct',
352 'Object state with provided identifier already exists in provided object state group'
353 );
354 }
355 } catch (APINotFoundException $e) {
356 // Do nothing
357 }
358 }
359
360 $this->repository->beginTransaction();
361 try {
362 $spiObjectState = $this->objectStateHandler->update(
363 $loadedObjectState->id,
364 $inputStruct
365 );
366 $this->repository->commit();
367 } catch (Exception $e) {
368 $this->repository->rollback();
369 throw $e;
370 }
371
372 return $this->buildDomainObjectStateObject($spiObjectState);
373 }
374
383 public function setPriorityOfObjectState(APIObjectState $objectState, $priority)
384 {
385 if (!is_int($priority)) {
386 throw new InvalidArgumentValue('priority', $priority);
387 }
388
389 if (!$this->repository->canUser('state', 'administrate', $objectState)) {
390 throw new UnauthorizedException('state', 'administrate');
391 }
392
393 $loadedObjectState = $this->loadObjectState($objectState->id);
394
395 $this->repository->beginTransaction();
396 try {
397 $this->objectStateHandler->setPriority(
398 $loadedObjectState->id,
399 $priority
400 );
401 $this->repository->commit();
402 } catch (Exception $e) {
403 $this->repository->rollback();
404 throw $e;
405 }
406 }
407
416 public function deleteObjectState(APIObjectState $objectState)
417 {
418 if (!$this->repository->canUser('state', 'administrate', $objectState)) {
419 throw new UnauthorizedException('state', 'administrate');
420 }
421
422 $loadedObjectState = $this->loadObjectState($objectState->id);
423
424 $this->repository->beginTransaction();
425 try {
426 $this->objectStateHandler->delete($loadedObjectState->id);
427 $this->repository->commit();
428 } catch (Exception $e) {
429 $this->repository->rollback();
430 throw $e;
431 }
432 }
433
444 public function setContentState(ContentInfo $contentInfo, APIObjectStateGroup $objectStateGroup, APIObjectState $objectState)
445 {
446 if ($this->repository->canUser('state', 'assign', $contentInfo, $objectState) !== true) {
447 throw new UnauthorizedException('state', 'assign', ['contentId' => $contentInfo->id]);
448 }
449
450 $loadedObjectState = $this->loadObjectState($objectState->id);
451
452 if ($loadedObjectState->getObjectStateGroup()->id != $objectStateGroup->id) {
453 throw new InvalidArgumentException('objectState', 'Object state does not belong to the given group');
454 }
455
456 $this->repository->beginTransaction();
457 try {
458 $this->objectStateHandler->setContentState(
459 $contentInfo->id,
460 $objectStateGroup->id,
461 $loadedObjectState->id
462 );
463 $this->repository->commit();
464 } catch (Exception $e) {
465 $this->repository->rollback();
466 throw $e;
467 }
468 }
469
480 public function getContentState(ContentInfo $contentInfo, APIObjectStateGroup $objectStateGroup)
481 {
482 $spiObjectState = $this->objectStateHandler->getContentState(
483 $contentInfo->id,
484 $objectStateGroup->id
485 );
486
487 return $this->buildDomainObjectStateObject($spiObjectState, $objectStateGroup);
488 }
489
497 public function getContentCount(APIObjectState $objectState)
498 {
499 return $this->objectStateHandler->getContentCount(
500 $objectState->id
501 );
502 }
503
511 public function newObjectStateGroupCreateStruct($identifier)
512 {
513 $objectStateGroupCreateStruct = new ObjectStateGroupCreateStruct();
514 $objectStateGroupCreateStruct->identifier = $identifier;
515
516 return $objectStateGroupCreateStruct;
517 }
518
524 public function newObjectStateGroupUpdateStruct()
525 {
526 return new ObjectStateGroupUpdateStruct();
527 }
528
536 public function newObjectStateCreateStruct($identifier)
537 {
538 $objectStateCreateStruct = new ObjectStateCreateStruct();
539 $objectStateCreateStruct->identifier = $identifier;
540
541 return $objectStateCreateStruct;
542 }
543
549 public function newObjectStateUpdateStruct()
550 {
551 return new ObjectStateUpdateStruct();
552 }
553
563 protected function buildDomainObjectStateObject(
564 SPIObjectState $spiObjectState,
565 APIObjectStateGroup $objectStateGroup = null,
566 array $prioritizedLanguages = []
567 ) {
568 $objectStateGroup = $objectStateGroup ?: $this->loadObjectStateGroup($spiObjectState->groupId);
569
570 return new ObjectState(
571 [
572 'id' => $spiObjectState->id,
573 'identifier' => $spiObjectState->identifier,
574 'priority' => $spiObjectState->priority,
575 'mainLanguageCode' => $spiObjectState->defaultLanguage,
576 'languageCodes' => $spiObjectState->languageCodes,
577 'names' => $spiObjectState->name,
578 'descriptions' => $spiObjectState->description,
579 'objectStateGroup' => $objectStateGroup,
580 'prioritizedLanguages' => $prioritizedLanguages,
581 ]
582 );
583 }
584
593 protected function buildDomainObjectStateGroupObject(
594 SPIObjectStateGroup $spiObjectStateGroup,
595 array $prioritizedLanguages = []
596 ) {
597 return new ObjectStateGroup(
598 [
599 'id' => $spiObjectStateGroup->id,
600 'identifier' => $spiObjectStateGroup->identifier,
601 'mainLanguageCode' => $spiObjectStateGroup->defaultLanguage,
602 'languageCodes' => $spiObjectStateGroup->languageCodes,
603 'names' => $spiObjectStateGroup->name,
604 'descriptions' => $spiObjectStateGroup->description,
605 'prioritizedLanguages' => $prioritizedLanguages,
606 ]
607 );
608 }
609
620 protected function buildCreateInputStruct($identifier, $defaultLanguageCode, $names, $descriptions)
621 {
622 if (!is_string($identifier) || empty($identifier)) {
623 throw new InvalidArgumentValue('identifier', $identifier);
624 }
625
626 if (!is_string($defaultLanguageCode) || empty($defaultLanguageCode)) {
627 throw new InvalidArgumentValue('defaultLanguageCode', $defaultLanguageCode);
628 }
629
630 if (!is_array($names) || empty($names)) {
631 throw new InvalidArgumentValue('names', $names);
632 }
633
634 if (!isset($names[$defaultLanguageCode])) {
635 throw new InvalidArgumentValue('names', $names);
636 }
637
638 foreach ($names as $languageCode => $name) {
639 try {
640 $this->repository->getContentLanguageService()->loadLanguage($languageCode);
641 } catch (NotFoundException $e) {
642 throw new InvalidArgumentValue('names', $names);
643 }
644
645 if (!is_string($name) || empty($name)) {
646 throw new InvalidArgumentValue('names', $names);
647 }
648 }
649
650 if ($descriptions !== null && !is_array($descriptions)) {
651 throw new InvalidArgumentValue('descriptions', $descriptions);
652 }
653
654 $descriptions = $descriptions !== null ? $descriptions : [];
655
656 $inputStruct = new InputStruct();
657 $inputStruct->identifier = $identifier;
658 $inputStruct->defaultLanguage = $defaultLanguageCode;
659 $inputStruct->name = $names;
660
661 $inputStruct->description = [];
662 foreach ($names as $languageCode => $name) {
663 if (isset($descriptions[$languageCode]) && !empty($descriptions[$languageCode])) {
664 $inputStruct->description[$languageCode] = $descriptions[$languageCode];
665 } else {
666 $inputStruct->description[$languageCode] = '';
667 }
668 }
669
670 return $inputStruct;
671 }
672
684 protected function buildObjectStateUpdateInputStruct(APIObjectState $objectState, $identifier, $defaultLanguageCode, $names, $descriptions)
685 {
686 $inputStruct = new InputStruct();
687
688 if ($identifier !== null && (!is_string($identifier) || empty($identifier))) {
689 throw new InvalidArgumentValue('identifier', $identifier);
690 }
691
692 $inputStruct->identifier = $identifier !== null ? $identifier : $objectState->identifier;
693
694 if ($defaultLanguageCode !== null && (!is_string($defaultLanguageCode) || empty($defaultLanguageCode))) {
695 throw new InvalidArgumentValue('defaultLanguageCode', $defaultLanguageCode);
696 }
697
698 $inputStruct->defaultLanguage = $defaultLanguageCode !== null ? $defaultLanguageCode : $objectState->defaultLanguageCode;
699
700 if ($names !== null && (!is_array($names) || empty($names))) {
701 throw new InvalidArgumentValue('names', $names);
702 }
703
704 $inputStruct->name = $names !== null ? $names : $objectState->getNames();
705
706 if (!isset($inputStruct->name[$inputStruct->defaultLanguage])) {
707 throw new InvalidArgumentValue('names', $inputStruct->name);
708 }
709
710 foreach ($inputStruct->name as $languageCode => $name) {
711 try {
712 $this->repository->getContentLanguageService()->loadLanguage($languageCode);
713 } catch (NotFoundException $e) {
714 throw new InvalidArgumentValue('names', $inputStruct->name);
715 }
716
717 if (!is_string($name) || empty($name)) {
718 throw new InvalidArgumentValue('names', $inputStruct->name);
719 }
720 }
721
722 if ($descriptions !== null && !is_array($descriptions)) {
723 throw new InvalidArgumentValue('descriptions', $descriptions);
724 }
725
726 $descriptions = $descriptions !== null ? $descriptions : $objectState->getDescriptions();
727 $descriptions = $descriptions !== null ? $descriptions : [];
728
729 $inputStruct->description = [];
730 foreach ($inputStruct->name as $languageCode => $name) {
731 if (isset($descriptions[$languageCode]) && !empty($descriptions[$languageCode])) {
732 $inputStruct->description[$languageCode] = $descriptions[$languageCode];
733 } else {
734 $inputStruct->description[$languageCode] = '';
735 }
736 }
737
738 return $inputStruct;
739 }
740
752 protected function buildObjectStateGroupUpdateInputStruct(APIObjectStateGroup $objectStateGroup, $identifier, $defaultLanguageCode, $names, $descriptions)
753 {
754 $inputStruct = new InputStruct();
755
756 if ($identifier !== null && (!is_string($identifier) || empty($identifier))) {
757 throw new InvalidArgumentValue('identifier', $identifier);
758 }
759
760 $inputStruct->identifier = $identifier !== null ? $identifier : $objectStateGroup->identifier;
761
762 if ($defaultLanguageCode !== null && (!is_string($defaultLanguageCode) || empty($defaultLanguageCode))) {
763 throw new InvalidArgumentValue('defaultLanguageCode', $defaultLanguageCode);
764 }
765
766 $inputStruct->defaultLanguage = $defaultLanguageCode !== null ? $defaultLanguageCode : $objectStateGroup->defaultLanguageCode;
767
768 if ($names !== null && (!is_array($names) || empty($names))) {
769 throw new InvalidArgumentValue('names', $names);
770 }
771
772 $inputStruct->name = $names !== null ? $names : $objectStateGroup->getNames();
773
774 if (!isset($inputStruct->name[$inputStruct->defaultLanguage])) {
775 throw new InvalidArgumentValue('names', $inputStruct->name);
776 }
777
778 foreach ($inputStruct->name as $languageCode => $name) {
779 try {
780 $this->repository->getContentLanguageService()->loadLanguage($languageCode);
781 } catch (NotFoundException $e) {
782 throw new InvalidArgumentValue('names', $inputStruct->name);
783 }
784
785 if (!is_string($name) || empty($name)) {
786 throw new InvalidArgumentValue('names', $inputStruct->name);
787 }
788 }
789
790 if ($descriptions !== null && !is_array($descriptions)) {
791 throw new InvalidArgumentValue('descriptions', $descriptions);
792 }
793
794 $descriptions = $descriptions !== null ? $descriptions : $objectStateGroup->getDescriptions();
795 $descriptions = $descriptions !== null ? $descriptions : [];
796
797 $inputStruct->description = [];
798 foreach ($inputStruct->name as $languageCode => $name) {
799 if (isset($descriptions[$languageCode]) && !empty($descriptions[$languageCode])) {
800 $inputStruct->description[$languageCode] = $descriptions[$languageCode];
801 } else {
802 $inputStruct->description[$languageCode] = '';
803 }
804 }
805
806 return $inputStruct;
807 }
808 }
eZ\Publish\API\Repository\Exceptions\NotFoundException
This Exception is thrown if an object referenced by an id or identifier could not be found in the rep...
Definition: API/Repository/Exceptions/NotFoundException.php:16
eZ\Publish\API\Repository\Values\Content\ContentInfo
Definition: API/Repository/Values/Content/ContentInfo.php:31
eZ\Publish\API\Repository\Values\ObjectState\ObjectStateCreateStruct
This class represents a value for creating object states.
Definition: API/Repository/Values/ObjectState/ObjectStateCreateStruct.php:15
eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupCreateStruct
This class represents a value for creating object state groups.
Definition: API/Repository/Values/ObjectState/ObjectStateGroupCreateStruct.php:15
eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupUpdateStruct
This class represents a value for updating object state groups.
Definition: API/Repository/Values/ObjectState/ObjectStateGroupUpdateStruct.php:15
eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
Definition: API/Repository/Values/ObjectState/ObjectStateGroup.php:22
eZ\Publish\API\Repository\Values\ObjectState\ObjectStateUpdateStruct
This class represents a value for updating object states.
Definition: API/Repository/Values/ObjectState/ObjectStateUpdateStruct.php:15
eZ\Publish\API\Repository\Values\ObjectState\ObjectState
Definition: API/Repository/Values/ObjectState/ObjectState.php:23
eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
Invalid Argument Type Exception implementation.
Definition: Core/Base/Exceptions/InvalidArgumentException.php:20
eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue
Invalid Argument Type Exception implementation.
Definition: Base/Exceptions/InvalidArgumentValue.php:17
eZ\Publish\Core\Base\Exceptions\NotFoundException
Not Found Exception implementation.
Definition: Core/Base/Exceptions/NotFoundException.php:21
eZ\Publish\Core\Base\Exceptions\UnauthorizedException
UnauthorizedException Exception implementation.
Definition: Core/Base/Exceptions/UnauthorizedException.php:21
eZ\Publish\Core\Repository\ObjectStateService
Definition: Core/Repository/ObjectStateService.php:37
eZ\Publish\Core\Repository\ObjectStateService\createObjectState
createObjectState(APIObjectStateGroup $objectStateGroup, ObjectStateCreateStruct $objectStateCreateStruct)
Creates a new object state in the given group.
Definition: Core/Repository/ObjectStateService.php:258
eZ\Publish\Core\Repository\ObjectStateService\newObjectStateUpdateStruct
newObjectStateUpdateStruct()
Instantiates a new Object State Update Struct.
Definition: Core/Repository/ObjectStateService.php:549
eZ\Publish\Core\Repository\ObjectStateService\newObjectStateGroupCreateStruct
newObjectStateGroupCreateStruct($identifier)
Instantiates a new Object State Group Create Struct and sets $identified in it.
Definition: Core/Repository/ObjectStateService.php:511
eZ\Publish\Core\Repository\ObjectStateService\buildObjectStateUpdateInputStruct
buildObjectStateUpdateInputStruct(APIObjectState $objectState, $identifier, $defaultLanguageCode, $names, $descriptions)
Validates input for updating object states and builds the InputStruct object.
Definition: Core/Repository/ObjectStateService.php:684
eZ\Publish\Core\Repository\ObjectStateService\updateObjectStateGroup
updateObjectStateGroup(APIObjectStateGroup $objectStateGroup, ObjectStateGroupUpdateStruct $objectStateGroupUpdateStruct)
Updates an object state group.
Definition: Core/Repository/ObjectStateService.php:174
eZ\Publish\Core\Repository\ObjectStateService\loadObjectState
loadObjectState($stateId, array $prioritizedLanguages=[])
{Loads an object state.Used as prioritized language code on translated properties of returned object....
Definition: Core/Repository/ObjectStateService.php:308
eZ\Publish\Core\Repository\ObjectStateService\buildDomainObjectStateObject
buildDomainObjectStateObject(SPIObjectState $spiObjectState, APIObjectStateGroup $objectStateGroup=null, array $prioritizedLanguages=[])
Converts the object state SPI value object to API value object.
Definition: Core/Repository/ObjectStateService.php:563
eZ\Publish\Core\Repository\ObjectStateService\getContentState
getContentState(ContentInfo $contentInfo, APIObjectStateGroup $objectStateGroup)
Gets the object-state of object identified by $contentId.
Definition: Core/Repository/ObjectStateService.php:480
eZ\Publish\Core\Repository\ObjectStateService\$settings
$settings
Definition: Core/Repository/ObjectStateService.php:45
eZ\Publish\Core\Repository\ObjectStateService\$repository
$repository
Definition: Core/Repository/ObjectStateService.php:39
eZ\Publish\Core\Repository\ObjectStateService\$objectStateHandler
$objectStateHandler
Definition: Core/Repository/ObjectStateService.php:42
eZ\Publish\Core\Repository\ObjectStateService\buildObjectStateGroupUpdateInputStruct
buildObjectStateGroupUpdateInputStruct(APIObjectStateGroup $objectStateGroup, $identifier, $defaultLanguageCode, $names, $descriptions)
Validates input for updating object state groups and builds the InputStruct object.
Definition: Core/Repository/ObjectStateService.php:752
eZ\Publish\Core\Repository\ObjectStateService\newObjectStateGroupUpdateStruct
newObjectStateGroupUpdateStruct()
Instantiates a new Object State Group Update Struct.
Definition: Core/Repository/ObjectStateService.php:524
eZ\Publish\Core\Repository\ObjectStateService\getContentCount
getContentCount(APIObjectState $objectState)
Returns the number of objects which are in this state.
Definition: Core/Repository/ObjectStateService.php:497
eZ\Publish\Core\Repository\ObjectStateService\__construct
__construct(RepositoryInterface $repository, Handler $objectStateHandler, array $settings=[])
Setups service with reference to repository object that created it & corresponding handler.
Definition: Core/Repository/ObjectStateService.php:54
eZ\Publish\Core\Repository\ObjectStateService\deleteObjectStateGroup
deleteObjectStateGroup(APIObjectStateGroup $objectStateGroup)
Deletes a object state group including all states and links to content.
Definition: Core/Repository/ObjectStateService.php:226
eZ\Publish\Core\Repository\ObjectStateService\setContentState
setContentState(ContentInfo $contentInfo, APIObjectStateGroup $objectStateGroup, APIObjectState $objectState)
Sets the object-state of a state group to $state for the given content.
Definition: Core/Repository/ObjectStateService.php:444
eZ\Publish\Core\Repository\ObjectStateService\deleteObjectState
deleteObjectState(APIObjectState $objectState)
Deletes a object state.
Definition: Core/Repository/ObjectStateService.php:416
eZ\Publish\Core\Repository\ObjectStateService\createObjectStateGroup
createObjectStateGroup(ObjectStateGroupCreateStruct $objectStateGroupCreateStruct)
Creates a new object state group.
Definition: Core/Repository/ObjectStateService.php:74
eZ\Publish\Core\Repository\ObjectStateService\buildCreateInputStruct
buildCreateInputStruct($identifier, $defaultLanguageCode, $names, $descriptions)
Validates input for creating object states/groups and builds the InputStruct object.
Definition: Core/Repository/ObjectStateService.php:620
eZ\Publish\Core\Repository\ObjectStateService\loadObjectStates
loadObjectStates(APIObjectStateGroup $objectStateGroup, array $prioritizedLanguages=[])
This method returns the ordered list of object states of a group.
Definition: Core/Repository/ObjectStateService.php:145
eZ\Publish\Core\Repository\ObjectStateService\updateObjectState
updateObjectState(APIObjectState $objectState, ObjectStateUpdateStruct $objectStateUpdateStruct)
Updates an object state.
Definition: Core/Repository/ObjectStateService.php:326
eZ\Publish\Core\Repository\ObjectStateService\loadObjectStateGroups
loadObjectStateGroups($offset=0, $limit=-1, array $prioritizedLanguages=[])
{Loads all object state groups.Used as prioritized language code on translated properties of returned...
Definition: Core/Repository/ObjectStateService.php:122
eZ\Publish\Core\Repository\ObjectStateService\setPriorityOfObjectState
setPriorityOfObjectState(APIObjectState $objectState, $priority)
Changes the priority of the state.
Definition: Core/Repository/ObjectStateService.php:383
eZ\Publish\Core\Repository\ObjectStateService\loadObjectStateGroup
loadObjectStateGroup($objectStateGroupId, array $prioritizedLanguages=[])
{Loads a object state group.Used as prioritized language code on translated properties of returned ob...
Definition: Core/Repository/ObjectStateService.php:112
eZ\Publish\Core\Repository\ObjectStateService\buildDomainObjectStateGroupObject
buildDomainObjectStateGroupObject(SPIObjectStateGroup $spiObjectStateGroup, array $prioritizedLanguages=[])
Converts the object state group SPI value object to API value object.
Definition: Core/Repository/ObjectStateService.php:593
eZ\Publish\Core\Repository\ObjectStateService\newObjectStateCreateStruct
newObjectStateCreateStruct($identifier)
Instantiates a new Object State Create Struct and sets $identifier in it.
Definition: Core/Repository/ObjectStateService.php:536
eZ\Publish\Core\Repository\Values\ObjectState\ObjectStateGroup
Definition: Core/Repository/Values/ObjectState/ObjectStateGroup.php:26
eZ\Publish\Core\Repository\Values\ObjectState\ObjectState
Definition: Core/Repository/Values/ObjectState/ObjectState.php:27
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\API\Repository\ObjectStateService
Definition: API/Repository/ObjectStateService.php:23
eZ\Publish\API\Repository\Repository
Repository interface.
Definition: API/Repository/Repository.php:16
eZ\Publish\SPI\Persistence\Content\Language\Handler
Language Handler interface.
Definition: SPI/Persistence/Content/Language/Handler.php:15
eZ\Publish\SPI\Persistence\Content\ObjectState\Handler
The Object State Handler interface provides managing of object states and groups.
Definition: SPI/Persistence/Content/ObjectState/Handler.php:13
eZ\Publish\Core\Repository
Definition: Core/Repository/BookmarkService.php:9
eZ\Publish\SPI\Persistence\Content\ObjectState
Definition: ObjectState/Group.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.