-
Notifications
You must be signed in to change notification settings - Fork 8
/
flexslider.install
executable file
·61 lines (54 loc) · 1.8 KB
/
flexslider.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @file
* Installation actions for FlexSlider.
*/
/**
* Implements hook_uninstall().
*
* Deletes all content and configuration installed by this module.
*/
function flexslider_uninstall() {
// Delete all of the configuration installed by this module.
$dir = \Drupal::service('extension.list.module')->getPath('flexslider') . '/config/install';
$files = \Drupal::service('file_system')->scanDirectory($dir, '/.*/');
foreach ($files as $file) {
\Drupal::configFactory()->getEditable($file->name)->delete();
}
\Drupal::logger('flexslider')->info(t('Deleted flexslider configuration'), []);
}
/**
* Implements hook_requirements().
*/
function flexslider_requirements($phase) {
$requirements = [];
// Check to see if the flexslider library is available.
if ($phase == 'runtime') {
$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);
}
if (!$found) {
$requirements['flexslider'] = [
'title' => t('FlexSlider'),
'description' => t('FlexSlider library not found. Please consult the README.md for installation instructions.'),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}
/**
* Add styles to the default configuration for flexslider module.
*/
function flexslider_update_8001() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('flexslider.settings');
$config->set('flexslider_css', TRUE);
$config->set('flexslider_module_css', TRUE);
$config->save(TRUE);
}