ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FastRoute\Dispatcher\RegexBasedAbstract Class Reference
+ Inheritance diagram for FastRoute\Dispatcher\RegexBasedAbstract:
+ Collaboration diagram for FastRoute\Dispatcher\RegexBasedAbstract:

Public Member Functions

 dispatch ($httpMethod, $uri)
 Dispatches against the provided HTTP method verb and URI. More...
 
 dispatch ($httpMethod, $uri)
 Dispatches against the provided HTTP method verb and URI. More...
 

Protected Member Functions

 dispatchVariableRoute ($routeData, $uri)
 

Protected Attributes

 $staticRouteMap = []
 
 $variableRouteData = []
 

Additional Inherited Members

- Data Fields inherited from FastRoute\Dispatcher
const NOT_FOUND = 0
 
const FOUND = 1
 
const METHOD_NOT_ALLOWED = 2
 

Detailed Description

Definition at line 7 of file RegexBasedAbstract.php.

Member Function Documentation

◆ dispatch()

FastRoute\Dispatcher\RegexBasedAbstract::dispatch (   $httpMethod,
  $uri 
)

Dispatches against the provided HTTP method verb and URI.

Returns array with one of the following formats:

[self::NOT_FOUND]
[self::METHOD_NOT_ALLOWED, ['GET', 'OTHER_ALLOWED_METHODS']]
[self::FOUND, $handler, ['varName' => 'value', ...]]
Parameters
string$httpMethod
string$uri
Returns
array

Implements FastRoute\Dispatcher.

Definition at line 20 of file RegexBasedAbstract.php.

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 }
$result
$handler

References $handler, $result, FastRoute\Dispatcher\RegexBasedAbstract\$variableRouteData, FastRoute\Dispatcher\RegexBasedAbstract\dispatchVariableRoute(), FastRoute\Dispatcher\FOUND, FastRoute\Dispatcher\METHOD_NOT_ALLOWED, and FastRoute\Dispatcher\NOT_FOUND.

+ Here is the call graph for this function:

◆ dispatchVariableRoute()

FastRoute\Dispatcher\RegexBasedAbstract::dispatchVariableRoute (   $routeData,
  $uri 
)
abstractprotected

Field Documentation

◆ $staticRouteMap

FastRoute\Dispatcher\RegexBasedAbstract::$staticRouteMap = []
protected

Definition at line 10 of file RegexBasedAbstract.php.

◆ $variableRouteData

FastRoute\Dispatcher\RegexBasedAbstract::$variableRouteData = []
protected

The documentation for this class was generated from the following file: