Completed
Push — master ( 08b605...3e0b85 )
by Łukasz
22:32
created

LocationService::swapLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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