function Url::getRouteName

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

Returns the route name.

Return value

string

Throws

\UnexpectedValueException. If this is a URI with no corresponding route.

3 calls to Url::getRouteName()
Url::access in core/lib/Drupal/Core/Url.php
Checks this Url object against applicable access check services.
Url::getInternalPath in core/lib/Drupal/Core/Url.php
Returns the internal path (system path) for this route.
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 565

Class

Url
Defines an object that holds information about a URL.

Namespace

Drupal\Core

Code

public function getRouteName() {
    if ($this->unrouted) {
        throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.');
    }
    return $this->routeName;
}

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