function RouteMatch::createFromRequest

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

Creates a RouteMatch from a request.

Parameters

\Symfony\Component\HttpFoundation\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).

17 calls to RouteMatch::createFromRequest()
AccessManager::checkRequest in core/lib/Drupal/Core/Access/AccessManager.php
AjaxBasePageNegotiatorTest::testApplies in core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php
@covers ::applies @dataProvider providerTestApplies
AjaxBasePageNegotiatorTest::testDetermineActiveThemeDefaultTheme in core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php
@covers ::determineActiveTheme
AjaxBasePageNegotiatorTest::testDetermineActiveThemeInvalidToken in core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php
@covers ::determineActiveTheme
AjaxBasePageNegotiatorTest::testDetermineActiveThemeValidToken in core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php
@covers ::determineActiveTheme

... See full list

File

core/lib/Drupal/Core/Routing/RouteMatch.php, line 78

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 = [];
        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();
    }
}

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