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

Public Member Functions

 __construct (RouteParser $routeParser, DataGenerator $dataGenerator)
 Constructs a route collector. More...
 
 addRoute ($httpMethod, $route, $handler)
 Adds a route to the collection. More...
 
 addGroup ($prefix, callable $callback)
 Create a route group with a common prefix. More...
 
 get ($route, $handler)
 Adds a GET route to the collection. More...
 
 post ($route, $handler)
 Adds a POST route to the collection. More...
 
 put ($route, $handler)
 Adds a PUT route to the collection. More...
 
 delete ($route, $handler)
 Adds a DELETE route to the collection. More...
 
 patch ($route, $handler)
 Adds a PATCH route to the collection. More...
 
 head ($route, $handler)
 Adds a HEAD route to the collection. More...
 
 getData ()
 Returns the collected route data, as provided by the data generator. More...
 

Protected Attributes

 $routeParser
 
 $dataGenerator
 
 $currentGroupPrefix
 

Detailed Description

Definition at line 5 of file RouteCollector.php.

Constructor & Destructor Documentation

◆ __construct()

FastRoute\RouteCollector::__construct ( RouteParser  $routeParser,
DataGenerator  $dataGenerator 
)

Constructs a route collector.

Parameters
RouteParser$routeParser
DataGenerator$dataGenerator

Definition at line 22 of file RouteCollector.php.

23  {
24  $this->routeParser = $routeParser;
25  $this->dataGenerator = $dataGenerator;
26  $this->currentGroupPrefix = '';
27  }

Member Function Documentation

◆ addGroup()

FastRoute\RouteCollector::addGroup (   $prefix,
callable  $callback 
)

Create a route group with a common prefix.

All routes created in the passed callback will have the given group prefix prepended.

Parameters
string$prefix
callable$callback

Definition at line 57 of file RouteCollector.php.

Referenced by FastRoute\RouteCollectorTest\testGroups().

58  {
59  $previousGroupPrefix = $this->currentGroupPrefix;
60  $this->currentGroupPrefix = $previousGroupPrefix . $prefix;
61  $callback($this);
62  $this->currentGroupPrefix = $previousGroupPrefix;
63  }
+ Here is the caller graph for this function:

◆ addRoute()

FastRoute\RouteCollector::addRoute (   $httpMethod,
  $route,
  $handler 
)

Adds a route to the collection.

The syntax used in the $route string depends on the used route parser.

Parameters
string|string[]$httpMethod
string$route
mixed$handler

Definition at line 38 of file RouteCollector.php.

References $handler.

Referenced by FastRoute\Dispatcher\DispatcherTest\testCapturing(), FastRoute\Dispatcher\DispatcherTest\testDuplicateStaticRoute(), FastRoute\Dispatcher\DispatcherTest\testDuplicateVariableNameError(), FastRoute\Dispatcher\DispatcherTest\testDuplicateVariableRoute(), and FastRoute\Dispatcher\DispatcherTest\testShadowedStaticRoute().

39  {
40  $route = $this->currentGroupPrefix . $route;
41  $routeDatas = $this->routeParser->parse($route);
42  foreach ((array) $httpMethod as $method) {
43  foreach ($routeDatas as $routeData) {
44  $this->dataGenerator->addRoute($method, $routeData, $handler);
45  }
46  }
47  }
$handler
+ Here is the caller graph for this function:

◆ delete()

FastRoute\RouteCollector::delete (   $route,
  $handler 
)

Adds a DELETE route to the collection.

This is simply an alias of $this->addRoute('DELETE', $route, $handler)

Parameters
string$route
mixed$handler

Definition at line 112 of file RouteCollector.php.

References $handler.

Referenced by FastRoute\RouteCollectorTest\testGroups().

113  {
114  $this->addRoute('DELETE', $route, $handler);
115  }
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
$handler
+ Here is the caller graph for this function:

◆ get()

FastRoute\RouteCollector::get (   $route,
  $handler 
)

Adds a GET route to the collection.

This is simply an alias of $this->addRoute('GET', $route, $handler)

Parameters
string$route
mixed$handler

Definition at line 73 of file RouteCollector.php.

References $handler.

Referenced by FastRoute\RouteCollectorTest\testGroups().

74  {
75  $this->addRoute('GET', $route, $handler);
76  }
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
$handler
+ Here is the caller graph for this function:

◆ getData()

FastRoute\RouteCollector::getData ( )

Returns the collected route data, as provided by the data generator.

Returns
array

Definition at line 148 of file RouteCollector.php.

149  {
150  return $this->dataGenerator->getData();
151  }

◆ head()

FastRoute\RouteCollector::head (   $route,
  $handler 
)

Adds a HEAD route to the collection.

This is simply an alias of $this->addRoute('HEAD', $route, $handler)

Parameters
string$route
mixed$handler

Definition at line 138 of file RouteCollector.php.

References $handler.

Referenced by FastRoute\RouteCollectorTest\testGroups().

139  {
140  $this->addRoute('HEAD', $route, $handler);
141  }
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
$handler
+ Here is the caller graph for this function:

◆ patch()

FastRoute\RouteCollector::patch (   $route,
  $handler 
)

Adds a PATCH route to the collection.

This is simply an alias of $this->addRoute('PATCH', $route, $handler)

Parameters
string$route
mixed$handler

Definition at line 125 of file RouteCollector.php.

References $handler.

Referenced by FastRoute\RouteCollectorTest\testGroups().

126  {
127  $this->addRoute('PATCH', $route, $handler);
128  }
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
$handler
+ Here is the caller graph for this function:

◆ post()

FastRoute\RouteCollector::post (   $route,
  $handler 
)

Adds a POST route to the collection.

This is simply an alias of $this->addRoute('POST', $route, $handler)

Parameters
string$route
mixed$handler

Definition at line 86 of file RouteCollector.php.

References $handler.

Referenced by FastRoute\RouteCollectorTest\testGroups().

87  {
88  $this->addRoute('POST', $route, $handler);
89  }
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
$handler
+ Here is the caller graph for this function:

◆ put()

FastRoute\RouteCollector::put (   $route,
  $handler 
)

Adds a PUT route to the collection.

This is simply an alias of $this->addRoute('PUT', $route, $handler)

Parameters
string$route
mixed$handler

Definition at line 99 of file RouteCollector.php.

References $handler.

Referenced by FastRoute\RouteCollectorTest\testGroups().

100  {
101  $this->addRoute('PUT', $route, $handler);
102  }
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
$handler
+ Here is the caller graph for this function:

Field Documentation

◆ $currentGroupPrefix

FastRoute\RouteCollector::$currentGroupPrefix
protected

Definition at line 14 of file RouteCollector.php.

◆ $dataGenerator

FastRoute\RouteCollector::$dataGenerator
protected

Definition at line 11 of file RouteCollector.php.

◆ $routeParser

FastRoute\RouteCollector::$routeParser
protected

Definition at line 8 of file RouteCollector.php.


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