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

URIText.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
8
9 use eZ\Publish\Core\MVC\Symfony\SiteAccess\VersatileMatcher;
10 use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest;
11 use eZ\Publish\Core\MVC\Symfony\SiteAccess\URILexer;
12
13 class URIText extends Regex implements VersatileMatcher, URILexer
14 {
16 private $prefix;
17
19 private $suffix;
20
26 private $siteAccessesConfiguration;
27
33 public function __construct(array $siteAccessesConfiguration)
34 {
35 $this->prefix = isset($siteAccessesConfiguration['prefix']) ? $siteAccessesConfiguration['prefix'] : '';
36 $this->suffix = isset($siteAccessesConfiguration['suffix']) ? $siteAccessesConfiguration['suffix'] : '';
37
38 parent::__construct(
39 '^(/' . preg_quote($this->prefix, '@') . '(\w+)' . preg_quote($this->suffix, '@') . ')',
40 2
41 );
42 $this->siteAccessesConfiguration = $siteAccessesConfiguration;
43 }
44
45 public function getName()
46 {
47 return 'uri:text';
48 }
49
55 public function setRequest(SimplifiedRequest $request)
56 {
57 if (!$this->element) {
58 $this->setMatchElement($request->pathinfo);
59 }
60
61 parent::setRequest($request);
62 }
63
71 public function analyseURI($uri)
72 {
73 $uri = '/' . ltrim($uri, '/');
74
75 return preg_replace("@$this->regex@", '', $uri);
76 }
77
85 public function analyseLink($linkUri)
86 {
87 $linkUri = '/' . ltrim($linkUri, '/');
88 $siteAccessUri = "/$this->prefix" . $this->match() . $this->suffix;
89
90 return $siteAccessUri . $linkUri;
91 }
92
93 public function reverseMatch($siteAccessName)
94 {
95 $this->request->setPathinfo("/{$this->prefix}{$siteAccessName}{$this->suffix}{$this->request->pathinfo}");
96
97 return $this;
98 }
99
100 public function getRequest()
101 {
102 return $this->request;
103 }
104 }
eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest
Definition: SimplifiedRequest.php:21
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex
Definition: Regex.php:13
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\setMatchElement
setMatchElement($element)
Injects element to match against with the regexp.
Definition: Regex.php:100
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\match
match()
Returns matched Siteaccess or false if no siteaccess could be matched.
Definition: Regex.php:58
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\$request
$request
Definition: Regex.php:36
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText
Definition: URIText.php:14
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\getRequest
getRequest()
Returns the SimplifiedRequest object corresponding to the reverse match.
Definition: URIText.php:100
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\analyseURI
analyseURI($uri)
Analyses $uri and removes the siteaccess part, if needed.
Definition: URIText.php:71
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\$suffix
$suffix
Definition: URIText.php:19
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\$siteAccessesConfiguration
$siteAccessesConfiguration
Definition: URIText.php:26
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\__construct
__construct(array $siteAccessesConfiguration)
Constructor.
Definition: URIText.php:33
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\analyseLink
analyseLink($linkUri)
Analyses $linkUri when generating a link to a route, in order to have the siteaccess part back in the...
Definition: URIText.php:85
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\reverseMatch
reverseMatch($siteAccessName)
Returns matcher object corresponding to $siteAccessName or null if non applicable.
Definition: URIText.php:93
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\$prefix
$prefix
Definition: URIText.php:16
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\getName
getName()
Returns the matcher's name.
Definition: URIText.php:45
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText\setRequest
setRequest(SimplifiedRequest $request)
Injects the request object to match against.
Definition: URIText.php:55
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher
Interface for SiteAccess matchers.
Definition: Publish/Core/MVC/Symfony/SiteAccess/Matcher.php:15
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\VersatileMatcher
Interface for SiteAccess matchers.
Definition: VersatileMatcher.php:16
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.