function seeds_toolbar_preprocess_seeds_toolbar in Seeds Toolbar 8
Implements hook_preprocess_hook().
File
- ./
seeds_toolbar.module, line 274 - Contains seeds_toolbar.module.
Code
function seeds_toolbar_preprocess_seeds_toolbar(&$variables) {
$config = \Drupal::config('seeds_toolbar.settings');
// Clear render cache when saving config.
\Drupal::service('renderer')
->addCacheableDependency($variables, $config);
$variables['attributes']['class'][] = $config
->get('style');
// hoverIntents on Admin Toolbar version 3 does not work because of a different selector, this code will
// help fix this issue by adding the required class. I still don't like how we are adding 'toolbar-tray-horizontal' when
// the toolbar is clearly vertical.
/** @var \Drupal\Core\Extension\ModuleExtensionList $module_extension_list */
$module_extension_list = \Drupal::service('extension.list.module');
$admin_toolbar_info = $module_extension_list
->getExtensionInfo('admin_toolbar');
$version = str_replace('8.x-', '', $admin_toolbar_info['version']);
if (version_compare($version, '3.0.0', '>=')) {
$variables['attributes']['class'][] = 'toolbar-tray-horizontal';
$variables["trays"]["administration"]["attributes"]['class'][] = 'is-active toolbar-tray-horizontal';
}
}