PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / nikic / fast-route / src / Dispatcher / RegexBasedAbstract.php
ameliabooking / vendor / nikic / fast-route / src / Dispatcher Last commit date
CharCountBased.php 7 years ago GroupCountBased.php 7 years ago GroupPosBased.php 7 years ago MarkBased.php 7 years ago RegexBasedAbstract.php 7 years ago
RegexBasedAbstract.php
89 lines
1 <?php
2
3 namespace FastRoute\Dispatcher;
4
5 use FastRoute\Dispatcher;
6
7 abstract class RegexBasedAbstract implements Dispatcher
8 {
9 /** @var mixed[][] */
10 protected $staticRouteMap = [];
11
12 /** @var mixed[] */
13 protected $variableRouteData = [];
14
15 /**
16 * @return mixed[]
17 */
18 abstract protected function dispatchVariableRoute($routeData, $uri);
19
20 public function dispatch($httpMethod, $uri)
21 {
22 if (isset($this->staticRouteMap[$httpMethod][$uri])) {
23 $handler = $this->staticRouteMap[$httpMethod][$uri];
24 return [self::FOUND, $handler, []];
25 }
26
27 $varRouteData = $this->variableRouteData;
28 if (isset($varRouteData[$httpMethod])) {
29 $result = $this->dispatchVariableRoute($varRouteData[$httpMethod], $uri);
30 if ($result[0] === self::FOUND) {
31 return $result;
32 }
33 }
34
35 // For HEAD requests, attempt fallback to GET
36 if ($httpMethod === 'HEAD') {
37 if (isset($this->staticRouteMap['GET'][$uri])) {
38 $handler = $this->staticRouteMap['GET'][$uri];
39 return [self::FOUND, $handler, []];
40 }
41 if (isset($varRouteData['GET'])) {
42 $result = $this->dispatchVariableRoute($varRouteData['GET'], $uri);
43 if ($result[0] === self::FOUND) {
44 return $result;
45 }
46 }
47 }
48
49 // If nothing else matches, try fallback routes
50 if (isset($this->staticRouteMap['*'][$uri])) {
51 $handler = $this->staticRouteMap['*'][$uri];
52 return [self::FOUND, $handler, []];
53 }
54 if (isset($varRouteData['*'])) {
55 $result = $this->dispatchVariableRoute($varRouteData['*'], $uri);
56 if ($result[0] === self::FOUND) {
57 return $result;
58 }
59 }
60
61 // Find allowed methods for this URI by matching against all other HTTP methods as well
62 $allowedMethods = [];
63
64 foreach ($this->staticRouteMap as $method => $uriMap) {
65 if ($method !== $httpMethod && isset($uriMap[$uri])) {
66 $allowedMethods[] = $method;
67 }
68 }
69
70 foreach ($varRouteData as $method => $routeData) {
71 if ($method === $httpMethod) {
72 continue;
73 }
74
75 $result = $this->dispatchVariableRoute($routeData, $uri);
76 if ($result[0] === self::FOUND) {
77 $allowedMethods[] = $method;
78 }
79 }
80
81 // If there are no allowed methods the route simply does not exist
82 if ($allowedMethods) {
83 return [self::METHOD_NOT_ALLOWED, $allowedMethods];
84 }
85
86 return [self::NOT_FOUND];
87 }
88 }
89