You are here

function drush_hook_update_deploy_tools_site_deploy_n_set_validate in Hook Update Deploy Tools 7

Same name and namespace in other branches
  1. 8 hook_update_deploy_tools.drush.inc \drush_hook_update_deploy_tools_site_deploy_n_set_validate()

Implements drush_hook_COMMAND_validate().

File

./hook_update_deploy_tools.drush.inc, line 349
Drush commands for Hook Deploy Update Tools.

Code

function drush_hook_update_deploy_tools_site_deploy_n_set_validate($module_name, $set_to = FALSE) {

  // $set_to must be a number and not more than 4 characters.
  if (!empty($set_to)) {
    $lowest_version = floor(VERSION) * 1000;
    $highest_version = $lowest_version + 999;
    switch (TRUE) {

      // First evaluate to TRUE wins.
      case !is_numeric($set_to):
        drush_set_error('HOOK_UPDATE_DEPLOY_TOOLS', dt("The argument 'set_to' must be a number. ex: 7023"));
        break;
      case strlen((string) $set_to) !== 4:
        drush_set_error('HOOK_UPDATE_DEPLOY_TOOLS', dt("The argument 'set_to' must be a 4 digit number. ex: 7023"));
        break;
      case $set_to < $lowest_version:
        drush_set_error('HOOK_UPDATE_DEPLOY_TOOLS', dt("For this site, the argument 'set_to' can not be less than !number.", array(
          '!number' => $lowest_version,
        )));
        break;
      case $set_to > $highest_version:
        drush_set_error('HOOK_UPDATE_DEPLOY_TOOLS', dt("For this site, the argument 'set_to' can not be more than !number.", array(
          '!number' => $highest_version,
        )));
        break;
    }
  }
}