function drush_pm_enable

8.0.x drush_pm_enable()
6.x drush_pm_enable()
7.x drush_pm_enable()
3.x drush_pm_enable()
4.x drush_pm_enable()
5.x drush_pm_enable()
master drush_pm_enable()

Command callback. Enable one or more extensions from downloaded projects. Note that the modules and themes to be enabled were evaluated during the pm-enable validate hook, above.


commands/pm/, line 922
The drush Project Manager


function drush_pm_enable() {
  // Get the data built during the validate phase
  $extension_info = drush_get_context('PM_ENABLE_EXTENSION_INFO');
  $modules = drush_get_context('PM_ENABLE_MODULES');
  $themes = drush_get_context('PM_ENABLE_THEMES');

  // Inform the user which extensions will finally be enabled.
  $extensions = array_merge($modules, $themes);
  if (empty($extensions)) {
    return drush_log(dt('There were no extensions that could be enabled.'), 'ok');
  else {
    drush_print(dt('The following extensions will be enabled: !extensions', array('!extensions' => implode(', ', $extensions))));
    if (!drush_confirm(dt('Do you really want to continue?'))) {
      return drush_user_abort();

  // Enable themes.
  if (!empty($themes)) {

  // Enable modules and pass dependency validation in form submit.
  if (!empty($modules)) {

  // Inform the user of final status.
  $rsc = drush_db_select('system', array('name', 'status'), 'name IN (:extensions)', array(':extensions' => $extensions));
  $problem_extensions = array();
  while ($extension = drush_db_fetch_object($rsc)) {
    if ($extension->status) {
      drush_log(dt('!extension was enabled successfully.', array('!extension' => $extension->name)), 'ok');
    else {
      $problem_extensions[] = $extension->name;
  if (!empty($problem_extensions)) {
    return drush_set_error('DRUSH_PM_ENABLE_EXTENSION_ISSUE', dt('There was a problem enabling !extension.', array('!extension' => implode(',', $problem_extensions))));
  // Return the list of extensions enabled
  return $extensions;