You are here

public function CurrentPathStack::getPath in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Path/CurrentPathStack.php \Drupal\Core\Path\CurrentPathStack::getPath()

Returns the path of the current request.

Parameters

\Symfony\Component\HttpFoundation\Request $request: (optional) The request.

Return value

string Returns the path, without leading slashes.

File

core/lib/Drupal/Core/Path/CurrentPathStack.php, line 54
Contains \Drupal\Core\Path\CurrentPathStack.

Class

CurrentPathStack
Represents the current path for the current request.

Namespace

Drupal\Core\Path

Code

public function getPath($request = NULL) {
  if (!isset($request)) {
    $request = $this->requestStack
      ->getCurrentRequest();
  }
  if (!isset($this->paths[$request])) {
    $this->paths[$request] = $request
      ->getPathInfo();
  }
  return $this->paths[$request];
}