From 74b5ae9b87185e456d33ab56a987a936459daa5d Mon Sep 17 00:00:00 2001 From: Purencool <purencool@gmail.com> Date: Sat, 1 Jun 2024 09:18:06 +1000 Subject: [PATCH] #3437099 made sure the css file is loaded below the theme. --- .../browser_development_assist.module | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/modules/browser_development_assist/browser_development_assist.module b/modules/browser_development_assist/browser_development_assist.module index 5a12451..829ae3a 100644 --- a/modules/browser_development_assist/browser_development_assist.module +++ b/modules/browser_development_assist/browser_development_assist.module @@ -7,6 +7,7 @@ use Drupal\browser_development_assist\Processing\FileSystemStructure; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Asset\AttachedAssetsInterface; /** * Implements hook_help(). @@ -27,20 +28,6 @@ function browser_development_assist_help($route_name, RouteMatchInterface $route } } -/** - * Implements hook_page_attachments(). - */ -function browser_development_assist_page_attachments(array &$page) { - - // Attaching library to theme - $active = \Drupal::theme()->getActiveTheme()->getName(); - $current_theme = \Drupal::config('system.theme')->get('default'); - if ($active === $current_theme) { - $page['#attached']['library'][] = 'browser_development_assist/browser-development-assist'; - } -} - - /** * Implements hook_library_info_build(). */ @@ -53,10 +40,43 @@ function browser_development_assist_library_info_build() { 'version' => 'VERSION', 'css' => [ 'theme' => [ - "$css" => ['weight' => '100'] + "$css" => [] ] ], ], ]; } +/** + * Attaches + * + * Implements hook_page_attachments(). + */ +function browser_development_assist_page_attachments(array &$page) { + + // Attaching library to theme + $active = \Drupal::theme()->getActiveTheme()->getName(); + $current_theme = \Drupal::config('system.theme')->get('default'); + if ($active === $current_theme) { + $page['#attached']['library'][] = 'browser_development_assist/browser-development-assist'; + } +} + + + + + +/** + * Implements hook_css_alter(). + */ +function browser_development_assist_css_alter(&$css, AttachedAssetsInterface $assets) { + + $library = \Drupal::service('library.discovery') + ->getLibraryByName('browser_development_assist', 'browser-development-assist'); + + $path = $library['css'][0]['data']; + + if (isset($css[$path])) { + $css[$path]['group'] = 300; + } +} -- GitLab