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

URLAliasService::createGlobalUrlAlias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 5
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * URLAliasService 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\URLAliasService as URLAliasServiceInterface;
12
use eZ\Publish\API\Repository\Values\Content\Location;
13
use eZ\Publish\Core\Repository\Helper\LanguageResolver;
14
15
/**
16
 * SiteAccess aware implementation of URLAliasService injecting languages where needed.
17
 */
18
class URLAliasService implements URLAliasServiceInterface
19
{
20
    /**
21
     * Aggregated service.
22
     *
23
     * @var \eZ\Publish\API\Repository\URLAliasService
24
     */
25
    protected $service;
26
27
    /**
28
     * Language resolver
29
     *
30
     * @var LanguageResolver
31
     */
32
    protected $languageResolver;
33
34
    /**
35
     * Construct service object from aggregated service and LanguageResolver.
36
     *
37
     * @param \eZ\Publish\API\Repository\URLAliasService $service
38
     * @param LanguageResolver $languageResolver
39
     */
40
    public function __construct(
41
        URLAliasServiceInterface $service,
42
        LanguageResolver $languageResolver
43
    ) {
44
        $this->service = $service;
45
        $this->languageResolver = $languageResolver;
46
    }
47
48
    public function createUrlAlias(Location $location, $path, $languageCode, $forwarding = false, $alwaysAvailable = false)
49
    {
50
        return $this->service->createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable);
51
    }
52
53
    public function createGlobalUrlAlias($resource, $path, $languageCode, $forwarding = false, $alwaysAvailable = false)
54
    {
55
        return $this->service->createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable);
56
    }
57
58 View Code Duplication
    public function listLocationAliases(
59
        Location $location,
60
        $custom = true,
61
        $languageCode = null,
62
        $showAllTranslations = null,
63
        array $prioritizedLanguageList = null
64
    ) {
65
        $prioritizedLanguageList = $this->languageResolver->getLanguages($prioritizedLanguageList ?: []);
66
67
        return $this->service->listLocationAliases(
68
            $location,
69
            $custom,
70
            $languageCode,
71
            $showAllTranslations,
72
            $prioritizedLanguageList
73
        );
74
    }
75
76
    public function listGlobalAliases($languageCode = null, $offset = 0, $limit = -1)
77
    {
78
        return $this->service->listGlobalAliases($languageCode, $offset, $limit);
79
    }
80
81
    public function removeAliases(array $aliasList)
82
    {
83
        return $this->service->removeAliases($aliasList);
84
    }
85
86
    public function lookup($url, $languageCode = null)
87
    {
88
        return $this->service->lookup($url, $languageCode);
89
    }
90
91 View Code Duplication
    public function reverseLookup(
92
        Location $location,
93
        $languageCode = null,
94
        $showAllTranslations = null,
95
        array $prioritizedLanguageList = null
96
    ) {
97
        $prioritizedLanguageList = $this->languageResolver->getLanguages($prioritizedLanguageList ?: []);
98
99
        return $this->service->reverseLookup(
100
            $location,
101
            $languageCode,
102
            $showAllTranslations,
103
            $prioritizedLanguageList
104
        );
105
    }
106
107
    public function load($id)
108
    {
109
        return $this->service->load($id);
110
    }
111
}
112