function LinkGeneratorTrait::getLinkGenerator

Returns the link generator.

Return value

\Drupal\Core\Utility\LinkGeneratorInterface The link generator

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Inject the 'link_generator' service or use \Drupal\Core\Link instead

See also

https://www.drupal.org/node/2614344

File

core/lib/Drupal/Core/Routing/LinkGeneratorTrait.php, line 62

Class

LinkGeneratorTrait
Wrapper methods for the Link Generator.

Namespace

Drupal\Core\Routing

Code

protected function getLinkGenerator() {
    @trigger_error(__NAMESPACE__ . "\\LinkGeneratorTrait::getLinkGenerator() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Inject the 'link_generator' service or use \\Drupal\\Core\\Link instead. See https://www.drupal.org/node/2614344", E_USER_DEPRECATED);
    if (!isset($this->linkGenerator)) {
        $this->linkGenerator = \Drupal::service('link_generator');
    }
    return $this->linkGenerator;
}

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