Skip to content
Snippets Groups Projects

Add check to preprocess file link hook to not run on webforms

Merged Michael Lee requested to merge lee5151 into main
1 file
+ 9
6
Compare changes
  • Side-by-side
  • Inline
@@ -1147,11 +1147,14 @@ function asc_bootstrap_bux_preprocess_views_exposed_form(&$variables)
*/
function asc_bootstrap_bux_preprocess_file_link(array &$variables)
{
$link = $variables['link'];
$attributes = $link->getUrl()->getOption('attributes');
if (isset($attributes['target']) && $attributes['target'] === '_blank') {
$string = $link->getText();
$string .= " (opens in a new window)";
$link->setText($string);
$route_name = \Drupal::routeMatch()->getRouteName();
if ($route_name !== "entity.webform.canonical") {
$link = $variables['link'];
$attributes = $link->getUrl()->getOption('attributes');
if (isset($attributes['target']) && $attributes['target'] === '_blank') {
$string = $link->getText();
$string .= " (opens in a new window)";
$link->setText($string);
}
}
}
Loading