Loading modal_page.module +5 −10 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ function modal_page_form_alter(&$form, FormStateInterface $form_state, $form_id) */ function modal_page_page_attachments(array &$attachments) { // Load Modals. $modals = \Drupal::entityTypeManager()->getStorage('modal')->loadMultiple(); // Get Modals to show on current page. $modals = \Drupal::service('modal_page.modals')->getModalsToShow(); // If there is no, skip it. // If there are none, skip the rest of the function. if (empty($modals)) { return FALSE; } Loading Loading @@ -106,16 +106,11 @@ function modal_page_theme() { */ function modal_page_preprocess_html(&$variables) { // Get Modals to show on this page. // Get Modals to show on the current page. $modals = \Drupal::service('modal_page.modals')->getModalsToShow(); // If there are none, skip the rest of the function. if (empty($modals)) { // If the page has no modals, we can remove all libraries related to the module. $libraries = $variables["page"]["#attached"]["library"]; $bootstrapIndex = array_search("modal_page/modal-page-bootstrap", $libraries); unset($libraries[$bootstrapIndex]); $modalLibraryIndex = array_search("modal_page/modal", $libraries); unset($libraries[$modalLibraryIndex]); return FALSE; } Loading Loading
modal_page.module +5 −10 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ function modal_page_form_alter(&$form, FormStateInterface $form_state, $form_id) */ function modal_page_page_attachments(array &$attachments) { // Load Modals. $modals = \Drupal::entityTypeManager()->getStorage('modal')->loadMultiple(); // Get Modals to show on current page. $modals = \Drupal::service('modal_page.modals')->getModalsToShow(); // If there is no, skip it. // If there are none, skip the rest of the function. if (empty($modals)) { return FALSE; } Loading Loading @@ -106,16 +106,11 @@ function modal_page_theme() { */ function modal_page_preprocess_html(&$variables) { // Get Modals to show on this page. // Get Modals to show on the current page. $modals = \Drupal::service('modal_page.modals')->getModalsToShow(); // If there are none, skip the rest of the function. if (empty($modals)) { // If the page has no modals, we can remove all libraries related to the module. $libraries = $variables["page"]["#attached"]["library"]; $bootstrapIndex = array_search("modal_page/modal-page-bootstrap", $libraries); unset($libraries[$bootstrapIndex]); $modalLibraryIndex = array_search("modal_page/modal", $libraries); unset($libraries[$modalLibraryIndex]); return FALSE; } Loading