Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Map/URI.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map;
8
9 use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map;
10 use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest;
11 use eZ\Publish\Core\MVC\Symfony\SiteAccess\URILexer;
12
13 class URI extends Map implements URILexer
14 {
20 public function setRequest(SimplifiedRequest $request)
21 {
22 if (!$this->key) {
23 sscanf($request->pathinfo, '/%[^/]', $key);
24 $this->setMapKey(rawurldecode($key));
25 }
26
27 parent::setRequest($request);
28 }
29
30 public function getName()
31 {
32 return 'uri:map';
33 }
34
42 public function analyseURI($uri)
43 {
44 if (($siteaccessPart = "/$this->key") === $uri) {
45 return '/';
46 }
47
48 if (mb_strpos($uri, $siteaccessPart) === 0) {
49 return mb_substr($uri, mb_strlen($siteaccessPart));
50 }
51
52 return $uri;
53 }
54
62 public function analyseLink($linkUri)
63 {
64 // Joining slash between uriElements and actual linkUri must be present, except if $linkUri is empty or is just the slash root.
65 $joiningSlash = empty($linkUri) || ($linkUri === '/') ? '' : '/';
66 $linkUri = ltrim($linkUri, '/');
67 // Removing query string to analyse as SiteAccess might be in it.
68 $qsPos = strpos($linkUri, '?');
69 $queryString = '';
70 if ($qsPos !== false) {
71 $queryString = substr($linkUri, $qsPos);
72 $linkUri = substr($linkUri, 0, $qsPos);
73 }
74
75 return "/{$this->key}{$joiningSlash}{$linkUri}{$queryString}";
76 }
77
78 public function reverseMatch($siteAccessName)
79 {
80 $matcher = parent::reverseMatch($siteAccessName);
81 if ($matcher instanceof self) {
82 $request = $matcher->getRequest();
83 // Clean up "old" siteaccess prefix and add the new prefix.
84 $request->setPathinfo($this->analyseLink($request->pathinfo));
85 }
86
87 return $matcher;
88 }
89 }
eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest
Definition: SimplifiedRequest.php:21
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\URI
Definition: Map/URI.php:14
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\URI\setRequest
setRequest(SimplifiedRequest $request)
Injects the request object to match against.
Definition: Map/URI.php:20
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\URI\getName
getName()
Returns the matcher's name.
Definition: Map/URI.php:30
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\URI\reverseMatch
reverseMatch($siteAccessName)
Definition: Map/URI.php:78
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\URI\analyseURI
analyseURI($uri)
Fixes up $uri to remove the siteaccess part, if needed.
Definition: Map/URI.php:42
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\URI\analyseLink
analyseLink($linkUri)
Analyses $linkUri when generating a link to a route, in order to have the siteaccess part back in the...
Definition: Map/URI.php:62
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map
Definition: Map.php:13
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\setMapKey
setMapKey($key)
Injects the key that will be used for matching against the map configuration.
Definition: Map.php:78
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\$key
$key
Definition: Map.php:19
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\$request
$request
Definition: Map.php:36
eZ\Publish\Core\MVC\Symfony\SiteAccess\$matcher
$matcher
Definition: SiteAccess.php:37
eZ\Publish\Core\MVC\Symfony\SiteAccess\URILexer
Interface for SiteAccess matchers that need to alter the URI after matching.
Definition: URILexer.php:14
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map
Definition: Map/Host.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.