Url::getUri

public 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.

File

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

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

1
2
3
4
5
6
7
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;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.