LinkGenerator
class LinkGenerator implements LinkGeneratorInterface (View source)
Provides a class which generates a link with route names and parameters.
Properties
| protected UrlGeneratorInterface | $urlGenerator | The url generator. |
|
| protected ModuleHandlerInterface | $moduleHandler | The module handler firing the route_link alter hook. |
|
| protected RendererInterface | $renderer | The renderer service. |
Methods
__construct(UrlGeneratorInterface $url_generator, ModuleHandlerInterface $module_handler, RendererInterface $renderer)
Constructs a LinkGenerator instance.
GeneratedLink
doGenerate(GeneratedLink $generated_link, array $attributes, array $variables)
Generates the link.
Details
__construct(UrlGeneratorInterface $url_generator, ModuleHandlerInterface $module_handler, RendererInterface $renderer)
Constructs a LinkGenerator instance.
GeneratedLink
generateFromLink(Link $link)
Renders a link from a link object.
GeneratedLink
generate(string|array|MarkupInterface $text, Url $url)
Renders a link to a URL.
Examples:
protected GeneratedLink
doGenerate(GeneratedLink $generated_link, array $attributes, array $variables)
Generates the link.