Completed
Push — EZP-31584 ( d4db81 )
by
unknown
18:34
created

LocationService::loadFirstAvailableLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
nc 1
nop 2
rs 10
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Repository\SiteAccessAware;
8
9
use eZ\Publish\API\Repository\LocationService as LocationServiceInterface;
10
use eZ\Publish\API\Repository\Values\Content\Location;
11
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
12
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
13
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
14
use eZ\Publish\API\Repository\Values\Content\LocationUpdateStruct;
15
use eZ\Publish\API\Repository\LanguageResolver;
16
17
/**
18
 * LocationService for SiteAccessAware layer.
19
 *
20
 * Currently does nothing but hand over calls to aggregated service.
21
 */
22
class LocationService implements LocationServiceInterface
23
{
24
    /** @var \eZ\Publish\API\Repository\LocationService */
25
    protected $service;
26
27
    /** @var \eZ\Publish\API\Repository\LanguageResolver */
28
    protected $languageResolver;
29
30
    /**
31
     * Construct service object from aggregated service and LanguageResolver.
32
     *
33
     * @param \eZ\Publish\API\Repository\LocationService $service
34
     * @param \eZ\Publish\API\Repository\LanguageResolver $languageResolver
35
     */
36
    public function __construct(
37
        LocationServiceInterface $service,
38
        LanguageResolver $languageResolver
39
    ) {
40
        $this->service = $service;
41
        $this->languageResolver = $languageResolver;
42
    }
43
44
    public function copySubtree(Location $subtree, Location $targetParentLocation)
45
    {
46
        return $this->service->copySubtree($subtree, $targetParentLocation);
47
    }
48
49 View Code Duplication
    public function loadLocation($locationId, array $prioritizedLanguages = null, bool $useAlwaysAvailable = null)
50
    {
51
        return $this->service->loadLocation(
52
            $locationId,
53
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages),
54
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
55
        );
56
    }
57
58
    public function loadLocationList(array $locationIds, array $prioritizedLanguages = null, bool $useAlwaysAvailable = null): iterable
59
    {
60
        return $this->service->loadLocationList(
61
            $locationIds,
62
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages),
63
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
64
        );
65
    }
66
67 View Code Duplication
    public function loadLocationByRemoteId($remoteId, array $prioritizedLanguages = null, bool $useAlwaysAvailable = null)
68
    {
69
        return $this->service->loadLocationByRemoteId(
70
            $remoteId,
71
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages),
72
            $this->languageResolver->getUseAlwaysAvailable($useAlwaysAvailable)
73
        );
74
    }
75
76
    public function loadLocations(ContentInfo $contentInfo, Location $rootLocation = null, array $prioritizedLanguages = null)
77
    {
78
        return $this->service->loadLocations(
79
            $contentInfo,
80
            $rootLocation,
81
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
82
        );
83
    }
84
85
    public function loadLocationChildren(Location $location, $offset = 0, $limit = 25, array $prioritizedLanguages = null)
86
    {
87
        return $this->service->loadLocationChildren(
88
            $location,
89
            $offset,
90
            $limit,
91
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
92
        );
93
    }
94
95
    public function loadParentLocationsForDraftContent(VersionInfo $versionInfo, array $prioritizedLanguages = null)
96
    {
97
        return $this->service->loadParentLocationsForDraftContent(
98
            $versionInfo,
99
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
100
        );
101
    }
102
103
    public function getLocationChildCount(Location $location)
104
    {
105
        return $this->service->getLocationChildCount($location);
106
    }
107
108
    public function createLocation(ContentInfo $contentInfo, LocationCreateStruct $locationCreateStruct)
109
    {
110
        return $this->service->createLocation($contentInfo, $locationCreateStruct);
111
    }
112
113
    public function updateLocation(Location $location, LocationUpdateStruct $locationUpdateStruct)
114
    {
115
        return $this->service->updateLocation($location, $locationUpdateStruct);
116
    }
117
118
    public function swapLocation(Location $location1, Location $location2)
119
    {
120
        return $this->service->swapLocation($location1, $location2);
121
    }
122
123
    public function hideLocation(Location $location)
124
    {
125
        return $this->service->hideLocation($location);
126
    }
127
128
    public function unhideLocation(Location $location)
129
    {
130
        return $this->service->unhideLocation($location);
131
    }
132
133
    public function moveSubtree(Location $location, Location $newParentLocation)
134
    {
135
        return $this->service->moveSubtree($location, $newParentLocation);
136
    }
137
138
    public function deleteLocation(Location $location)
139
    {
140
        $this->service->deleteLocation($location);
141
    }
142
143
    public function newLocationCreateStruct($parentLocationId)
144
    {
145
        return $this->service->newLocationCreateStruct($parentLocationId);
146
    }
147
148
    public function newLocationUpdateStruct()
149
    {
150
        return $this->service->newLocationUpdateStruct();
151
    }
152
153
    /**
154
     * Get the total number of all existing Locations. Can be combined with loadAllLocations.
155
     *
156
     * @see loadAllLocations
157
     *
158
     * @return int Total number of Locations
159
     */
160
    public function getAllLocationsCount(): int
161
    {
162
        return $this->service->getAllLocationsCount();
163
    }
164
165
    /**
166
     * Bulk-load all existing Locations, constrained by $limit and $offset to paginate results.
167
     *
168
     * @param int $limit
169
     * @param int $offset
170
     *
171
     * @return \eZ\Publish\API\Repository\Values\Content\Location[]
172
     */
173
    public function loadAllLocations(int $offset = 0, int $limit = 25): array
174
    {
175
        return $this->service->loadAllLocations($offset, $limit);
176
    }
177
178
    public function loadFirstAvailableLocation(ContentInfo $contentInfo, array $prioritizedLanguages = null): Location
179
    {
180
        return $this->service->loadFirstAvailableLocation($contentInfo, $prioritizedLanguages);
181
    }
182
}
183