function styleswitcher_css_alter in Style Switcher 8.2
Same name and namespace in other branches
- 3.0.x styleswitcher.module \styleswitcher_css_alter()
Implements hook_css_alter().
File
- ./
styleswitcher.module, line 34 - Module's hooks implementations and helper functions.
Code
function styleswitcher_css_alter(&$css, AttachedAssetsInterface $assets) {
$path = drupal_get_path('module', 'styleswitcher') . '/styleswitcher.active.css';
// The dynamic-css library is not always attached. For example, maintenance
// pages don't have it. So check for its presence.
if (isset($css[$path])) {
$asset = $css[$path];
unset($css[$path]);
// Use the latest standard group to be after the most of other css. Some
// themes (like Omega) use even latter groups to set their grid layouts
// hoping they wouldn't be overridden.
$asset['group'] = CSS_AGGREGATE_THEME;
$asset['weight'] = PHP_INT_MAX;
$theme = Drupal::theme()
->getActiveTheme()
->getName();
// Construct absolute URL explicitly to work out disabled clean URLs.
$path = Url::fromRoute('styleswitcher.css', [
'theme' => $theme,
], [
'absolute' => TRUE,
])
->toString();
$css[$path] = $asset;
$css[$path]['data'] = $path;
}
}