Skip to content

Commit

Permalink
refactor: drop support for Drupal 8
Browse files Browse the repository at this point in the history
Drop mentions of jQuery Easing module (not available for D9+)
Remove hook_libraries*
  • Loading branch information
Mathew Winstone authored and Mathew Winstone committed Jul 24, 2023
1 parent 3e7218e commit f365797
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 128 deletions.
2 changes: 1 addition & 1 deletion flexslider.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ dependencies:
- drupal:image
type: module
configure: entity.flexslider.collection
core_version_requirement: ^8 || ^9 || ^10
core_version_requirement: ^9 || ^10
23 changes: 7 additions & 16 deletions flexslider.install
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,14 @@ function flexslider_requirements($phase) {

// Check to see if the flexslider library is available.
if ($phase == 'runtime') {
// @todo Remove this conditional once 8.9 is the minimum supported core
// version.
if (\Drupal::hasService('library.libraries_directory_file_finder')) {
/** @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder $library_file_finder */
$library_file_finder = \Drupal::service('library.libraries_directory_file_finder');
$found = (bool) $library_file_finder->find('flexslider/jquery.flexslider-min.js');
}
else {
$path = DRUPAL_ROOT . '/libraries/flexslider/jquery.flexslider-min.js';
$found = file_exists($path);
$path = DRUPAL_ROOT . '/libraries/flexslider/jquery.flexslider-min.js';
$found = file_exists($path);

// Find the library in the profiles path if not found.
if (!$found) {
$path = \Drupal::service('extension.list.profile')->getPath(\Drupal::installProfile());
$path .= '/libraries/flexslider/jquery.flexslider-min.js';
$found = file_exists($path);
}
// Find the library in the profiles path if not found.
if (!$found) {
$path = \Drupal::service('extension.list.profile')->getPath(\Drupal::installProfile());
$path .= '/libraries/flexslider/jquery.flexslider-min.js';
$found = file_exists($path);
}

if (!$found) {
Expand Down
108 changes: 0 additions & 108 deletions flexslider.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,6 @@
use Drupal\Core\Url;
use Drupal\flexslider\Entity\Flexslider;

/**
* Implements hook_libraries_info().
*
* @todo Remove this once 8.9 is the minimal core version and Libraries is no
* longer required.
*/
function flexslider_libraries_info() {
$libraries['flexslider'] = [
'name' => 'FlexSlider',
'vendor url' => 'http://www.woothemes.com/flexslider/',
'download url' => 'https://github.com/woothemes/FlexSlider',
'version arguments' => [
'file' => 'jquery.flexslider-min.js',
// e.g. jQuery FlexSlider v2.1.
'pattern' => '/jQuery FlexSlider v(\d+\.+\d+(\.+\d+)?)/',
'lines' => 2,
],
'files' => [
'js' => [
'jquery.flexslider-min.js',
],
'css' => [
'flexslider.css',
],
],
];

return $libraries;
}

/**
* Implements hook_libraries_info_alter().
*
* @todo Remove this once 8.9 is the minimal core version and Libraries is no
* longer required.
*/
function flexslider_libraries_info_alter(&$libraries) {
$debug = \Drupal::config('flexslider.settings')->get('flexslider_debug');
if ($debug) {
// Switch to the unminified version of the library.
if (isset($libraries['flexslider'])) {
$libraries['flexslider']['files']['js'] = [
'jquery.flexslider.js',
];
}
}

// Add support for jQuery Easing module.
if (\Drupal::moduleHandler()->moduleExists('jqeasing')) {
$libraries['flexslider']['dependencies'][] = 'easing (>=1.3)';
}

// Remove the library css if privileged user disabled it.
if (!\Drupal::config('flexslider.settings')->get('flexslider_css')) {
if (!empty($libraries['flexslider']['files']['css']) && ($key = array_search('flexslider.css', $libraries['flexslider']['files']['css']))) {
unset($libraries['flexslider']['files']['css'][$key]);
}
}
}

/**
* Implements hook_library_info_alter().
Expand Down Expand Up @@ -107,12 +48,6 @@ function flexslider_library_info_alter(&$libraries, $extension) {
];
}

// Add support for jQuery Easing module.
if (\Drupal::moduleHandler()->moduleExists('jqeasing')) {
// Using the jqeasing module.
$libraries['flexslider']['dependencies'][] = 'jqeasing.easing';
}

}
}

Expand Down Expand Up @@ -256,46 +191,3 @@ function flexslider_add($id = NULL, $optionset = NULL) {

return $attached;
}

/**
* List of all easing methods available from jQuery Easing v1.3.
*
* @return array
* Array of easing methods
*/
function _flexslider_jqeasing_options() {
return [
"jswing" => "jswing",
"def" => "def",
"easeInQuad" => "easeInQuad",
"easeOutQuad" => "easeOutQuad",
"easeInOutQuad" => "easeInOutQuad",
"easeInCubic" => "easeInCubic",
"easeOutCubic" => "easeOutCubic",
"easeInOutCubic" => "easeInOutCubic",
"easeInQuart" => "easeInQuart",
"easeOutQuart" => "easeOutQuart",
"easeInOutQuart" => "easeInOutQuart",
"easeInQuint" => "easeInQuint",
"easeOutQuint" => "easeOutQuint",
"easeInOutQuint" => "easeInOutQuint",
"easeInSine" => "easeInSine",
"easeOutSine" => "easeOutSine",
"easeInOutSine" => "easeInOutSine",
"easeInExpo" => "easeInExpo",
"easeOutExpo" => "easeOutExpo",
"easeInOutExpo" => "easeInOutExpo",
"easeInCirc" => "easeInCirc",
"easeOutCirc" => "easeOutCirc",
"easeInOutCirc" => "easeInOutCirc",
"easeInElastic" => "easeInElastic",
"easeOutElastic" => "easeOutElastic",
"easeInOutElastic" => "easeInOutElastic",
"easeInBack" => "easeInBack",
"easeOutBack" => "easeOutBack",
"easeInOutBack" => "easeInOutBack",
"easeInBounce" => "easeInBounce",
"easeOutBounce" => "easeOutBounce",
"easeInOutBounce" => "easeInOutBounce",
];
}
2 changes: 1 addition & 1 deletion flexslider_example/flexslider_example.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'FlexSlider Example'
description: 'Provide FlexSlider Example content type and related configuration. Used for generating example FlexSlider implementations'
type: module
core_version_requirement: ^8 || ^9 || ^10
core_version_requirement: ^9 || ^10
package: FlexSlider
dependencies:
- drupal:field
Expand Down
2 changes: 1 addition & 1 deletion flexslider_fields/flexslider_fields.info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'FlexSlider Fields'
description: 'Adds a display mode in Fields for FlexSlider'
core_version_requirement: ^8 || ^9 || ^10
core_version_requirement: ^9 || ^10
package: FlexSlider
dependencies:
- flexslider:flexslider
Expand Down
2 changes: 1 addition & 1 deletion flexslider_views/flexslider_views.info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'FlexSlider Views Style'
description: 'Adds a Views style plugin for FlexSlider'
core_version_requirement: ^8 || ^9 || ^10
core_version_requirement: ^9 || ^10
package: FlexSlider
dependencies:
- drupal:views
Expand Down

0 comments on commit f365797

Please sign in to comment.