From ded8dc77d25fbb80fc51bca9f0a2c397375ae98f Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 2 Oct 2013 22:34:56 +0100 Subject: [PATCH] Issue #2040269 by Tim Bozeman, RunePhilosof, typhonius, Cottser: Remove drupal_add_css() from bartik.theme. --- core/themes/bartik/bartik.theme | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index aafb0e74301..0a794017476 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -5,6 +5,8 @@ * Functions to support theming in the Bartik theme. */ +use Drupal\Core\Template\RenderWrapper; + /** * Implements hook_preprocess_HOOK() for html.tpl.php. * @@ -84,8 +86,18 @@ function bartik_preprocess_maintenance_page(&$variables) { if (!$variables['db_is_active']) { $variables['site_name'] = ''; } - drupal_add_css(drupal_get_path('theme', 'bartik') . '/css/maintenance-page.css'); - $variables['styles'] = drupal_get_css(); + $variables['styles'] = new RenderWrapper('drupal_get_css'); + // Normally we could attach libraries via hook_page_alter(), but when the + // database is inactive it's not called so we add them here. + $libraries = array( + '#attached' => array( + 'library' => array( + array('bartik', 'maintenance_page'), + ), + ), + ); + + drupal_render($libraries); $site_config = \Drupal::config('system.site'); // Always print the site name and slogan, but if they are toggled off, we'll @@ -102,6 +114,23 @@ function bartik_preprocess_maintenance_page(&$variables) { } } +/** + * Implements hook_library_info(). + */ +function bartik_library_info() { + $path = drupal_get_path('theme', 'bartik'); + $libraries['maintenance_page'] = array( + 'version' => \DRUPAL::VERSION, + 'css' => array( + $path . '/css/maintenance-page.css' => array( + 'group' => CSS_AGGREGATE_THEME, + ), + ), + ); + + return $libraries; +} + /** * Implements hook_preprocess_HOOK() for node.html.twig. */