Commit f2a4b54f authored by Mark Quirvien Cristobal's avatar Mark Quirvien Cristobal
Browse files

Add bootstrap library to composer and alter page attachments

- Issue #3256345 by vhin0210: Add example of altering existing modal links to ReadMe
parent 8d010fc3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -35,3 +35,11 @@ bootstrap4_modal_selection:
    js/entity_browser.bootstrap4_modal_selection.js: {}
  dependencies:
    - core/drupalSettings

bootstrap:
  js:
    /libraries/popper.js/dist/umd/popper.min.js: { weight: -49 }
    /libraries/bootstrap/dist/js/bootstrap.min.js: { weight: -48 }
  css:
    component:
      /libraries/bootstrap/dist/css/bootstrap.min.css: {}
+13 −0
Original line number Diff line number Diff line
@@ -111,3 +111,16 @@ function bootstrap4_modal_preprocess_page(&$variables) {
  $variables['#attached']['library'][] = 'bootstrap4_modal/bs4_modal.dialog';
  $variables['#attached']['library'][] = 'bootstrap4_modal/bs4_modal.dialog.ajax';
}

/**
 * Implements hook_page_attachments_alter().
 */
function bootstrap4_modal_page_attachments_alter(array &$attachments) {
  if (isset($attachments['#attached']) && isset($attachments['#attached']['library'])) {
    $matches = preg_grep('/\/bootstrap/i', $attachments['#attached']['library']);
    if (count($matches) <=0 ){
      $attachments['#attached']['library'][] = 'bootstrap4_modal/bootstrap';
    }
  }
}
+3 −0
Original line number Diff line number Diff line
@@ -21,5 +21,8 @@
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    },
    "require": {
        "twbs/bootstrap": "^5.0.0"
    }
}