LinkGenerator::__construct

public LinkGenerator::__construct(UrlGeneratorInterface $url_generator, ModuleHandlerInterface $module_handler, RendererInterface $renderer) Constructs a LinkGenerator instance. Parameters \Drupal\Core\Routing\UrlGeneratorInterface $url_generator: The url generator. \Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler. \Drupal\Core\Render\RendererInterface $renderer: The renderer service. File core/lib/Drupal/Core/Utility/LinkGenerator.php, line 53 Class LinkGe

LinkGenerator::generateFromLink

public LinkGenerator::generateFromLink(Link $link) Renders a link from a link object. @internal Should not be used in user code. Use \Drupal\Core\Link instead. Parameters \Drupal\Core\Link $link: A link object to convert to a string. Return value \Drupal\Core\GeneratedLink A GeneratedLink object containing a link to the given route and parameters and bubbleable metadata. Overrides LinkGeneratorInterface::generateFromLink File core/lib/Drupal/Core/Utility/LinkGenerator.php, line 62 Class L

LinkGenerator::generate

public LinkGenerator::generate($text, Url $url) For anonymous users, the "active" class will be calculated on the server, because most sites serve each anonymous user the same cached page anyway. For authenticated users, the "active" class will be calculated on the client (through JavaScript), only data- attributes are added to links to prevent breaking the render cache. The JavaScript is added in system_page_attachments(). Overrides LinkGeneratorInterface::generate See also system_page_attac

LinkGenerator::$urlGenerator

The url generator. Type: \Drupal\Core\Routing\UrlGeneratorInterface File core/lib/Drupal/Core/Utility/LinkGenerator.php, line 27 Class LinkGenerator Provides a class which generates a link with route names and parameters. Namespace Drupal\Core\Utility Code protected $urlGenerator;

LinkGenerator::$renderer

The renderer service. Type: \Drupal\Core\Render\RendererInterface File core/lib/Drupal/Core/Utility/LinkGenerator.php, line 41 Class LinkGenerator Provides a class which generates a link with route names and parameters. Namespace Drupal\Core\Utility Code protected $renderer;

LinkGenerator::$moduleHandler

The module handler firing the route_link alter hook. Type: \Drupal\Core\Extension\ModuleHandlerInterface File core/lib/Drupal/Core/Utility/LinkGenerator.php, line 34 Class LinkGenerator Provides a class which generates a link with route names and parameters. Namespace Drupal\Core\Utility Code protected $moduleHandler;

LinkGenerator

Provides a class which generates a link with route names and parameters. Hierarchy class \Drupal\Core\Utility\LinkGenerator implements LinkGeneratorInterface File core/lib/Drupal/Core/Utility/LinkGenerator.php, line 20 Namespace Drupal\Core\Utility Members Name Modifiers Type Description LinkGenerator::$moduleHandler protected property The module handler firing the route_link alter hook. LinkGenerator::$renderer protected property The renderer service. LinkGene

Link::__construct

public Link::__construct($text, Url $url) Constructs a new Link object. Parameters string $text: The text of the link. \Drupal\Core\Url $url: The url object. File core/lib/Drupal/Core/Link.php, line 40 Class Link Defines an object that holds information about a link. Namespace Drupal\Core Code public function __construct($text, Url $url) { $this->text = $text; $this->url = $url; }

Link::toString

public Link::toString() Generates the HTML for this Link object. Do not use this method to render a link in an HTML context. In an HTML context, self::toRenderable() should be used so that render cache information is maintained. However, there might be use cases such as tests and non-HTML contexts where calling this method directly makes sense. Return value \Drupal\Core\GeneratedLink The link HTML markup. See also \Drupal\Core\Link::toRenderable() File core/lib/Drupal/Core/Link.php, line 148

Link::toRenderable

public Link::toRenderable() Returns a render array representation of the object. Return value mixed[] A render array. Overrides RenderableInterface::toRenderable File core/lib/Drupal/Core/Link.php, line 155 Class Link Defines an object that holds information about a link. Namespace Drupal\Core Code public function toRenderable() { return [ '#type' => 'link', '#url' => $this->url, '#title' => $this->text, ]; }