function CurrentRouteMatch::getRouteMatch

Same name in other branches
  1. 9 core/lib/Drupal/Core/Routing/CurrentRouteMatch.php \Drupal\Core\Routing\CurrentRouteMatch::getRouteMatch()
  2. 8.9.x core/lib/Drupal/Core/Routing/CurrentRouteMatch.php \Drupal\Core\Routing\CurrentRouteMatch::getRouteMatch()
  3. 11.x core/lib/Drupal/Core/Routing/CurrentRouteMatch.php \Drupal\Core\Routing\CurrentRouteMatch::getRouteMatch()

Returns the route match for a passed in request.

Parameters

\Symfony\Component\HttpFoundation\Request $request: A request object.

Return value

\Drupal\Core\Routing\RouteMatchInterface A route match object created from the request.

4 calls to CurrentRouteMatch::getRouteMatch()
CurrentRouteMatch::getCurrentRouteMatch in core/lib/Drupal/Core/Routing/CurrentRouteMatch.php
Returns the route match for the current request.
CurrentRouteMatch::getMasterRouteMatch in core/lib/Drupal/Core/Routing/CurrentRouteMatch.php
Gets the master route match..
CurrentRouteMatch::getParentRouteMatch in core/lib/Drupal/Core/Routing/CurrentRouteMatch.php
Returns the parent route match of the current.
CurrentRouteMatch::getRouteMatchFromRequest in core/lib/Drupal/Core/Routing/CurrentRouteMatch.php
Returns a route match from a given request, if possible.

File

core/lib/Drupal/Core/Routing/CurrentRouteMatch.php, line 99

Class

CurrentRouteMatch
Default object for current_route_match service.

Namespace

Drupal\Core\Routing

Code

protected function getRouteMatch(Request $request) {
    if (isset($this->routeMatches[$request])) {
        $route_match = $this->routeMatches[$request];
    }
    else {
        $route_match = RouteMatch::createFromRequest($request);
        // Since getRouteMatch() might be invoked both before and after routing
        // is completed, only statically cache the route match after there's a
        // matched route.
        if ($route_match->getRouteObject()) {
            $this->routeMatches[$request] = $route_match;
        }
    }
    return $route_match;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.