v1/vendor/chi-teck/drupal-code-generator/templates/hook/link_alter.twig

12 lines
390 B
Twig

/**
* Implements hook_link_alter().
*/
function {{ machine_name }}_link_alter(&$variables) {
// Add a warning to the end of route links to the admin section.
/** @var \Drupal\Core\Url $url */
$url = $variables['url'];
if ($url->isRouted() && strpos($url->getRouteName(), 'admin') !== FALSE) {
$variables['text'] = t('@text (Warning!)', ['@text' => $variables['text']]);
}
}