protected function LinkGenerator::doGenerate in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Utility/LinkGenerator.php \Drupal\Core\Utility\LinkGenerator::doGenerate()
Generates the link.
Parameters
Drupal\Core\GeneratedLink $generated_link: The generated link, along with its associated cacheability metadata.
array $attributes: The attributes of the generated link.
array $variables: The link text, url, and other options.
Return value
Drupal\Core\GeneratedLink The generated link, along with its associated cacheability metadata.
1 call to LinkGenerator::doGenerate()
- LinkGenerator::generate in core/
lib/ Drupal/ Core/ Utility/ LinkGenerator.php - 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…
File
- core/
lib/ Drupal/ Core/ Utility/ LinkGenerator.php, line 203
Class
- LinkGenerator
- Provides a class which generates a link with route names and parameters.
Namespace
Drupal\Core\UtilityCode
protected function doGenerate($generated_link, $attributes, $variables) {
if (!$variables['text'] instanceof MarkupInterface) {
$variables['text'] = Html::escape($variables['text']);
}
$attributes = new Attribute($attributes);
// This is safe because Attribute does escaping and $variables['text'] is
// either rendered or escaped.
return $generated_link
->setGeneratedLink('<' . $generated_link::TAG . $attributes . '>' . $variables['text'] . '</' . $generated_link::TAG . '>');
}