You are here

function drush_deploy_delete_plan in Deploy - Content Staging 7.3

Same name and namespace in other branches
  1. 7.2 deploy.drush.inc \drush_deploy_delete_plan()

Command callback for deleting a deployment plan.

File

./deploy.drush.inc, line 206
Provides Drush integration for Deploy.

Code

function drush_deploy_delete_plan($name) {
  $plan = deploy_plan_load($name);
  if (FALSE === $plan) {

    // We don't care if the plan doesn't exist. The user just wants it removed.
    drush_print(dt("Plan '@name' doesn't exist.", array(
      '@name' => $name,
    )));
    return DRUSH_SUCCESS;
  }

  // Cast to ensure proper bitwise evaluation.
  $plan->export_type = (int) $plan->export_type;
  if (EXPORT_IN_DATABASE !== ($plan->export_type & EXPORT_IN_DATABASE)) {
    return drush_set_error(dt("Plan '@name' only exists in code. This plan can't be deleted.", array(
      '@name' => $name,
    )));
  }
  $confirm_message = dt("Are you sure you want to delete plan named '@name'?", array(
    '@name' => $name,
  ));
  $exported = FALSE;
  if (EXPORT_IN_CODE === ($plan->export_type & EXPORT_IN_CODE)) {
    $exported = TRUE;
    $confirm_message = dt("Plan '@name' is exported to code. Do you want to revert this plan to the exported configuration?", array(
      '@name' => $name,
    ));
  }
  if (!drush_confirm($confirm_message)) {
    drush_user_abort();
  }
  ctools_export_crud_delete('deploy_plans', $name);
  if ($exported) {
    drush_print(dt("Reverted plan '@name'.", array(
      '@name' => $name,
    )));
  }
  else {
    drush_print(dt("Deleted plan '@name'.", array(
      '@name' => $name,
    )));
  }
}