class RouteCollection implements Countable, IteratorAggregate

Properties

protected array $routes

An array of the routes keyed by method.

protected array $allRoutes

An flattened array of all of the routes.

protected array $nameList

A look-up table of routes by their names.

protected array $actionList

A look-up table of routes by controller action.

Methods

add(Route $route)

Add a Route instance to the collection.

void
addToCollections(Route $route)

Add the given route to the arrays of routes.

void
addLookups(Route $route)

Add the route to any look-up tables if necessary.

void
addToActionList(array $action, Route $route)

Add a route to the controller action dictionary.

void
refreshNameLookups()

Refresh the name look-up table.

void
refreshActionLookups()

Refresh the action look-up table.

match(Request $request)

Find the first route matching a given request.

Route|null
matchAgainstRoutes(array $routes, Request $request, bool $includingMethod = true)

Determine if a route in the array matches the request.

array
checkForAlternateVerbs(Request $request)

Determine if any routes match on another HTTP verb.

getRouteForMethods(Request $request, array $methods)

Get a route (if necessary) that responds when other available methods are present.

void
methodNotAllowed(array $others)

Throw a method not allowed HTTP exception.

array
get(string|null $method = null)

Get routes from the collection by method.

bool
hasNamedRoute(string $name)

Determine if the route collection contains a given named route.

Route|null
getByName(string $name)

Get a route instance by its name.

Route|null
getByAction(string $action)

Get a route instance by its controller action.

array
getRoutes()

Get all of the routes in the collection.

array
getRoutesByMethod()

Get all of the routes keyed by their HTTP verb / method.

array
getRoutesByName()

Get all of the routes keyed by their name.

getIterator()

Get an iterator for the items.

int
count()

Count the number of items in the collection.

Details

at line 50
Route add(Route $route)

Add a Route instance to the collection.

Parameters

Route $route

Return Value

Route

at line 65
protected void addToCollections(Route $route)

Add the given route to the arrays of routes.

Parameters

Route $route

Return Value

void

at line 82
protected void addLookups(Route $route)

Add the route to any look-up tables if necessary.

Parameters

Route $route

Return Value

void

at line 108
protected void addToActionList(array $action, Route $route)

Add a route to the controller action dictionary.

Parameters

array $action
Route $route

Return Value

void

at line 120
void refreshNameLookups()

Refresh the name look-up table.

This is done in case any names are fluently defined or if routes are overwritten.

Return Value

void

at line 138
void refreshActionLookups()

Refresh the action look-up table.

This is done in case any actions are overwritten with new controllers.

Return Value

void

at line 157
Route match(Request $request)

Find the first route matching a given request.

Parameters

Request $request

Return Value

Route

Exceptions

NotFoundHttpException

at line 190
protected Route|null matchAgainstRoutes(array $routes, Request $request, bool $includingMethod = true)

Determine if a route in the array matches the request.

Parameters

array $routes
Request $request
bool $includingMethod

Return Value

Route|null

at line 203
protected array checkForAlternateVerbs(Request $request)

Determine if any routes match on another HTTP verb.

Parameters

Request $request

Return Value

array

at line 230
protected Route getRouteForMethods(Request $request, array $methods)

Get a route (if necessary) that responds when other available methods are present.

Parameters

Request $request
array $methods

Return Value

Route

Exceptions

MethodNotAllowedHttpException

at line 249
protected void methodNotAllowed(array $others)

Throw a method not allowed HTTP exception.

Parameters

array $others

Return Value

void

Exceptions

MethodNotAllowedHttpException

at line 260
array get(string|null $method = null)

Get routes from the collection by method.

Parameters

string|null $method

Return Value

array

at line 271
bool hasNamedRoute(string $name)

Determine if the route collection contains a given named route.

Parameters

string $name

Return Value

bool

at line 282
Route|null getByName(string $name)

Get a route instance by its name.

Parameters

string $name

Return Value

Route|null

at line 293
Route|null getByAction(string $action)

Get a route instance by its controller action.

Parameters

string $action

Return Value

Route|null

at line 303
array getRoutes()

Get all of the routes in the collection.

Return Value

array

at line 313
array getRoutesByMethod()

Get all of the routes keyed by their HTTP verb / method.

Return Value

array

at line 323
array getRoutesByName()

Get all of the routes keyed by their name.

Return Value

array

at line 333
ArrayIterator getIterator()

Get an iterator for the items.

Return Value

ArrayIterator

at line 343
int count()

Count the number of items in the collection.

Return Value

int