Commit 5fd2c222 authored by phenaproxima's avatar phenaproxima Committed by chr.fritsch

Issue #3099836 by phenaproxima, Berdir: Use new LibrariesDirectoryFinder

parent a7477cd2
......@@ -12,20 +12,30 @@ function dropzonejs_requirements($phase) {
$requirements = [];
$path = DRUPAL_ROOT . '/libraries/dropzone/dist/min/dropzone.min.js';
if (\Drupal::moduleHandler()->moduleExists('libraries')) {
$path = libraries_get_path('dropzone') . '/dist/min/dropzone.min.js';
// @todo Remove this conditional structure in favor of using the libraries
// directory file finder service when Drupal 8.9 is the minimum supported
// version of core.
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');
$library_found = (bool) $library_file_finder->find('dropzone/dist/min/dropzone.min.js');
}
else {
$path = DRUPAL_ROOT . '/libraries/dropzone/dist/min/dropzone.min.js';
if (\Drupal::moduleHandler()->moduleExists('libraries')) {
$path = libraries_get_path('dropzone') . '/dist/min/dropzone.min.js';
}
// Is the library found in the root libraries path.
$library_found = file_exists($path);
// Is the library found in the root libraries path.
$library_found = file_exists($path);
// If library is not found, then look in the current profile libraries path.
if (!$library_found) {
$profile_path = drupal_get_path('profile', \Drupal::installProfile());
$profile_path .= '/libraries/dropzone/dist/min/dropzone.min.js';
// Is the library found in the current profile libraries path.
$library_found = file_exists($profile_path);
// If library is not found, then look in the current profile libraries path.
if (!$library_found) {
$profile_path = drupal_get_path('profile', \Drupal::installProfile());
$profile_path .= '/libraries/dropzone/dist/min/dropzone.min.js';
// Is the library found in the current profile libraries path.
$library_found = file_exists($profile_path);
}
}
if (!$library_found) {
......
......@@ -65,14 +65,22 @@ function template_preprocess_dropzonejs(array &$variables) {
function dropzonejs_library_info_build() {
$libraries = [];
if (\Drupal::moduleHandler()->moduleExists('libraries')) {
// @todo Remove this conditional structure in favor of using the libraries
// directory file finder service when Drupal 8.9 is the minimum supported
// version of core.
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');
$exif_path = $library_file_finder->find('exif-js/exif.js');
}
elseif (\Drupal::moduleHandler()->moduleExists('libraries')) {
$exif_path = libraries_get_path('exif-js') . '/exif.js';
}
else {
$exif_path = DRUPAL_ROOT . '/libraries/exif-js/exif.js';
}
if ($exif_found = file_exists($exif_path)) {
if ($exif_path && file_exists($exif_path)) {
$libraries['exif-js'] = [
'title' => 'Exif',
'website' => 'https://github.com/exif-js/exif-js',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment