Remove all lambda functions
This is an addition to commit 65dc6ce.
There was still a lamba function left in the server model.
This commit is contained in:
@@ -27,6 +27,17 @@
|
|||||||
*/
|
*/
|
||||||
class Server extends CI_Model {
|
class Server extends CI_Model {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a field 'available' to the server.
|
||||||
|
*
|
||||||
|
* This field will be true if the last heartbeat was received less
|
||||||
|
* than 2 minutes ago.
|
||||||
|
*/
|
||||||
|
private function addAvailability($var) {
|
||||||
|
$var['available'] = time_diff($var['last_update'], mysql_now()) < 120 ? true : false;
|
||||||
|
return $var;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new server.
|
* Creates a new server.
|
||||||
*
|
*
|
||||||
@@ -59,10 +70,7 @@ class Server extends CI_Model {
|
|||||||
*/
|
*/
|
||||||
public function getAll() {
|
public function getAll() {
|
||||||
$servers = $this->db->get('servers')->result_array();
|
$servers = $this->db->get('servers')->result_array();
|
||||||
return array_map(function($var) {
|
return array_map(array($this, "addAvailability"), $servers);
|
||||||
$var['available'] = time_diff($var['last_update'], mysql_now()) < 120 ? true : false;
|
|
||||||
return $var;
|
|
||||||
}, $servers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user