You are here

slick_test.module in Slick Carousel 8.2

Testing Slick.

File

tests/modules/slick_test/slick_test.module
View source
<?php

/**
 * @file
 * Testing Slick.
 */

/**
 * Implements hook_theme().
 */
function slick_test_theme() {
  return [
    'slick_test' => [
      'render element' => 'element',
    ],
  ];
}

/**
 * Prepares variables for slick-test.html.twig templates.
 */
function template_preprocess_slick_test(&$variables) {
  $element = $variables['element'];
  $variables['content'] = $element['#children'];
  $variables['settings'] = isset($element['#settings']) ? $element['#settings'] : [];
}

/**
 * Implements hook_library_info_alter().
 */
function slick_test_library_info_alter(array &$libraries, $extension) {
  if ($extension === 'slick') {
    $path = \Drupal::root() . '/libraries/slick/slick/slick.min.js';
    if (!is_file($path)) {
      $libraries['slick']['js'] = [
        'https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js' => [
          'type' => 'external',
          'weight' => -4,
        ],
      ];
      unset($libraries['slick']['js']['/libraries/slick/slick/slick.min.js']);
    }
  }
}

Functions