You are here

function slick_devel_library_info_alter in Slick extras 8

Implements hook_library_info_alter().

File

slick_devel/slick_devel.module, line 11
Provides options for the Slick development.

Code

function slick_devel_library_info_alter(&$libraries, $module) {
  $slick_path = drupal_get_path('module', 'slick');
  $path = drupal_get_path('module', 'slick_devel');
  $config = \Drupal::config('slick_devel.settings');
  if ($config
    ->get('unminified')) {

    // Switch to the un-minified version of the library.
    if ($module == 'slick' && isset($libraries['slick'])) {
      $path = 'libraries/slick';
      if (function_exists('blazy_libraries_get_path')) {
        if (blazy_libraries_get_path('slick') || blazy_libraries_get_path('slick-carousel')) {
          $path = blazy_libraries_get_path('slick') ?: blazy_libraries_get_path('slick-carousel');
        }
      }
      else {
        if (!is_file(\Drupal::root() . $path . '/slick/slick.js')) {
          $path = 'libraries/slick-carousel';
        }
      }
      $libraries['slick']['js'] = [
        '/' . $path . '/slick/slick.js' => [],
      ];
    }
  }
  if ($config
    ->get('debug')) {

    // Switch to the development version of the slick.load.js.
    if ($module == 'slick' && isset($libraries['slick.load'])) {
      $libraries['slick.load']['js'] = [
        '/' . $slick_path . '/js/slick.load.js' => [],
      ];
    }
  }
  else {

    // Switch to the development version of the slick.load.js.
    if ($config
      ->get('replace') && $module == 'slick' && isset($libraries['slick.load'])) {
      $libraries['slick.load']['js'] = [
        '/' . $path . '/js/slick.load.devel.js' => [],
      ];
    }
  }
  if ($config
    ->get('disable')) {

    // Disable the module slick.load.js.
    if ($module == 'slick' && isset($libraries['slick.load'])) {
      unset($libraries['slick.load']['js']);
    }
  }
}