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

HostText.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\Routing\SimplifiedRequest;
10 use eZ\Publish\Core\MVC\Symfony\SiteAccess\VersatileMatcher;
11
12 class HostText extends Regex implements VersatileMatcher
13 {
14 private $prefix;
15
16 private $suffix;
17
23 private $siteAccessesConfiguration;
24
30 public function __construct(array $siteAccessesConfiguration)
31 {
32 $this->prefix = isset($siteAccessesConfiguration['prefix']) ? $siteAccessesConfiguration['prefix'] : '';
33 $this->suffix = isset($siteAccessesConfiguration['suffix']) ? $siteAccessesConfiguration['suffix'] : '';
34 parent::__construct(
35 '^' . preg_quote($this->prefix, '@') . "(\w+)" . preg_quote($this->suffix, '@') . '$',
36 1
37 );
38 $this->siteAccessesConfiguration = $siteAccessesConfiguration;
39 }
40
41 public function getName()
42 {
43 return 'host:text';
44 }
45
51 public function setRequest(SimplifiedRequest $request)
52 {
53 if (!$this->element) {
54 $this->setMatchElement($request->host);
55 }
56
57 parent::setRequest($request);
58 }
59
60 public function reverseMatch($siteAccessName)
61 {
62 $this->request->setHost($this->prefix . $siteAccessName . $this->suffix);
63
64 return $this;
65 }
66
67 public function getRequest()
68 {
69 return $this->request;
70 }
71 }
eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest
Definition: SimplifiedRequest.php:21
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText
Definition: HostText.php:13
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\getRequest
getRequest()
Returns the SimplifiedRequest object corresponding to the reverse match.
Definition: HostText.php:67
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\setRequest
setRequest(SimplifiedRequest $request)
Injects the request object to match against.
Definition: HostText.php:51
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\$suffix
$suffix
Definition: HostText.php:16
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\$siteAccessesConfiguration
$siteAccessesConfiguration
Definition: HostText.php:23
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\__construct
__construct(array $siteAccessesConfiguration)
Constructor.
Definition: HostText.php:30
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\getName
getName()
Returns the matcher's name.
Definition: HostText.php:41
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\$prefix
$prefix
Definition: HostText.php:14
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostText\reverseMatch
reverseMatch($siteAccessName)
Returns matcher object corresponding to $siteAccessName or null if non applicable.
Definition: HostText.php:60
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\$request
$request
Definition: Regex.php:36
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\VersatileMatcher
Interface for SiteAccess matchers.
Definition: VersatileMatcher.php:16
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.