There's no way, currently to get the machine name of a task status.

Closest thing is


/**
 * Traslate a task status code into a css class.
 */
function hosting_task_status_class($status = NULL) {

Branch incoming adds hosting_task_status_name() and modifies hosting_task_status_class() to implement it:


/**
 * Return a machine name for each state.
 */
function hosting_task_status_name($hosting_task_status = NULL) {
  $codes = array(
    HOSTING_TASK_SUCCESS    => 'success',
    HOSTING_TASK_QUEUED     => 'queued',
    HOSTING_TASK_ERROR      => 'error',
    HOSTING_TASK_PROCESSING => 'processing',
    HOSTING_TASK_WARNING    => 'warning',
  );
  if (!is_null($hosting_task_status) && isset($codes[$hosting_task_status])) {
    return $codes[$hosting_task_status];
  }
  elseif (!is_null($hosting_task_status) && !isset($codes[$hosting_task_status])) {
    return '';
  }
  else {
    return $codes;
  }
}

/**
 * Return a css class from a hosting task status integer value.
 */
function hosting_task_status_class($status = NULL) {
  if (!is_null($status) && $name = hosting_task_status_name($status)) {
    return 'hosting-' . $name;
  }
  else {
    return '';
  }
}

Comments

Jon Pugh created an issue. See original summary.

  • Jon Pugh committed 5e75ffc on 3015584-hosting-task-status-name
    Issue #3015584: Add function to get task status "name"
    

  • Jon Pugh committed 18fc68a on 3015584-hosting-task-status-name
    Issue #3015584: Add function to get task status "name"
    
jon pugh’s picture

Issue summary: View changes
StatusFileSize
new1.75 KB

  • Jon Pugh committed 5c649e1 on 3015584-hosting-task-status-name
    Issue #3015584: Add function to get task status "name"
    
jon pugh’s picture

Issue summary: View changes
StatusFileSize
new1.73 KB

  • Jon Pugh committed 37b05a7 on 3015584-hosting-task-status-name
    Issue #3015584: Add function to get task status "name"
    
jon pugh’s picture

StatusFileSize
new2.6 KB
helmo’s picture

Status: Needs review » Reviewed & tested by the community

Looks good

jon pugh’s picture

Helmo can you confirm the classes on the task tables are right? Look at queued tasks, make sure they have the grey background and icon.

I thought I saw a regression....

  • Jon Pugh committed 18fc68a on 7.x-3.x
    Issue #3015584: Add function to get task status "name"
    
  • Jon Pugh committed 37b05a7 on 7.x-3.x
    Issue #3015584: Add function to get task status "name"
    
  • Jon Pugh committed 5c649e1 on 7.x-3.x
    Issue #3015584: Add function to get task status "name"
    
  • Jon Pugh committed 5e75ffc on 7.x-3.x
    Issue #3015584: Add function to get task status "name"
    
jon pugh’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, Helmo, merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.