You are here

function dropzonejs_requirements in DropzoneJS 8

Same name and namespace in other branches
  1. 8.2 dropzonejs.install \dropzonejs_requirements()

Implements hook_requirements().

File

./dropzonejs.install, line 11
Install, update and uninstall functions for the dropzonejs module.

Code

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';
  }

  // 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_get_profile());
    $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) {
    $requirements['dropzonejs_library'] = array(
      'title' => t('Dropzone library missing'),
      'description' => t('Dropzonejs requires the dropzone.min.js library.
        Download it (https://github.com/enyo/dropzone) and place it in the
        libraries folder (/libraries)'),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}