function Url::getUri

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

Returns the URI value for this Url object.

Only to be used if self::$unrouted is TRUE.

Return value

string A URI not connected to a route. May be an external URL.

Throws

\UnexpectedValueException Thrown when the URI was requested for a routed URL.

2 calls to Url::getUri()
Url::getRouteName in core/lib/Drupal/Core/Url.php
Returns the route name.
Url::toString in core/lib/Drupal/Core/Url.php
Generates the string URL representation for this Url object.

File

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

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public function getUri() {
    if (!$this->unrouted) {
        throw new \UnexpectedValueException('This URL has a Drupal route, so the canonical form is not a URI.');
    }
    return $this->uri;
}

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