Completed
Push — siteaccessaware-layer-only ( 14ffb6 )
by André
15:43
created

ObjectStateService   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 128
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 128
rs 10
c 0
b 0
f 0
wmc 19
lcom 1
cbo 2

19 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A createObjectStateGroup() 0 4 1
A loadObjectStateGroup() 0 6 1
A loadObjectStateGroups() 0 6 1
A loadObjectStates() 0 6 1
A updateObjectStateGroup() 0 4 1
A deleteObjectStateGroup() 0 4 1
A createObjectState() 0 4 1
A loadObjectState() 0 6 1
A updateObjectState() 0 4 1
A setPriorityOfObjectState() 0 4 1
A deleteObjectState() 0 4 1
A setContentState() 0 4 1
A getContentState() 0 4 1
A getContentCount() 0 4 1
A newObjectStateGroupCreateStruct() 0 4 1
A newObjectStateGroupUpdateStruct() 0 4 1
A newObjectStateCreateStruct() 0 4 1
A newObjectStateUpdateStruct() 0 4 1
1
<?php
2
3
/**
4
 * ObjectStateService 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
namespace eZ\Publish\Core\Repository\SiteAccessAware;
10
11
use eZ\Publish\API\Repository\ObjectStateService as ObjectStateServiceInterface;
12
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateCreateStruct;
13
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupCreateStruct;
14
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupUpdateStruct;
15
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateUpdateStruct;
16
use eZ\Publish\API\Repository\Values\ObjectState\ObjectState;
17
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup;
18
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
19
use eZ\Publish\Core\Repository\Helper\LanguageResolver;
20
21
/**
22
 * SiteAccess aware implementation of ObjectStateService injecting languages where needed.
23
 */
24
class ObjectStateService implements ObjectStateServiceInterface
25
{
26
    /**
27
     * Aggregated service.
28
     *
29
     * @var \eZ\Publish\API\Repository\ObjectStateService
30
     */
31
    protected $service;
32
33
    /**
34
     * Language resolver
35
     *
36
     * @var LanguageResolver
37
     */
38
    protected $languageResolver;
39
40
    /**
41
     * Construct service object from aggregated service and LanguageResolver.
42
     *
43
     * @param \eZ\Publish\API\Repository\ObjectStateService $service
44
     * @param LanguageResolver $languageResolver
45
     */
46
    public function __construct(
47
        ObjectStateServiceInterface $service,
48
        LanguageResolver $languageResolver
49
    ) {
50
        $this->service = $service;
51
        $this->languageResolver = $languageResolver;
52
    }
53
54
    public function createObjectStateGroup(ObjectStateGroupCreateStruct $objectStateGroupCreateStruct)
55
    {
56
        return $this->service->createObjectStateGroup($objectStateGroupCreateStruct);
57
    }
58
59
    public function loadObjectStateGroup($objectStateGroupId, array $prioritizedLanguages = [])
60
    {
61
        $prioritizedLanguages = $this->languageResolver->getLanguages($prioritizedLanguages);
62
63
        return $this->service->loadObjectStateGroup($objectStateGroupId, $prioritizedLanguages);
64
    }
65
66
    public function loadObjectStateGroups($offset = 0, $limit = -1, array $prioritizedLanguages = [])
67
    {
68
        $prioritizedLanguages = $this->languageResolver->getLanguages($prioritizedLanguages);
69
70
        return $this->service->loadObjectStateGroups($offset, $limit, $prioritizedLanguages);
71
    }
72
73
    public function loadObjectStates(ObjectStateGroup $objectStateGroup, array $prioritizedLanguages = [])
74
    {
75
        $prioritizedLanguages = $this->languageResolver->getLanguages($prioritizedLanguages);
76
77
        return $this->service->loadObjectStates($objectStateGroup, $prioritizedLanguages);
78
    }
79
80
    public function updateObjectStateGroup(ObjectStateGroup $objectStateGroup, ObjectStateGroupUpdateStruct $objectStateGroupUpdateStruct)
81
    {
82
        return $this->service->updateObjectStateGroup($objectStateGroup, $objectStateGroupUpdateStruct);
83
    }
84
85
    public function deleteObjectStateGroup(ObjectStateGroup $objectStateGroup)
86
    {
87
        return $this->service->deleteObjectStateGroup($objectStateGroup);
88
    }
89
90
    public function createObjectState(ObjectStateGroup $objectStateGroup, ObjectStateCreateStruct $objectStateCreateStruct)
91
    {
92
        return $this->service->createObjectState($objectStateGroup, $objectStateCreateStruct);
93
    }
94
95
    public function loadObjectState($stateId, array $prioritizedLanguages = [])
96
    {
97
        $prioritizedLanguages = $this->languageResolver->getLanguages($prioritizedLanguages);
98
99
        return $this->service->loadObjectState($stateId, $prioritizedLanguages);
100
    }
101
102
    public function updateObjectState(ObjectState $objectState, ObjectStateUpdateStruct $objectStateUpdateStruct)
103
    {
104
        return $this->service->updateObjectState($objectState, $objectStateUpdateStruct);
105
    }
106
107
    public function setPriorityOfObjectState(ObjectState $objectState, $priority)
108
    {
109
        return $this->service->setPriorityOfObjectState($objectState, $priority);
110
    }
111
112
    public function deleteObjectState(ObjectState $objectState)
113
    {
114
        return $this->service->deleteObjectState($objectState);
115
    }
116
117
    public function setContentState(ContentInfo $contentInfo, ObjectStateGroup $objectStateGroup, ObjectState $objectState)
118
    {
119
        return $this->service->setContentState($contentInfo, $objectStateGroup, $objectState);
120
    }
121
122
    public function getContentState(ContentInfo $contentInfo, ObjectStateGroup $objectStateGroup)
123
    {
124
        return $this->service->getContentState($contentInfo, $objectStateGroup);
125
    }
126
127
    public function getContentCount(ObjectState $objectState)
128
    {
129
        return $this->service->getContentCount($objectState);
130
    }
131
132
    public function newObjectStateGroupCreateStruct($identifier)
133
    {
134
        return $this->service->newObjectStateGroupCreateStruct($identifier);
135
    }
136
137
    public function newObjectStateGroupUpdateStruct()
138
    {
139
        return $this->service->newObjectStateGroupUpdateStruct();
140
    }
141
142
    public function newObjectStateCreateStruct($identifier)
143
    {
144
        return $this->service->newObjectStateCreateStruct($identifier);
145
    }
146
147
    public function newObjectStateUpdateStruct()
148
    {
149
        return $this->service->newObjectStateUpdateStruct();
150
    }
151
}
152