RouterInterface

Interface defining a HTTP path router.

since

2.0.0

package

Joomla Framework

Methods

addRoute

Add a route to the router.

addRoute(\Joomla\Router\Route route) : 
since

2.0.0

Arguments

route

RouteThe route definition

Response

$this

addRoutes

Add an array of route maps or objects to the router.

addRoutes(\Joomla\Router\Route[]|array[] routes) : 
since

2.0.0

throws

UnexpectedValueExceptionIf missing the pattern or controller keys from the mapping array.

Arguments

routes

array<string|int, Route>|array<string|int, array<string|int, mixed>>A list of route maps or Route objects to add to the router.

Response

$this

all

Add a route to the router that accepts all request methods.

all( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

delete

Add a DELETE route to the router.

delete( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

get

Add a GET route to the router.

get( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

getRoutes

Get the routes registered with this router.

getRoutes() : \Joomla\Router\Route||string|int
since

2.0.0

Response

array<string|int, Route>

head

Add a HEAD route to the router.

head( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

options

Add a OPTIONS route to the router.

options( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

parseRoute

Parse the given route and return the information about the route, including the controller assigned to the route.

parseRoute( route,  method = 'GET') : \Joomla\Router\ResolvedRoute
since

2.0.0

throws

MethodNotAllowedExceptionif the route was found but does not support the request method

RouteNotFoundExceptionif the route was not found

Arguments

route

stringThe route string for which to find and execute a controller.

method

stringRequest method to match, should be a valid HTTP request method.

Response

ResolvedRoute

patch

Add a PATCH route to the router.

patch( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

post

Add a POST route to the router.

post( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

put

Add a PUT route to the router.

put( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this

trace

Add a TRACE route to the router.

trace( pattern,  controller, mixed||string|int rules = [], mixed||string|int defaults = []) : 
since

2.0.0

Arguments

pattern

stringThe route pattern to use for matching.

controller

mixedThe controller to map to the given pattern.

rules

array<string|int, mixed>An array of regex rules keyed using the route variables.

defaults

array<string|int, mixed>An array of default values that are used when the URL is matched.

Response

$this