function UrlGeneratorTrait::getUrlGenerator

Returns the URL generator service.

Return value

\Drupal\Core\Routing\UrlGeneratorInterface The URL generator service.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use the url_generator service instead.

File

core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php, line 81

Class

UrlGeneratorTrait
Wrapper methods for the Url Generator.

Namespace

Drupal\Core\Routing

Code

protected function getUrlGenerator() {
    @trigger_error(__NAMESPACE__ . "\\UrlGeneratorTrait::getUrlGenerator() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use the url_generator service instead. See https://www.drupal.org/node/2614344", E_USER_DEPRECATED);
    if (!$this->urlGenerator) {
        $this->urlGenerator = \Drupal::service('url_generator');
    }
    return $this->urlGenerator;
}

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