Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / examples / restful / remote / lib / response.php
diff --git a/examples/restful/remote/lib/response.php b/examples/restful/remote/lib/response.php
new file mode 100644 (file)
index 0000000..1225282
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+/**
+ * @class Response
+ * A simple JSON Response class.
+ */
+class Response {
+    public $success, $data, $message, $errors, $tid, $trace;
+
+    public function __construct($params = array()) {
+        $this->success  = isset($params["success"]) ? $params["success"] : false;
+        $this->message  = isset($params["message"]) ? $params["message"] : '';
+        $this->data     = isset($params["data"])    ? $params["data"]    : array();
+    }
+
+    public function to_json() {
+        return json_encode(array(
+            'success'   => $this->success,
+            'message'   => $this->message,
+            'data'      => $this->data
+        ));
+    }
+}