24 $this->routeParser = $routeParser;
25 $this->dataGenerator = $dataGenerator;
26 $this->currentGroupPrefix =
'';
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);
57 public function addGroup($prefix, callable $callback)
59 $previousGroupPrefix = $this->currentGroupPrefix;
60 $this->currentGroupPrefix = $previousGroupPrefix . $prefix;
62 $this->currentGroupPrefix = $previousGroupPrefix;
75 $this->addRoute(
'GET', $route,
$handler);
88 $this->addRoute(
'POST', $route,
$handler);
101 $this->addRoute(
'PUT', $route,
$handler);
114 $this->addRoute(
'DELETE', $route,
$handler);
127 $this->addRoute(
'PATCH', $route,
$handler);
140 $this->addRoute(
'HEAD', $route,
$handler);
150 return $this->dataGenerator->getData();
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
getData()
Returns the collected route data, as provided by the data generator.
head($route, $handler)
Adds a HEAD route to the collection.
patch($route, $handler)
Adds a PATCH route to the collection.
post($route, $handler)
Adds a POST route to the collection.
__construct(RouteParser $routeParser, DataGenerator $dataGenerator)
Constructs a route collector.
put($route, $handler)
Adds a PUT route to the collection.
addGroup($prefix, callable $callback)
Create a route group with a common prefix.