You are here

public static function Url::fromRouteMatch in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::fromRouteMatch()
  2. 9 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::fromRouteMatch()

Creates a new URL object from a route match.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

Return value

static

6 calls to Url::fromRouteMatch()
batch_process in core/includes/form.inc
Processes the batch.
PathBasedBreadcrumbBuilder::build in core/modules/system/src/PathBasedBreadcrumbBuilder.php
PathMatcher::isFrontPage in core/lib/Drupal/Core/Path/PathMatcher.php
shortcut_preprocess_page_title in core/modules/shortcut/shortcut.module
Implements hook_preprocess_HOOK() for page title templates.
system_js_settings_alter in core/modules/system/system.module
Implements hook_js_settings_alter().

... See full list

File

core/lib/Drupal/Core/Url.php, line 165

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public static function fromRouteMatch(RouteMatchInterface $route_match) {
  if ($route_match
    ->getRouteObject()) {
    return new static($route_match
      ->getRouteName(), $route_match
      ->getRawParameters()
      ->all());
  }
  else {
    throw new \InvalidArgumentException('Route required');
  }
}