You are here

function dropzonejs_library_info_build in DropzoneJS 8.2

Same name and namespace in other branches
  1. 8 dropzonejs.module \dropzonejs_library_info_build()

Implements hook_library_info_build().

File

./dropzonejs.module, line 65
Contains dropzonejs.module.

Code

function dropzonejs_library_info_build() {
  $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_path && file_exists($exif_path)) {
    $libraries['exif-js'] = [
      'title' => 'Exif',
      'website' => 'https://github.com/exif-js/exif-js',
      'version' => 'v2.3.0',
      'license' => [
        'name' => 'MIT',
        'url' => 'https://github.com/exif-js/exif-js/blob/master/LICENSE.md',
        'gpl-compatible' => TRUE,
      ],
      'js' => [
        '/libraries/exif-js/exif.js' => [],
      ],
    ];
  }
  return $libraries;
}