function Url::getInternalPath

Same name in other branches
  1. 9 core/lib/Drupal/Core/Url.php \Drupal\Core\Url::getInternalPath()
  2. 8.9.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url::getInternalPath()
  3. 11.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url::getInternalPath()

Returns the internal path (system path) for this route.

This path will not include any prefixes, fragments, or query strings.

Return value

string The internal path for this route.

Throws

\UnexpectedValueException. If this is a URI with no corresponding system path.

File

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

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public function getInternalPath() {
    if ($this->unrouted) {
        throw new \UnexpectedValueException('Unrouted URIs do not have internal representations.');
    }
    if (!isset($this->internalPath)) {
        $this->internalPath = $this->urlGenerator()
            ->getPathFromRoute($this->getRouteName(), $this->getRouteParameters());
    }
    return $this->internalPath;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.