- Adds a helper method to convert cameCase to under_score
- Removes unused method from Queue daemon
This commit is contained in:
@@ -78,6 +78,34 @@ class Daemon {
|
|||||||
$this->callSelf();
|
$this->callSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getQueue() {
|
||||||
|
$queue = Setting::where('name', 'queue')
|
||||||
|
->findOne();
|
||||||
|
return array(
|
||||||
|
($queue) ? $queue : null,
|
||||||
|
($queue) ? unserialize($queue->value) : null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshToken() {
|
||||||
|
return Security::generateRandomString(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
function manageSession($action) {
|
||||||
|
switch ($action) {
|
||||||
|
case 'start':
|
||||||
|
if(session_id()) {
|
||||||
|
session_write_close();
|
||||||
|
}
|
||||||
|
session_id($this->payload['session']);
|
||||||
|
session_start();
|
||||||
|
break;
|
||||||
|
case 'end':
|
||||||
|
session_write_close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function callSelf() {
|
function callSelf() {
|
||||||
$payload = json_encode(array('token' => $this->refreshedToken));
|
$payload = json_encode(array('token' => $this->refreshedToken));
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -100,39 +128,4 @@ class Daemon {
|
|||||||
));
|
));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQueue() {
|
|
||||||
$queue = Setting::where('name', 'queue')
|
|
||||||
->findOne();
|
|
||||||
return array(
|
|
||||||
($queue) ? $queue : null,
|
|
||||||
($queue) ? unserialize($queue->value) : null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkAuthorization() {
|
|
||||||
if(!current_user_can('manage_options')) {
|
|
||||||
header('HTTP/1.0 401 Not Authorized');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshToken() {
|
|
||||||
return Security::generateRandomString(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
function manageSession($action) {
|
|
||||||
switch ($action) {
|
|
||||||
case 'start':
|
|
||||||
if(session_id()) {
|
|
||||||
session_write_close();
|
|
||||||
}
|
|
||||||
session_id($this->payload['session']);
|
|
||||||
session_start();
|
|
||||||
break;
|
|
||||||
case 'end':
|
|
||||||
session_write_close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -178,4 +178,10 @@ class Helpers {
|
|||||||
$func = create_function('$c', 'return strtoupper($c[1]);');
|
$func = create_function('$c', 'return strtoupper($c[1]);');
|
||||||
return preg_replace_callback('/_([a-z])/', $func, $str);
|
return preg_replace_callback('/_([a-z])/', $func, $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function camelCaseToUnderscore($str) {
|
||||||
|
$str[0] = strtolower($str[0]);
|
||||||
|
$func = create_function('$c', 'return "_" . strtolower($c[1]);');
|
||||||
|
return preg_replace_callback('/([A-Z])/', $func, $str);
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user