You are here

public function SlickSkinManager::libraryInfoAlter in Slick Carousel 8.2

Implements hook_library_info_alter().

File

src/SlickSkinManager.php, line 385

Class

SlickSkinManager
Provides Slick skin manager.

Namespace

Drupal\slick

Code

public function libraryInfoAlter(&$libraries, $extension) {
  if ($library_path = $this
    ->getSlickPath()) {
    if ($this
      ->config('library') == 'accessible-slick') {
      $libraries['accessible-slick']['js'] = [
        '/' . $library_path . '/slick/slick.min.js' => [
          'weight' => -3,
        ],
      ];
      $libraries['accessible-slick']['css']['base'] = [
        '/' . $library_path . '/slick/slick.min.css' => [],
      ];
      $libraries['slick.css']['css']['theme'] = [
        '/' . $library_path . '/slick/accessible-slick-theme.min.css' => [
          'weight' => -2,
        ],
      ];
      $libraries_to_alter = [
        'slick.load',
        'slick.colorbox',
        'vanilla',
      ];
      foreach ($libraries_to_alter as $library_name) {
        $key = array_search('slick/slick', $libraries[$library_name]['dependencies']);
        $libraries[$library_name]['dependencies'][$key] = 'slick/accessible-slick';
      }
    }
    else {
      $libraries['slick']['js'] = [
        '/' . $library_path . '/slick/slick.min.js' => [
          'weight' => -3,
        ],
      ];
      $libraries['slick']['css']['base'] = [
        '/' . $library_path . '/slick/slick.css' => [],
      ];
      $libraries['slick.css']['css']['theme'] = [
        '/' . $library_path . '/slick/slick-theme.css' => [
          'weight' => -2,
        ],
      ];
    }
  }
  if ($library_easing = $this
    ->getEasingPath()) {
    $libraries['slick.easing']['js'] = [
      '/' . $library_easing => [
        'weight' => -4,
      ],
    ];
  }
  $library_mousewheel = slick_libraries_get_path('mousewheel') ?: slick_libraries_get_path('jquery-mousewheel');
  if ($library_mousewheel) {
    $libraries['slick.mousewheel']['js'] = [
      '/' . $library_mousewheel . '/jquery.mousewheel.min.js' => [
        'weight' => -4,
      ],
    ];
  }
}