Maps URI patterns to actions and views.
Routes are declared through the interfaces provided by the \HotMelt\Route class.
HotMelt will automatically load Site/routes.php, so you should use that file to declare routes.
| property-read |
The action to execute for this route. |
|---|---|
| property-read |
The view to render the result of this route's action in.
Either an instance of |
| see | |
| see |
add(string $expr, mixed $action, mixed $view = null, mixed $methods = false, mixed $options = false) : void
| see | \HotMelt\Action \HotMelt\View |
|---|---|
stringA regular expression to match against the request URI.
mixedThe action to execute for the route.
Can be either a subclass of \HotMelt\Action or a callable.
mixedThe view that the data returned from the route's action should be rendered in.
Can be either a subclass of \HotMelt\View or the name of a template to be rendered by an instance of \HotMelt\TemplateView.
You may pass null if you know that the action will never return (because it will always throw an exception).
mixedA string or an array of strings identifying valid HTTP methods for this route.
You may pass false to allow requests with any HTTP method.
mixedThe options for this route.
Upon adding a route, these options are merged with any default options set with \HotMelt\Route::pushDefaultOptions().
pushDefaultOptions(array $options) : void
Any options pushed through this method will override options previously pushed.
arrayAn array of options to push onto the default options stack.
popDefaultOptions() : void
effectiveOptions(array|bool $options = false) : array
array|boolAn array of options to merge with the options from the default options stack. Passing a set of options in this argument is conceptually similar to pushing that set onto the default options stack, then calling this method, and finally popping that set back off the stack, except the default options stack is not actually changed.
arrayA set of options.
__construct(string $expr, mixed $action, mixed $view, mixed $methods = false, mixed $options = false)
| see | \HotMelt\Action \HotMelt\View |
|---|---|
stringA regular expression to match against the request URI.
mixedThe action to execute for this route.
Can be either a subclass of \HotMelt\Action or a callable.
mixedThe view that the data returned from this route's action should be rendered in.
Can be either a subclass of \HotMelt\View or the name of a template to be rendered by an instance of \HotMelt\TemplateView.
You may pass null if you know that the action will never return (because it will always throw an exception).
mixedA string or an array of strings identifying valid HTTP methods for this route.
You may pass false to allow requests with any HTTP method.
mixedThe options for this route.
Upon adding a route, these options are merged with any default options set with \HotMelt\Route::pushDefaultOptions().
option(string $name) : mixed
stringAn option name.
mixed
routes() : array
array
find(mixed $requestOrURI) : \HotMelt\Route
mixedEither a \HotMelt\Request object or a URI (represented as a string).
\HotMelt\RouteThe route that is the best match from the routing table or false if there was no match.
acceptsMethod(string $method) : \HotMelt\`true`,
stringThe HTTP method to test.
\HotMelt\`true`,if the given method is valid for this route, or false, if it is not.
error(mixed $action = null, mixed $view = null, mixed $options = null) : \HotMelt\Route
Call this method without any arguments to retrieve the error route previously set through this method.
Call this method with at least the $action and $view arguments to set the error route.
mixedThe action to execute for the error route.
Can be either a subclass of \HotMelt\Action or a callable.
mixedThe view that the data returned from the error route's action should be rendered in.
Can be either a subclass of \HotMelt\View or the name of a template to be rendered by an instance of \HotMelt\TemplateView.
You may pass null if you know that the action will never return (because it will always throw an exception).
You may pass false to allow requests with any HTTP method.
mixedThe options for the error route.
Upon adding a route, these options are merged with any default options set with \HotMelt\Route::pushDefaultOptions().
\HotMelt\RouteThe error route.
contentTypes() : array
array
negotiateContentType(mixed $acceptableTypes) : string
mixedThe types from which to select a match.
If you pass false, the first content type declared for this route is returned.
stringThe best content type for this route.
negotiateView(\HotMelt\Request $request) : \HotMelt\View
| throws |
if no matching content type is declared for this route. |
|---|---|
\HotMelt\ViewThe best view for $request.
expr : string
| var |
A regular expression to match against the request URI. |
|---|---|
string
action : \HotMelt\Action
The action to execute for this route.
\HotMelt\Action
view : mixed
The view to render the result of this route's action in.
Either an instance of \HotMelt\View or null, if no view as been declared for this route.
mixed