Completed
Push — siteaccessaware-layer-only ( 7e91dd...edaec2 )
by André
56:17 queued 37:14
created

LocationService   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

17 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A copySubtree() 0 4 1
A loadLocation() 0 7 1
A loadLocationByRemoteId() 0 7 1
A loadLocations() 0 8 1
A loadLocationChildren() 0 9 1
A loadParentLocationsForDraftContent() 0 7 1
A getLocationChildCount() 0 4 1
A createLocation() 0 4 1
A updateLocation() 0 4 1
A swapLocation() 0 4 1
A hideLocation() 0 4 1
A unhideLocation() 0 4 1
A moveSubtree() 0 4 1
A deleteLocation() 0 4 1
A newLocationCreateStruct() 0 4 1
A newLocationUpdateStruct() 0 4 1
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\Helper\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 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 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
    public function loadLocation($locationId, array $prioritizedLanguages = null)
52
    {
53
        return $this->service->loadLocation(
54
            $locationId,
55
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
0 ignored issues
show
Bug introduced by
It seems like $this->languageResolver-...($prioritizedLanguages) targeting eZ\Publish\Core\Reposito...tPrioritizedLanguages() can also be of type array; however, eZ\Publish\API\Repositor...Service::loadLocation() does only seem to accept null|array<integer,string>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
56
        );
57
    }
58
59
    public function loadLocationByRemoteId($remoteId, array $prioritizedLanguages = null)
60
    {
61
        return $this->service->loadLocationByRemoteId(
62
            $remoteId,
63
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
0 ignored issues
show
Bug introduced by
It seems like $this->languageResolver-...($prioritizedLanguages) targeting eZ\Publish\Core\Reposito...tPrioritizedLanguages() can also be of type array; however, eZ\Publish\API\Repositor...oadLocationByRemoteId() does only seem to accept null|array<integer,string>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
64
        );
65
    }
66
67
    public function loadLocations(ContentInfo $contentInfo, Location $rootLocation = null, array $prioritizedLanguages = null)
68
    {
69
        return $this->service->loadLocations(
70
            $contentInfo,
71
            $rootLocation,
72
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
0 ignored issues
show
Bug introduced by
It seems like $this->languageResolver-...($prioritizedLanguages) targeting eZ\Publish\Core\Reposito...tPrioritizedLanguages() can also be of type array; however, eZ\Publish\API\Repositor...ervice::loadLocations() does only seem to accept null|array<integer,string>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
73
        );
74
    }
75
76
    public function loadLocationChildren(Location $location, $offset = 0, $limit = 25, array $prioritizedLanguages = null)
77
    {
78
        return $this->service->loadLocationChildren(
79
            $location,
80
            $offset,
81
            $limit,
82
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
0 ignored issues
show
Bug introduced by
It seems like $this->languageResolver-...($prioritizedLanguages) targeting eZ\Publish\Core\Reposito...tPrioritizedLanguages() can also be of type array; however, eZ\Publish\API\Repositor...:loadLocationChildren() does only seem to accept null|array<integer,string>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
83
        );
84
    }
85
86
    public function loadParentLocationsForDraftContent(VersionInfo $versionInfo, array $prioritizedLanguages = null)
87
    {
88
        return $this->service->loadParentLocationsForDraftContent(
89
            $versionInfo,
90
            $this->languageResolver->getPrioritizedLanguages($prioritizedLanguages)
0 ignored issues
show
Bug introduced by
It seems like $this->languageResolver-...($prioritizedLanguages) targeting eZ\Publish\Core\Reposito...tPrioritizedLanguages() can also be of type array; however, eZ\Publish\API\Repositor...ationsForDraftContent() does only seem to accept null|array<integer,string>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
91
        );
92
    }
93
94
    public function getLocationChildCount(Location $location)
95
    {
96
        return $this->service->getLocationChildCount($location);
97
    }
98
99
    public function createLocation(ContentInfo $contentInfo, LocationCreateStruct $locationCreateStruct)
100
    {
101
        return $this->service->createLocation($contentInfo, $locationCreateStruct);
102
    }
103
104
    public function updateLocation(Location $location, LocationUpdateStruct $locationUpdateStruct)
105
    {
106
        return $this->service->updateLocation($location, $locationUpdateStruct);
107
    }
108
109
    public function swapLocation(Location $location1, Location $location2)
110
    {
111
        return $this->service->swapLocation($location1, $location2);
112
    }
113
114
    public function hideLocation(Location $location)
115
    {
116
        return $this->service->hideLocation($location);
117
    }
118
119
    public function unhideLocation(Location $location)
120
    {
121
        return $this->service->unhideLocation($location);
122
    }
123
124
    public function moveSubtree(Location $location, Location $newParentLocation)
125
    {
126
        return $this->service->moveSubtree($location, $newParentLocation);
127
    }
128
129
    public function deleteLocation(Location $location)
130
    {
131
        $this->service->deleteLocation($location);
132
    }
133
134
    public function newLocationCreateStruct($parentLocationId)
135
    {
136
        return $this->service->newLocationCreateStruct($parentLocationId);
137
    }
138
139
    public function newLocationUpdateStruct()
140
    {
141
        return $this->service->newLocationUpdateStruct();
142
    }
143
}
144