environment_7.inc

  1. 8.0.x commands/core/drupal/environment_7.inc
  2. 6.x commands/core/drupal/environment_7.inc
  3. 7.x commands/core/drupal/environment_7.inc
  4. 3.x commands/core/drupal/environment_7.inc
  5. master commands/core/drupal/environment_7.inc

Specific functions for a drupal 5 environment. drush_include_engine() magically includes either this file or environment_X.inc depending on which version of drupal drush is called from.

Functions

Namesort descending Description
core_watchdog_severity_levels Helper function to obtain the severity levels based on Drupal version.
drush_check_module_dependencies Return dependencies and its status for modules.
drush_get_modules Get complete information for all available modules.
drush_get_themes Get complete information for all available themes.
drush_module_dependents Return dependents of modules.
drush_module_disable Disable a list of modules. It is assumed the list contains all dependents not already disabled.
drush_module_enable Enable a list of modules. It is assumed the list contains all the dependencies not already enabled.
drush_module_uninstall Uninstall a list of modules.
drush_system_modules_form_submit Submit the system modules form.
drush_theme_disable Disable a list of themes.
drush_theme_enable Enable a list of themes.

File

commands/core/drupal/environment_7.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Specific functions for a drupal 5 environment.
  5. * drush_include_engine() magically includes either this file
  6. * or environment_X.inc depending on which version of drupal drush
  7. * is called from.
  8. */
  9. /**
  10. * Get complete information for all available modules.
  11. *
  12. * @return
  13. * An array containing module info for all installed modules.
  14. */
  15. function drush_get_modules() {
  16. return system_rebuild_module_data();
  17. }
  18. /**
  19. * Return dependencies and its status for modules.
  20. *
  21. * @param $modules
  22. * Array of module names
  23. * @param $module_info
  24. * Drupal 'files' array for modules as returned by drush_get_modules().
  25. * @return
  26. * Array with dependencies and status for $modules
  27. */
  28. function drush_check_module_dependencies($modules, $module_info) {
  29. $status = array();
  30. foreach ($modules as $key => $module) {
  31. $dependencies = $module_info[$module]->requires;
  32. $unmet_dependencies = array_diff(array_keys($dependencies), array_keys($module_info));
  33. if (!empty($unmet_dependencies)) {
  34. $status[$key]['error'] = array(
  35. 'code' => 'DRUSH_PM_ENABLE_DEPENDENCY_NOT_FOUND',
  36. 'message' => dt('Module !module cannot be enabled because it depends on the following modules which could not be found: !unmet_dependencies', array('!module' => $module, '!unmet_dependencies' => implode(',', $unmet_dependencies)))
  37. );
  38. }
  39. else {
  40. // check for version incompatibility
  41. foreach ($dependencies as $dependency_name => $v) {
  42. $current_version = $module_info[$dependency_name]->info['version'];
  43. $incompatibility = drupal_check_incompatibility($v, $current_version);
  44. if (!is_null($incompatibility)) {
  45. $status[$key]['error'] = array(
  46. 'code' => 'DRUSH_PM_ENABLE_DEPENDENCY_VERSION_MISMATCH',
  47. 'message' => dt('Module !module cannot be enabled because it depends on !dependency !required_version but !current_version is available', array('!module' => $module, '!dependency' => $dependency_name, '!required_version' => $incompatibility, '!current_version' => $current_version))
  48. );
  49. }
  50. }
  51. }
  52. $status[$key]['dependencies'] = array_keys($dependencies);
  53. }
  54. return $status;
  55. }
  56. /**
  57. * Return dependents of modules.
  58. *
  59. * @param $modules
  60. * Array of module names
  61. * @param $module_info
  62. * Drupal 'files' array for modules as returned by drush_get_modules().
  63. * @return
  64. * Array with dependents for each one of $modules
  65. */
  66. function drush_module_dependents($modules, $module_info) {
  67. $dependents = array();
  68. foreach ($modules as $module) {
  69. $dependents = array_merge($dependents, array_keys($module_info[$module]->required_by));
  70. }
  71. return array_unique($dependents);
  72. }
  73. /**
  74. * Enable a list of modules. It is assumed the list contains all the dependencies not already enabled.
  75. *
  76. * @param $modules
  77. * Array of module names
  78. */
  79. function drush_module_enable($modules) {
  80. module_enable($modules, FALSE);
  81. }
  82. /**
  83. * Disable a list of modules. It is assumed the list contains all dependents not already disabled.
  84. *
  85. * @param $modules
  86. * Array of module names
  87. */
  88. function drush_module_disable($modules) {
  89. module_disable($modules, FALSE);
  90. }
  91. /**
  92. * Uninstall a list of modules.
  93. *
  94. * @param $modules
  95. * Array of module names
  96. */
  97. function drush_module_uninstall($modules) {
  98. require_once drush_get_context('DRUSH_DRUPAL_ROOT') . '/includes/install.inc';
  99. drupal_uninstall_modules($modules);
  100. }
  101. /**
  102. * Submit the system modules form.
  103. *
  104. * The modules should already be fully enabled/disabled before calling this
  105. * function. Calling this function just makes sure any activities triggered by
  106. * the form submit (such as admin_role) are completed.
  107. */
  108. function drush_system_modules_form_submit($active_modules) {
  109. module_load_include('inc', 'system', 'system.admin');
  110. $form_state = array('values' => array('status' => $active_modules));
  111. drupal_form_submit('system_modules', $form_state);
  112. }
  113. /**
  114. * Get complete information for all available themes.
  115. *
  116. * @return
  117. * An array containing theme info for all available themes.
  118. */
  119. function drush_get_themes() {
  120. return system_rebuild_theme_data();
  121. }
  122. /**
  123. * Enable a list of themes.
  124. *
  125. * @param $themes
  126. * Array of theme names.
  127. */
  128. function drush_theme_enable($themes) {
  129. theme_enable($themes);
  130. }
  131. /**
  132. * Disable a list of themes.
  133. *
  134. * @param $themes
  135. * Array of theme names.
  136. */
  137. function drush_theme_disable($themes) {
  138. theme_disable($themes);
  139. }
  140. /**
  141. * Helper function to obtain the severity levels based on Drupal version.
  142. *
  143. * This is a copy of watchdog_severity_levels() without t().
  144. *
  145. * Severity levels, as defined in RFC 3164: http://www.ietf.org/rfc/rfc3164.txt.
  146. *
  147. * @return
  148. * Array of watchdog severity levels.
  149. */
  150. function core_watchdog_severity_levels() {
  151. return array(
  152. WATCHDOG_EMERGENCY=> 'emergency',
  153. WATCHDOG_ALERT => 'alert',
  154. WATCHDOG_CRITICAL => 'critical',
  155. WATCHDOG_ERROR => 'error',
  156. WATCHDOG_WARNING => 'warning',
  157. WATCHDOG_NOTICE => 'notice',
  158. WATCHDOG_INFO => 'info',
  159. WATCHDOG_DEBUG => 'debug',
  160. );
  161. }