You are here

function seeds_toolbar_library_info_alter in Seeds Toolbar 8

Implements hook_library_info_alter().

File

./seeds_toolbar.module, line 100
Contains seeds_toolbar.module.

Code

function seeds_toolbar_library_info_alter(&$libraries, $extension) {

  // Clear all attached js and css from toolbar module and admin toolbar.
  if ($extension == 'toolbar' || $extension == 'admin_toolbar') {
    $libraries['toolbar.menu']['css'] = [];
    $libraries['toolbar.escapeAdmin']['css'] = [];
    $libraries['toolbar']['css'] = [];
    $libraries['toolbar.menu']['js'] = [];
    $libraries['toolbar.escapeAdmin']['js'] = [];
    $libraries['toolbar']['js'] = [];
    $libraries['toolbar.tree']['css'] = [];
    $libraries['toolbar.icon']['js'] = [];
  }

  // Fix JS loading compatibility for Responsive Preview module.
  if ($extension == "seeds_toolbar") {
    $moduleHandler = \Drupal::service('module_handler');
    if ($moduleHandler
      ->moduleExists('responsive_preview')) {
      $libraries['toolbar.seeds']['dependencies'][] = 'responsive_preview/drupal.responsive-preview';
    }

    // Add custom style if there exist any.
    $custom_style = \Drupal::config('seeds_toolbar.settings')
      ->get('custom_style');
    if (isset($custom_style) && !empty($custom_style)) {
      $libraries['toolbar.seeds']['css']['theme'][$custom_style] = [];
    }
  }
}