|
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
|
|
|
/** @var \eZ\Publish\API\Repository\URLAliasService */ |
|
21
|
|
|
protected $service; |
|
22
|
|
|
|
|
23
|
|
|
/** @var LanguageResolver */ |
|
24
|
|
|
protected $languageResolver; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Construct service object from aggregated service and LanguageResolver. |
|
28
|
|
|
* |
|
29
|
|
|
* @param \eZ\Publish\API\Repository\URLAliasService $service |
|
30
|
|
|
* @param LanguageResolver $languageResolver |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct( |
|
33
|
|
|
URLAliasServiceInterface $service, |
|
34
|
|
|
LanguageResolver $languageResolver |
|
35
|
|
|
) { |
|
36
|
|
|
$this->service = $service; |
|
37
|
|
|
$this->languageResolver = $languageResolver; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function createUrlAlias(Location $location, $path, $languageCode, $forwarding = false, $alwaysAvailable = false) |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->service->createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function createGlobalUrlAlias($resource, $path, $languageCode, $forwarding = false, $alwaysAvailable = false) |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->service->createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
View Code Duplication |
public function listLocationAliases( |
|
51
|
|
|
Location $location, |
|
52
|
|
|
$custom = true, |
|
53
|
|
|
$languageCode = null, |
|
54
|
|
|
bool $showAllTranslations = null, |
|
55
|
|
|
array $prioritizedLanguages = null |
|
56
|
|
|
) { |
|
57
|
|
|
return $this->service->listLocationAliases( |
|
58
|
|
|
$location, |
|
59
|
|
|
$custom, |
|
60
|
|
|
$languageCode, |
|
61
|
|
|
$this->languageResolver->getShowAllTranslations($showAllTranslations), |
|
62
|
|
|
$this->languageResolver->getPrioritizedLanguages($prioritizedLanguages) |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function listGlobalAliases($languageCode = null, $offset = 0, $limit = -1) |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->service->listGlobalAliases($languageCode, $offset, $limit); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function removeAliases(array $aliasList) |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->service->removeAliases($aliasList); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function lookup($url, $languageCode = null) |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->service->lookup($url, $languageCode); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
View Code Duplication |
public function reverseLookup( |
|
82
|
|
|
Location $location, |
|
83
|
|
|
$languageCode = null, |
|
84
|
|
|
bool $showAllTranslations = null, |
|
85
|
|
|
array $prioritizedLanguages = null |
|
86
|
|
|
) { |
|
87
|
|
|
return $this->service->reverseLookup( |
|
88
|
|
|
$location, |
|
89
|
|
|
$languageCode, |
|
90
|
|
|
$this->languageResolver->getShowAllTranslations($showAllTranslations), |
|
91
|
|
|
$this->languageResolver->getPrioritizedLanguages($prioritizedLanguages) |
|
92
|
|
|
); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function load($id) |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->service->load($id); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|