class RouteMatch implements RouteMatchInterface (View source)

Default object representing the results of routing.

Properties

protected string $routeName

The route name.

protected Route $route

The route.

protected ParameterBag $parameters

A key|value store of parameters.

protected ParameterBag $rawParameters

A key|value store of raw parameters.

Methods

__construct(string $route_name, Route $route, array $parameters = [], array $raw_parameters = [])

Constructs a RouteMatch object.

createFromRequest(Request $request)

Creates a RouteMatch from a request.

string|null
getRouteName()

Returns the route name.

Route|null
getRouteObject()

Returns the route object.

mixed|null
getParameter(string $parameter_name)

Returns the processed value of a named route parameter.

ParameterBag
getParameters()

Returns the bag of all processed route parameters.

string|null
getRawParameter(string $parameter_name)

Returns the raw value of a named route parameter.

ParameterBag
getRawParameters()

Returns the bag of all raw route parameters.

array
getParameterNames()

Returns the names of all parameters for the currently matched route.

Details

__construct(string $route_name, Route $route, array $parameters = [], array $raw_parameters = [])

Constructs a RouteMatch object.

Parameters

string $route_name

The name of the route.

Route $route

The route.

array $parameters

The parameters array.

array $raw_parameters

The raw $parameters array.

static RouteMatchInterface createFromRequest(Request $request)

Creates a RouteMatch from a request.

Parameters

Request $request

A request object.

Return Value

RouteMatchInterface

A new RouteMatch object if there's a matched route for the request. A new NullRouteMatch object otherwise (e.g., on a 404 page or when invoked prior to routing).

string|null getRouteName()

Returns the route name.

Return Value

string|null

The route name. NULL if no route is matched.

Route|null getRouteObject()

Returns the route object.

Return Value

Route|null

The route object. NULL if no route is matched.

mixed|null getParameter(string $parameter_name)

Returns the processed value of a named route parameter.

Raw URL parameters are processed by the parameter conversion system, which does operations such as converting entity ID parameters to fully-loaded entities. For example, the path node/12345 would have a raw node ID parameter value of 12345, while the processed parameter value would be the corresponding loaded node object.

Parameters

string $parameter_name

The parameter name.

Return Value

mixed|null

The parameter value. NULL if the route doesn't define the parameter or if the parameter value can't be determined from the request.

ParameterBag getParameters()

Returns the bag of all processed route parameters.

Raw URL parameters are processed by the parameter conversion system, which does operations such as converting entity ID parameters to fully-loaded entities. For example, the path node/12345 would have a raw node ID parameter value of 12345, while the processed parameter value would be the corresponding loaded node object.

Return Value

ParameterBag

The parameter bag.

string|null getRawParameter(string $parameter_name)

Returns the raw value of a named route parameter.

Parameters

string $parameter_name

The parameter name.

Return Value

string|null

The raw (non-upcast) parameter value. NULL if the route doesn't define the parameter or if the raw parameter value can't be determined from the request.

ParameterBag getRawParameters()

Returns the bag of all raw route parameters.

Return Value

ParameterBag

The parameter bag.

protected array getParameterNames()

Returns the names of all parameters for the currently matched route.

Return Value

array

Route parameter names as both the keys and values.