class CompiledRouteCollection extends AbstractRouteCollection (View source)

Properties

protected array $compiled

The compiled routes collection.

protected array $attributes

An array of the route attributes keyed by name.

protected RouteCollection|null $routes

The dynamically added routes that were added after loading the cached, compiled routes.

protected Router $router

The router instance used by the route.

protected Container $container

The container instance used by the route.

Methods

handleMatchedRoute(Request $request, Route|null $route)

Handle the matched route.

array
checkForAlternateVerbs(Request $request)

Determine if any routes match on another HTTP verb.

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

Determine if a route in the array matches the request.

getRouteForMethods(Request $request, array $methods)

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

void
methodNotAllowed(array $others, string $method)

Throw a method not allowed HTTP exception.

array
compile()

Compile the routes for caching.

CompiledUrlMatcherDumper
dumper()

Return the CompiledUrlMatcherDumper instance for the route collection.

RouteCollection
toSymfonyRouteCollection()

Convert the collection to a Symfony RouteCollection instance.

RouteCollection
addToSymfonyRoutesCollection(RouteCollection $symfonyRoutes, Route $route)

Add a route to the SymfonyRouteCollection instance.

string
generateRouteName()

Get a randomly generated route name.

getIterator()

Get an iterator for the items.

int
count()

Count the number of items in the collection.

void
__construct(array $compiled, array $attributes)

Create a new CompiledRouteCollection instance.

add(Route $route)

Add a Route instance to the collection.

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.

requestWithoutTrailingSlash(Request $request)

Get a cloned instance of the given request without any trailing slash on the URI.

Route[]
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.

Route[]
getRoutes()

Get all of the routes in the collection.

array
getRoutesByMethod()

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

Route[]
getRoutesByName()

Get all of the routes keyed by their name.

newRoute(array $attributes)

Resolve an array of attributes to a Route instance.

$this
setRouter(Router $router)

Set the router instance on the route.

$this
setContainer(Container $container)

Set the container instance on the route.

Details

protected Route handleMatchedRoute(Request $request, Route|null $route)

Handle the matched route.

Parameters

Request $request
Route|null $route

Return Value

Route

Exceptions

NotFoundHttpException

protected array checkForAlternateVerbs(Request $request)

Determine if any routes match on another HTTP verb.

Parameters

Request $request

Return Value

array

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

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

protected void methodNotAllowed(array $others, string $method)

Throw a method not allowed HTTP exception.

Parameters

array $others
string $method

Return Value

void

Exceptions

MethodNotAllowedHttpException

array compile()

Compile the routes for caching.

Return Value

array

CompiledUrlMatcherDumper dumper()

Return the CompiledUrlMatcherDumper instance for the route collection.

Return Value

CompiledUrlMatcherDumper

RouteCollection toSymfonyRouteCollection()

Convert the collection to a Symfony RouteCollection instance.

Return Value

RouteCollection

protected RouteCollection addToSymfonyRoutesCollection(RouteCollection $symfonyRoutes, Route $route)

Add a route to the SymfonyRouteCollection instance.

Parameters

RouteCollection $symfonyRoutes
Route $route

Return Value

RouteCollection

Exceptions

LogicException

protected string generateRouteName()

Get a randomly generated route name.

Return Value

string

ArrayIterator getIterator()

Get an iterator for the items.

Return Value

ArrayIterator

int count()

Count the number of items in the collection.

Return Value

int

void __construct(array $compiled, array $attributes)

Create a new CompiledRouteCollection instance.

Parameters

array $compiled
array $attributes

Return Value

void

Route add(Route $route)

Add a Route instance to the collection.

Parameters

Route $route

Return Value

Route

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

void refreshActionLookups()

Refresh the action look-up table.

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

Return Value

void

Route match(Request $request)

Find the first route matching a given request.

Parameters

Request $request

Return Value

Route

Exceptions

MethodNotAllowedHttpException
NotFoundHttpException

protected Request requestWithoutTrailingSlash(Request $request)

Get a cloned instance of the given request without any trailing slash on the URI.

Parameters

Request $request

Return Value

Request

Route[] get(string|null $method = null)

Get routes from the collection by method.

Parameters

string|null $method

Return Value

Route[]

bool hasNamedRoute(string $name)

Determine if the route collection contains a given named route.

Parameters

string $name

Return Value

bool

Route|null getByName(string $name)

Get a route instance by its name.

Parameters

string $name

Return Value

Route|null

Route|null getByAction(string $action)

Get a route instance by its controller action.

Parameters

string $action

Return Value

Route|null

Route[] getRoutes()

Get all of the routes in the collection.

Return Value

Route[]

array getRoutesByMethod()

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

Return Value

array

Route[] getRoutesByName()

Get all of the routes keyed by their name.

Return Value

Route[]

protected Route newRoute(array $attributes)

Resolve an array of attributes to a Route instance.

Parameters

array $attributes

Return Value

Route

$this setRouter(Router $router)

Set the router instance on the route.

Parameters

Router $router

Return Value

$this

$this setContainer(Container $container)

Set the container instance on the route.

Parameters

Container $container

Return Value

$this