$route
$route : array
uri => string (begins with / example: "/do_something") status => integer (the HTTP return status code, used for error handling) verbs => string[] (the array of string of allowed/matchable HTTP methods)
This class represents a route that will resolve in a Controller call.
matches(string $method, string $url, array $matchedExpr, array $matchedGet) : boolean
Check if the given URL matches the route URI.
Also fill GET and expressions parameters.
string | $method | the HTTP method used on the Request |
string | $url | the URL invoked |
array | $matchedExpr | will be filled with an associative array of paramName => urlValue |
array | $matchedGet | will be filled with an associative array of paramName => urlValue (reserved for get parameters) |
true if the given method and url matches this route
matchURI(string $uri, string $url, array $matchedExpr, array $matchedGet) : boolean
Check if the given URL matches the given URI.
$matchedExpr is given as an associative array: name => value
string | $uri | the URI to be matched against the given URL |
string | $url | the URL to be matched |
array | $matchedExpr | the variable to be filled with matched parameters |
array | $matchedGet | the variable to be filled with GET options |
true if the URL matches the URI, false otherwise
__construct(array $options)
Build a new route to be registered within a Router instance.
An usage example is:
<?php
$route = new Route([
"verbs" => [
RouteInterface::GET
],
"uri" => "/",
"status" => RouteInterface::OK,
"controller" => MyController::class,
"action" => "index",
]);
array | $options | The URI for the current route and more options |
The route is malformed
__invoke(\Psr\Http\Message\RequestInterface $request, \Psr\Http\Message\ResponseInterface $response, \Gishiki\Algorithms\Collections\GenericCollection $arguments, array $controllerArgs = array(), \Gishiki\Core\Application|null $app = null)
Execute the route callback by instantiating the given controller class and calling the specified action.
This function is called AUTOMATICALLY by the framework when the route can be used to fulfill the given request.
\Psr\Http\Message\RequestInterface | $request | a copy of the request made to the application |
\Psr\Http\Message\ResponseInterface | $response | the action must filled, and what will be returned to the client |
\Gishiki\Algorithms\Collections\GenericCollection | $arguments | a list of reversed URI and GET parameters |
array | $controllerArgs | an array containing data created from the application initialization |
\Gishiki\Core\Application|null | $app | the current application instance |
paramCheck( $urlSplit, $type) : boolean
Check if a piece of URL matches a parameter of the given type.
List of types:
$urlSplit | string the piece of URL to be checked |
|
$type | int the type of accepted parameter |
the given type is invalid
true on success, false otherwise
matchCheck(string $uriSplit, string $urlSplit, mixed $params) : boolean
Check weather a piece of an URL matches the corresponding piece of URI
string | $uriSplit | the slice of URI to be checked |
string | $urlSplit | the slice of URL to be checked |
mixed | $params | used to register the correspondence (if any) |
true if the URL slice matches the URI slice, false otherwise