class CurrentRouteMatch implements ResettableStackedRouteMatchInterface (View source)

Default object for current_route_match service.

Properties

protected RequestStack $requestStack

The related request stack.

protected SplObjectStorage $routeMatches

Internal cache of RouteMatch objects.

Methods

__construct(RequestStack $request_stack)

Constructs a CurrentRouteMatch object.

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.

getCurrentRouteMatch()

Returns the route match for the current request.

getRouteMatch(Request $request)

Returns the route match for a passed in request.

resetRouteMatch()

Resets the route match static cache.

getMasterRouteMatch()

Gets the master route match.

getParentRouteMatch()

Returns the parent route match of the current.

getRouteMatchFromRequest(Request $request)

Returns a route match from a given request, if possible.

Details

__construct(RequestStack $request_stack)

Constructs a CurrentRouteMatch object.

Parameters

RequestStack $request_stack

The request stack.

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.

RouteMatchInterface getCurrentRouteMatch()

Returns the route match for the current request.

Return Value

RouteMatchInterface

protected RouteMatchInterface getRouteMatch(Request $request)

Returns the route match for a passed in request.

Parameters

Request $request

A request object.

Return Value

RouteMatchInterface

A route match object created from the request.

resetRouteMatch()

Resets the route match static cache.

The route match should only be statically cached once routing is finished. Any code that uses a route match during routing may be incorrectly assumed to be acting after routing has completed. This method gives that code the ability to fix the static cache.

RouteMatchInterface getMasterRouteMatch()

Gets the master route match.

.

Return Value

RouteMatchInterface

RouteMatchInterface|null getParentRouteMatch()

Returns the parent route match of the current.

Return Value

RouteMatchInterface|null

The parent route match or NULL, if it the master route match.

RouteMatchInterface|null getRouteMatchFromRequest(Request $request)

Returns a route match from a given request, if possible.

Parameters

Request $request

The request.

Return Value

RouteMatchInterface|null

The matching route match, or NULL if there is no matching one.