Version 1
[yaffs-website] / web / modules / contrib / dropzonejs / dropzonejs.install
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for the dropzonejs module.
6  */
7
8 /**
9  * Implements hook_requirements().
10  */
11 function dropzonejs_requirements($phase) {
12
13   $requirements = [];
14
15   $path = DRUPAL_ROOT . '/libraries/dropzone/dist/min/dropzone.min.js';
16   if (\Drupal::moduleHandler()->moduleExists('libraries')) {
17     $path = libraries_get_path('dropzone') . '/dist/min/dropzone.min.js';
18   }
19
20   // Is the library found in the root libraries path.
21   $library_found = file_exists($path);
22
23   // If library is not found, then look in the current profile libraries path.
24   if (!$library_found) {
25     $profile_path = drupal_get_path('profile', drupal_get_profile());
26     $profile_path .= '/libraries/dropzone/dist/min/dropzone.min.js';
27     // Is the library found in the current profile libraries path.
28     $library_found = file_exists($profile_path);
29   }
30
31   if (!$library_found) {
32     $requirements['dropzonejs_library'] = array(
33       'title' => t('Dropzone library missing'),
34       'description' => t('Dropzonejs requires the dropzone.min.js library.
35         Download it (https://github.com/enyo/dropzone) and place it in the
36         libraries folder (/libraries)'),
37       'severity' => REQUIREMENT_ERROR,
38     );
39   }
40
41   return $requirements;
42 }
43
44 /**
45  * The upload handler should use stream wrappers.
46  */
47 function dropzonejs_update_8001() {
48   $config_factory = \Drupal::configFactory();
49   $config = $config_factory->getEditable('dropzonejs.settings');
50   $config->clear('tmp_dir');
51   $config->set('tmp_upload_scheme', 'temporary');
52   $config->save(TRUE);
53 }