Base application
[infodrom.org/touren.infodrom.org] / core / response.class.php
diff --git a/core/response.class.php b/core/response.class.php
new file mode 100644 (file)
index 0000000..cf36ffb
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+class Response
+{
+    protected $_code;
+    protected $_type;
+    protected $_data;
+    protected $_location;
+
+    public function __construct()
+    {
+       $this->_code = 200;
+       $this->_type = 'text/html';
+       $this->_data = [];
+    }
+
+    public function setCode($code)
+    {
+       $this->_code = $code;
+    }
+
+    public function getCode()
+    {
+       return $this->_code;
+    }
+
+    public function setType($type)
+    {
+       $this->_type = $type;
+    }
+
+    public function getType()
+    {
+       return $this->_type;
+    }
+
+    public function setData($data)
+    {
+       $this->_data = $data;
+    }
+
+    public function getData()
+    {
+       return $this->_data;
+    }
+
+    public function setError($text)
+    {
+       if ($this->_type != 'application/json')
+           throw new Exception('Kein Backend Call');
+
+       $this->setData(['status' => false, 'error' => $text]);
+    }
+
+    public function setLocation($url)
+    {
+       $this->_location = $url;
+    }
+
+    public function getLocation()
+    {
+       return $this->_location;
+    }
+}
\ No newline at end of file