1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
5
|
|
|
*/ |
6
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\Routing\JsRouting; |
7
|
|
|
|
8
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess; |
9
|
|
|
use FOS\JsRoutingBundle\Extractor\ExposedRoutesExtractorInterface; |
10
|
|
|
use Symfony\Component\HttpFoundation\Request; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Decorator of FOSJsRouting routes extractor. |
14
|
|
|
* Ensures that base URL contains the SiteAccess part when applicable. |
15
|
|
|
*/ |
16
|
|
|
class ExposedRoutesExtractor implements ExposedRoutesExtractorInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var ExposedRoutesExtractorInterface |
20
|
|
|
*/ |
21
|
|
|
private $innerExtractor; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var Request |
25
|
|
|
*/ |
26
|
|
|
private $masterRequest; |
27
|
|
|
|
28
|
|
|
public function __construct(ExposedRoutesExtractorInterface $innerExtractor, Request $masterRequest) |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$this->innerExtractor = $innerExtractor; |
31
|
|
|
$this->masterRequest = $masterRequest; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getRoutes() |
35
|
|
|
{ |
36
|
|
|
return $this->innerExtractor->getRoutes(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
* |
42
|
|
|
* Will add the SiteAccess if configured in the URI. |
43
|
|
|
* |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
public function getBaseUrl() |
47
|
|
|
{ |
48
|
|
|
$baseUrl = $this->innerExtractor->getBaseUrl(); |
49
|
|
|
$siteAccess = $this->masterRequest->attributes->get('siteaccess'); |
50
|
|
|
if ($siteAccess instanceof SiteAccess && $siteAccess->matcher instanceof SiteAccess\URILexer) { |
51
|
|
|
$baseUrl .= $siteAccess->matcher->analyseLink(''); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $baseUrl; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getPrefix($locale) |
58
|
|
|
{ |
59
|
|
|
return $this->innerExtractor->getPrefix($locale); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getHost() |
63
|
|
|
{ |
64
|
|
|
return $this->innerExtractor->getHost(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getScheme() |
68
|
|
|
{ |
69
|
|
|
return $this->innerExtractor->getScheme(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getCachePath($locale) |
73
|
|
|
{ |
74
|
|
|
return $this->innerExtractor->getCachePath($locale); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getResources() |
78
|
|
|
{ |
79
|
|
|
return $this->innerExtractor->getResources(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getExposedRoutes() |
83
|
|
|
{ |
84
|
|
|
return $this->innerExtractor->getExposedRoutes(); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|