RouteCollection class
Framework\Routing\RouteCollection
Class RouteCollection.
Implements:
Countable, JsonSerializable
Defined in libraries/routing/src/RouteCollection.php
Properties #
- $router
- -
- $origin
- -
- $name
- -
- $routes
- Array of HTTP Methods as keys and array of Routes as values.
- $notFoundAction
- The Error 404 page action.
$router
$origin
$name
$routes
Array of HTTP Methods as keys and array of Routes as values.
$notFoundAction
The Error 404 page action.
Methods #
- __construct()
- RouteCollection constructor.
- __call()
- -
- __get()
- -
- __isset()
- -
- add()
- Adds a Route to match many HTTP Methods.
- count()
- Count routes in the collection.
- delete()
- Adds a Route to match the HTTP DELETE Method.
- get()
- Adds a Route to match the HTTP GET Method.
- group()
- Groups many Routes into a URL path.
- jsonSerialize()
- -
- namespace()
- Updates Routes actions, which are strings, prepending a namespace.
- notFound()
- Sets the Route Not Found action for this collection.
- options()
- Adds a Route to match the HTTP OPTIONS Method.
- patch()
- Adds a Route to match the HTTP PATCH Method.
- post()
- Adds a Route to match the HTTP POST Method.
- presenter()
- Adds many Routes that can be used by a User Interface.
- put()
- Adds a Route to match the HTTP PUT Method.
- redirect()
- Adds a GET Route to match a path and automatically redirects to a URL.
- resource()
- Adds many Routes that can be used as a REST Resource.
- addRoute()
- -
- addSimple()
- -
- getRouteName()
- Get a Route name.
- getRouteNotFound()
- Gets the Route Not Found for this collection.
- makeRoute()
- -
- makeRouteActionFromArray()
- -
- setOrigin()
- -
__construct()
RouteCollection constructor.
- \Framework\Routing\Router $router - A Router instance
- string $origin - URL Origin. A string in the following format: `{scheme}://{hostname}[:{port}]`
- ?string $name - The collection name
__call()
- string $method
- array $arguments
__get()
- string $property
__isset()
- string $property
add()
Adds a Route to match many HTTP Methods.
- array $httpMethods - The HTTP Methods
- string $path - The URL path
- Closure|array|string $action - The Route action
- ?string $name - The Route name
count()
Count routes in the collection.
delete()
Adds a Route to match the HTTP DELETE Method.
- string $path - The URL path
- Closure|array|string $action - The Route action
- ?string $name - The Route name
get()
Adds a Route to match the HTTP GET Method.
- string $path - The URL path
- Closure|array|string $action - The Route action
- ?string $name - The Route name
group()
Groups many Routes into a URL path.
- string $basePath - The URL path to group in
- array $routes - The Routes to be grouped
- array $options - Custom options passed to the Routes
jsonSerialize()
namespace()
Updates Routes actions, which are strings, prepending a namespace.
- string $namespace - The namespace
- array $routes - The Routes
notFound()
Sets the Route Not Found action for this collection.
- Closure|string $action - the Route function to run when no Route path is found for this collection
options()
Adds a Route to match the HTTP OPTIONS Method.
- string $path - The URL path
- Closure|array|string $action - The Route action
- ?string $name - The Route name
patch()
Adds a Route to match the HTTP PATCH Method.
- string $path - The URL path
- Closure|array|string $action - The Route action
- ?string $name - The Route name
post()
Adds a Route to match the HTTP POST Method.
- string $path - The URL path
- Closure|array|string $action - The Route action
- ?string $name - The Route name
presenter()
Adds many Routes that can be used by a User Interface.
- string $path - The URL path
- string $class - The name of the class where the resource will point
- string $baseName - The base name used as a Route name prefix
- array $except - Actions not added. Allowed values are: index, new, create, show, edit, update, remove and delete
- string $placeholder - The placeholder. Normally it matches an id, a number
put()
Adds a Route to match the HTTP PUT Method.
- string $path - The URL path
- Closure|array|string $action - The Route action
- ?string $name - The Route name
redirect()
Adds a GET Route to match a path and automatically redirects to a URL.
- string $path - The URL path
- string $location - The URL to redirect
- int $code - The status code of the response
- ?string $name - The Route name
resource()
Adds many Routes that can be used as a REST Resource.
- string $path - The URL path
- string $class - The name of the class where the resource will point
- string $baseName - The base name used as a Route name prefix
- array $except - Actions not added. Allowed values are: index, create, show, update, replace and delete
- string $placeholder - The placeholder. Normally it matches an id, a number
addRoute()
- string $httpMethod
- \Framework\Routing\Route $route
addSimple()
- string $method
- string $path
- Closure|array|string $action
- ?string $name
getRouteName()
Get a Route name.
- string $name - The current Route name
getRouteNotFound()
Gets the Route Not Found for this collection.
makeRoute()
- string $path
- Closure|array|string $action
- ?string $name
makeRouteActionFromArray()
- array $action
setOrigin()
- string $origin