You are here

protected function CurrentPathHelper::getCurrentRequestUrl in Menu Trail By Path 8

Returns the current request Url

NOTE: There is a difference between $this->routeMatch->getRouteName and $this->context->getPathInfo() for now it seems more logical to prefer the latter, because that's the "real" url that visitors enter in their browser..

Return value

\Drupal\Core\Url|null

1 call to CurrentPathHelper::getCurrentRequestUrl()
CurrentPathHelper::getUrls in src/Path/CurrentPathHelper.php
@inheritdoc

File

src/Path/CurrentPathHelper.php, line 55

Class

CurrentPathHelper

Namespace

Drupal\menu_trail_by_path\Path

Code

protected function getCurrentRequestUrl() {
  $current_pathinfo_url = $this
    ->createUrlFromRelativeUri($this->context
    ->getPathInfo());
  if ($current_pathinfo_url
    ->isRouted()) {
    return $current_pathinfo_url;
  }
  elseif ($route_name = $this->routeMatch
    ->getRouteName()) {
    $route_parameters = $this->routeMatch
      ->getRawParameters()
      ->all();
    return new Url($route_name, $route_parameters);
  }
  return NULL;
}