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

Regex.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\Matcher;
11
12 abstract class Regex implements Matcher
13 {
19 protected $element;
20
26 protected $regex;
27
33 protected $itemNumber;
34
36 protected $request;
37
39 protected $matchedSiteAccess;
40
47 public function __construct($regex, $itemNumber)
48 {
49 $this->regex = $regex;
50 $this->itemNumber = $itemNumber;
51 }
52
53 public function __sleep()
54 {
55 return ['regex', 'itemNumber', 'matchedSiteAccess'];
56 }
57
58 public function match()
59 {
60 return $this->getMatchedSiteAccess();
61 }
62
68 protected function getMatchedSiteAccess()
69 {
70 if (isset($this->matchedSiteAccess)) {
71 return $this->matchedSiteAccess;
72 }
73
74 preg_match(
75 "@{$this->regex}@",
76 $this->element,
77 $match
78 );
79
80 $this->matchedSiteAccess = isset($match[$this->itemNumber]) ? $match[$this->itemNumber] : false;
81
82 return $this->matchedSiteAccess;
83 }
84
90 public function setRequest(SimplifiedRequest $request)
91 {
92 $this->request = $request;
93 }
94
100 public function setMatchElement($element)
101 {
102 $this->element = $element;
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\getMatchedSiteAccess
getMatchedSiteAccess()
Returns matched SiteAccess.
Definition: Regex.php:68
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\$regex
$regex
Definition: Regex.php:26
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\$matchedSiteAccess
$matchedSiteAccess
Definition: Regex.php:39
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\setRequest
setRequest(SimplifiedRequest $request)
Injects the request object to match against.
Definition: Regex.php:90
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\__sleep
__sleep()
Definition: Regex.php:53
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\$itemNumber
$itemNumber
Definition: Regex.php:33
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\$element
$element
Definition: Regex.php:19
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\$request
$request
Definition: Regex.php:36
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\__construct
__construct($regex, $itemNumber)
Constructor.
Definition: Regex.php:47
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher
Interface for SiteAccess matchers.
Definition: Publish/Core/MVC/Symfony/SiteAccess/Matcher.php:15
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.