function ng_lightbox_link_alter in NG Lightbox 8
Same name and namespace in other branches
- 2.x ng_lightbox.module \ng_lightbox_link_alter()
Implements hook_link_alter().
File
- ./
ng_lightbox.module, line 11 - The NG Lightbox module.
Code
function ng_lightbox_link_alter(&$vars) {
/** @var \Drupal\ng_lightbox\NgLightbox $lightbox */
$lightbox = \Drupal::service('ng_lightbox');
if ($lightbox
->isNgLightboxEnabledPath($vars['url'])) {
$lightbox
->addLightbox($vars);
}
elseif (!empty($vars['options']['attributes']['class'])) {
// We have to normalize to an array because many places incorrectly set
// class to a string.
$vars['options']['attributes']['class'] = (array) $vars['options']['attributes']['class'];
if (in_array('ng-lightbox', $vars['options']['attributes']['class'])) {
$lightbox
->addLightbox($vars);
}
}
// If you've enabled/disabled the modal for admin paths this allows you to
// override it for one off paths.
\Drupal::moduleHandler()
->alter('ng_lightbox_ajax_path', $vars);
}