You are here

public static function RouteMatch::createFromRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Routing/RouteMatch.php \Drupal\Core\Routing\RouteMatch::createFromRequest()

Creates a RouteMatch from a request.

Parameters

Request $request: A request object.

Return value

\Drupal\Core\Routing\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).

15 calls to RouteMatch::createFromRequest()
AccessManager::checkRequest in core/lib/Drupal/Core/Access/AccessManager.php
Execute access checks against the incoming request.
ConfigTranslationController::itemPage in core/modules/config_translation/src/Controller/ConfigTranslationController.php
Language translations overview page for a configuration name.
ControllerResolver::doGetArguments in core/lib/Drupal/Core/Controller/ControllerResolver.php
ControllerResolverTest::testGetArguments in core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
Tests getArguments().
ControllerResolverTest::testGetArgumentsWithRouteMatchAndPsr7Request in core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php
Tests getArguments with a route match and a PSR-7 request.

... See full list

File

core/lib/Drupal/Core/Routing/RouteMatch.php, line 83
Contains \Drupal\Core\Routing\RouteMatch.

Class

RouteMatch
Default object representing the results of routing.

Namespace

Drupal\Core\Routing

Code

public static function createFromRequest(Request $request) {
  if ($request->attributes
    ->get(RouteObjectInterface::ROUTE_OBJECT)) {
    $raw_variables = array();
    if ($raw = $request->attributes
      ->get('_raw_variables')) {
      $raw_variables = $raw
        ->all();
    }
    return new static($request->attributes
      ->get(RouteObjectInterface::ROUTE_NAME), $request->attributes
      ->get(RouteObjectInterface::ROUTE_OBJECT), $request->attributes
      ->all(), $raw_variables);
  }
  else {
    return new NullRouteMatch();
  }
}