Remove lambda functions
We want to be compatible with PHP < 5.3.0. Well, we don't *want* to be, but let's stop splitting hairs.
This commit is contained in:
@@ -38,6 +38,20 @@ class Job extends CI_Model {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a human readable status to the job.
|
||||
*/
|
||||
private function addStatus($var) {
|
||||
if ($var['started_at'] == '0000-00-00 00:00:00') {
|
||||
$var['status'] = 'pending';
|
||||
} else if ($var['finished_at'] == '0000-00-00 00:00:00') {
|
||||
$var['status'] = 'running';
|
||||
} else {
|
||||
$var['status'] = 'complete';
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new job.
|
||||
*
|
||||
@@ -114,14 +128,8 @@ class Job extends CI_Model {
|
||||
public function getById($job_id) {
|
||||
$job = $this->db->get_where('jobs', array('id' => $job_id))->row_array();
|
||||
|
||||
if ($job['started_at'] == '0000-00-00 00:00:00') {
|
||||
$job['status'] = 'pending';
|
||||
} else if ($job['finished_at'] == '0000-00-00 00:00:00') {
|
||||
$job['status'] = 'running';
|
||||
} else {
|
||||
$job['status'] = 'complete';
|
||||
}
|
||||
|
||||
$job = addStatus($job);
|
||||
|
||||
return $job;
|
||||
}
|
||||
|
||||
@@ -141,16 +149,7 @@ class Job extends CI_Model {
|
||||
}
|
||||
|
||||
$jobs = $this->db->get('jobs')->result_array();
|
||||
return array_map(function($var) {
|
||||
if ($var['started_at'] == '0000-00-00 00:00:00') {
|
||||
$var['status'] = 'pending';
|
||||
} else if ($var['finished_at'] == '0000-00-00 00:00:00') {
|
||||
$var['status'] = 'running';
|
||||
} else {
|
||||
$var['status'] = 'complete';
|
||||
}
|
||||
return $var;
|
||||
}, $jobs);
|
||||
return array_map(array($this, "addStatus"), $jobs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user