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

Map.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 abstract class Map implements VersatileMatcher
13 {
19 protected $key;
20
26 protected $map = [];
27
33 protected $reverseMap = [];
34
36 protected $request;
37
43 public function __construct(array $map)
44 {
45 $this->map = $map;
46 }
47
55 public function __sleep()
56 {
57 $this->map = [];
58 $this->reverseMap = [];
59
60 return ['map', 'reverseMap', 'key'];
61 }
62
63 public function setRequest(SimplifiedRequest $request)
64 {
65 $this->request = $request;
66 }
67
68 public function getRequest()
69 {
70 return $this->request;
71 }
72
78 public function setMapKey($key)
79 {
80 $this->key = $key;
81 }
82
86 public function getMapKey()
87 {
88 return $this->key;
89 }
90
96 public function match()
97 {
98 return isset($this->map[$this->key])
99 ? $this->map[$this->key]
100 : false;
101 }
102
108 public function reverseMatch($siteAccessName)
109 {
110 $reverseMap = $this->getReverseMap($siteAccessName);
111
112 if (!isset($reverseMap[$siteAccessName])) {
113 return null;
114 }
115
116 $this->setMapKey($reverseMap[$siteAccessName]);
117
118 return $this;
119 }
120
121 private function getReverseMap($defaultSiteAccess)
122 {
123 if (!empty($this->reverseMap)) {
124 return $this->reverseMap;
125 }
126
127 $map = $this->map;
128 foreach ($map as &$value) {
129 // $value can be true in the case of the use of a Compound matcher
130 if ($value === true) {
131 $value = $defaultSiteAccess;
132 }
133 }
134
135 return $this->reverseMap = array_flip($map);
136 }
137 }
eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest
Definition: SimplifiedRequest.php:21
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map
Definition: Map.php:13
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\match
match()
Returns matching Siteaccess.
Definition: Map.php:96
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\getMapKey
getMapKey()
Definition: Map.php:86
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\getRequest
getRequest()
Returns the SimplifiedRequest object corresponding to the reverse match.
Definition: Map.php:68
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\__sleep
__sleep()
Do not serialize the Siteaccess configuration in order to reduce ESI request URL size.
Definition: Map.php:55
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\getReverseMap
getReverseMap($defaultSiteAccess)
Definition: Map.php:121
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\$reverseMap
$reverseMap
Definition: Map.php:33
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\__construct
__construct(array $map)
Constructor.
Definition: Map.php:43
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\reverseMatch
reverseMatch($siteAccessName)
Definition: Map.php:108
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\setRequest
setRequest(SimplifiedRequest $request)
Injects the request object to match against.
Definition: Map.php:63
eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Map\$map
$map
Definition: Map.php:26
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
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+.