public static function deserialize($object) { $returnValue = new stdClass(); if (isset($object->__class__)) { if (!class_exists($object->__class__)) { require_once realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $object->__class__ . '.php'; } $returnValue = new $object->__class__(); } if (is_array($object)) { foreach ($object as $key => $value) { $returnValue->{$key} = JSONSerializer::deserialize($value); } } elseif (is_object($object)) { foreach (get_class_vars($object) as $key) { $returnValue->{$key} = $object->{$key}; } } else { return $object; } return $returnValue; }
} break; default: if (isset($action_map[$request->action])) { if (is_array($action_map[$request->action])) { if (class_exists($action_map[$request->action][0])) { $class = new $action_map[$request->action][0](); if (method_exists($class, $action_map[$request->action][1])) { $result = call_user_func_array(array($class, $action_map[$request->action][1]), $params); if ($result === false) { $output['error'] = $class->getLastError(); } else { $output['result'] = $result; } } else { $output['error'] = "Method {$action_map[$request->action][1]} does not exist in class {$action_map[$request->action][0]} for action {$action}"; } } else { $output['error'] = "Could not load class {$action_map[$request->action][0]} for action {$request->action}"; } } else { //TODO Deal with global methods later } } else { $output['error'] = "Invalid action ({$request->action}) provided"; } } $output['session_id'] = session_id(); log_message(print_r($output, true)); echo json_encode(JSONSerializer::serialize($output));