W3cubDocs

/Drupal 8

public static function Url::fromRouteMatch

public static Url::fromRouteMatch(RouteMatchInterface $route_match)

Creates a new URL object from a route match.

Parameters

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

Return value

$this

File

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

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');
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Url.php/function/Url::fromRouteMatch/8.1.x