From 6c2eb9c1ba2073549287cd4f5176c3fce39a1ab6 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Thu, 30 Jul 2015 15:47:45 +0100 Subject: [PATCH] Issue #2404253 by wuinfo, mermentau: Undefined index: css in color_library_info_alter() --- core/modules/color/color.module | 40 ++++++++++--------- .../color_test_theme.libraries.yml | 7 ++++ .../js/color_test_theme-fontsize.js | 9 +++++ 3 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js diff --git a/core/modules/color/color.module b/core/modules/color/color.module index 9aa932725cb..fa9499b1011 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -76,25 +76,27 @@ function color_library_info_alter(&$libraries, $extension) { $color_paths = \Drupal::config('color.theme.' . $extension)->get('stylesheets'); if (!empty($color_paths)) { foreach (array_keys($libraries) as $name) { - // Override stylesheets. - foreach ($libraries[$name]['css'] as $category => $css_assets) { - foreach ($css_assets as $path => $metadata) { - // Loop over the path array with recolored CSS files to find matching - // paths which could replace the non-recolored paths. - foreach ($color_paths as $color_path) { - // Color module currently requires unique file names to be used, - // which allows us to compare different file paths. - if (drupal_basename($path) == drupal_basename($color_path)) { - // Replace the path to the new css file. - // This keeps the order of the stylesheets intact. - $index = array_search($path, array_keys($libraries[$name]['css'][$category])); - $preceding_css_assets = array_slice($libraries[$name]['css'][$category], 0, $index); - $succeeding_css_assets = array_slice($libraries[$name]['css'][$category], $index + 1); - $libraries[$name]['css'][$category] = array_merge( - $preceding_css_assets, - [$color_path => $metadata], - $succeeding_css_assets - ); + if(isset($libraries[$name]['css'])) { + // Override stylesheets. + foreach ($libraries[$name]['css'] as $category => $css_assets) { + foreach ($css_assets as $path => $metadata) { + // Loop over the path array with recolored CSS files to find matching + // paths which could replace the non-recolored paths. + foreach ($color_paths as $color_path) { + // Color module currently requires unique file names to be used, + // which allows us to compare different file paths. + if (drupal_basename($path) == drupal_basename($color_path)) { + // Replace the path to the new css file. + // This keeps the order of the stylesheets intact. + $index = array_search($path, array_keys($libraries[$name]['css'][$category])); + $preceding_css_assets = array_slice($libraries[$name]['css'][$category], 0, $index); + $succeeding_css_assets = array_slice($libraries[$name]['css'][$category], $index + 1); + $libraries[$name]['css'][$category] = array_merge( + $preceding_css_assets, + [$color_path => $metadata], + $succeeding_css_assets + ); + } } } } diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml index afe431838a7..e4d536dc4ca 100644 --- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml +++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color_test_theme.libraries.yml @@ -3,3 +3,10 @@ base: css: theme: css/colors.css: {} + +fontsizer: + version: VERSION + js: + js/color_test_theme-fontsize.js: {} + dependencies: + - core/jquery diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js b/core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js new file mode 100644 index 00000000000..109f7438a3e --- /dev/null +++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/js/color_test_theme-fontsize.js @@ -0,0 +1,9 @@ +/** + * @file + * Adds javascript functions for font resizing. + */ +(function ($) { + "use strict"; + + $(document).ready(function () {}); +})(jQuery);