Skip to content
Snippets Groups Projects
Commit f3752e63 authored by Jan Hug's avatar Jan Hug
Browse files

Improve checking which links to alter

parent b2bc5a7d
No related branches found
No related tags found
No related merge requests found
......@@ -92,19 +92,27 @@ function layout_builder_iframe_modal_contextual_links_alter(array &$links, $grou
* Implements hook_link_alter().
*/
function layout_builder_iframe_modal_link_alter(&$variables) {
/** @var Drupal\Core\Url $url */
$url = $variables['url'];
$route_name = \Drupal::routeMatch()->getRouteName();
if (!$url || !$url->isRouted()) {
// Only change links on layout builder routes.
if (strpos($route_name, 'layout_builder') === FALSE) {
return;
}
if (empty($variables['options']['attributes']['class']) || !in_array('use-ajax', $variables['options']['attributes']['class'])) {
// Only change links that open in a dialog.
if (empty($variables['options']['attributes']['data-dialog-type'])) {
return;
}
/** @var Drupal\Core\Url $url */
$url = $variables['url'];
if (!$url || !$url->isRouted()) {
return;
}
$route_name = $url->getRouteName();
if (!_layout_builder_iframe_modal_is_layout_builder_route($route_name)) {
$link_route_name = $url->getRouteName();
if (!_layout_builder_iframe_modal_is_layout_builder_route($link_route_name)) {
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment