Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / commands / core / drupal / pm_8.inc
1 <?php
2
3 use Drush\Log\LogLevel;
4
5 /**
6  * Command callback. Drupal 8 does not support disabled modules.
7  *
8  * @param array $args
9  *   Arguments from the command line.
10  */
11 function _drush_pm_disable($args) {
12   drush_include_engine('drupal', 'environment');
13   // To be consistent call the environment.inc function which will show the user
14   // an error.
15   drush_module_disable($args);
16 }
17
18 /**
19  * Command callback. Uninstall one or more extensions.
20  *
21  * @param array $args
22  *   Arguments from the command line.
23  */
24 function _drush_pm_uninstall($extensions) {
25   $extension_info = drush_get_extensions();
26   $required = drush_drupal_required_modules($extension_info);
27
28   // Discards extensions which are enabled, not found or already uninstalled.
29   $extensions = array_combine($extensions, $extensions);
30   foreach ($extensions as $extension) {
31     if (!isset($extension_info[$extension])) {
32       unset($extensions[$extension]);
33       drush_log(dt('Extension !extension was not found and will not be uninstalled.', array('!extension' => $extension)), LogLevel::WARNING);
34     }
35     elseif (in_array($extension, $required)) {
36       unset($extensions[$extension]);
37       $info = $extension_info[$extension]->info;
38       $explanation = !empty($info['explanation']) ? ' ' . dt('Reason: !explanation.', array('!explanation' => strip_tags($info['explanation'])))  : '';
39       drush_log(dt('!extension is a required extension and can\'t be uninstalled.', array('!extension' => $extension)) . $explanation, LogLevel::OK);
40     }
41     elseif (!$extension_info[$extension]->status) {
42       unset($extensions[$extension]);
43       drush_log(dt('!extension is already uninstalled.', array('!extension' => $extension)), LogLevel::OK);
44     }
45     elseif (drush_extension_get_type($extension_info[$extension]) == 'module') {
46       // Add installed dependencies to the list of modules to uninstall.
47       foreach (drush_module_dependents(array($extension), $extension_info) as $dependent) {
48         // Check if this dependency is not required, already enabled, and not already already in the list of modules to uninstall.
49         if (!in_array($dependent, $required) && ($extension_info[$dependent]->status) && !in_array($dependent, $extensions)) {
50           $extensions[] = $dependent;
51         }
52       }
53     }
54   }
55
56   // Discard default theme.
57   $default_theme = drush_theme_get_default();
58   if (in_array($default_theme, $extensions)) {
59     unset($extensions[$default_theme]);
60     drush_log(dt('!theme is the default theme and can\'t be uninstalled.', array('!theme' => $default_theme)), LogLevel::OK);
61   }
62
63   // Inform the user which extensions will finally be disabled.
64   if (empty($extensions)) {
65     return drush_log(dt('There were no extensions that could be uninstalled.'), LogLevel::OK);
66   }
67   else {
68     drush_print(dt('The following extensions will be uninstalled: !extensions', array('!extensions' => implode(', ', $extensions))));
69     if(!drush_confirm(dt('Do you really want to continue?'))) {
70       return drush_user_abort();
71     }
72   }
73
74   // Classify extensions in themes and modules.
75   $modules = array();
76   $themes = array();
77   drush_pm_classify_extensions($extensions, $modules, $themes, $extension_info);
78
79   drush_module_uninstall($modules);
80   drush_theme_uninstall($themes);
81
82   // Inform the user of final status.
83   foreach ($extensions as $extension) {
84     drush_log(dt('!extension was successfully uninstalled.', array('!extension' => $extension)), LogLevel::OK);
85   }
86 }