public function UrlGenerator::getPathFromRoute

public UrlGenerator::getPathFromRoute($name, $parameters = array())

Gets the internal path (system path) for a route.

Parameters

string|\Symfony\Component\Routing\Route $name: The route name or a route object.

array $parameters: An array of parameters as passed to \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate().

Return value

string The internal Drupal path corresponding to the route.

Overrides UrlGeneratorInterface::getPathFromRoute

File

core/lib/Drupal/Core/Routing/UrlGenerator.php, line 120

Class

UrlGenerator
Generates URLs from route names and parameters.

Namespace

Drupal\Core\Routing

Code

public function getPathFromRoute($name, $parameters = array()) {
  $route = $this->getRoute($name);
  $name = $this->getRouteDebugMessage($name);
  $this->processRoute($name, $route, $parameters);
  $path = $this->getInternalPathFromRoute($name, $route, $parameters);
  // Router-based paths may have a querystring on them but Drupal paths may
  // not have one, so remove any ? and anything after it. For generate() this
  // is handled in processPath().
  $path = preg_replace('/\?.*/', '', $path);
  return trim($path, '/');
}

© 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!Routing!UrlGenerator.php/function/UrlGenerator::getPathFromRoute/8.1.x