splide-1.0.x-dev/tests/modules/splide_test/splide_test.module
tests/modules/splide_test/splide_test.module
<?php
/**
* @file
* Testing Splide.
*/
/**
* Implements hook_theme().
*/
function splide_test_theme() {
return ['splide_test' => ['render element' => 'element']];
}
/**
* Prepares variables for splide-test.html.twig templates.
*/
function template_preprocess_splide_test(&$variables) {
$element = $variables['element'];
$variables['content'] = $element['#children'];
$variables['settings'] = $element['#settings'] ?? [];
}
/**
* Implements hook_library_info_alter().
*/
function splide_test_library_info_alter(array &$libraries, $extension) {
if ($extension === 'splide') {
$path = \Drupal::root() . '/libraries/splide/dist/js/splide.min.js';
if (!is_file($path)) {
$libraries['splide']['js'] = [
'https://cdn.jsdelivr.net/npm/@splidejs/splide@latest/dist/js/splide.min.js' => [
'type' => 'external',
'weight' => -4,
],
];
}
}
}
