/** * Initializes the Request object */ public static function start() { // Parse GET variables if (count($_GET) == 0) { parse_str(self::query(), self::$get); } else { self::$get = $_GET; } // Parse POST variables if (count($_POST) == 0) { //assuming its json $input = file_get_contents('php://input'); $data = json_decode($input, true); self::$post = $data === null ? $input == '' ? [] : $input : $data; } else { self::$post = $_POST; } // Parse DATA $data = Session::get('xt-data', false); if ($data !== false) { self::$data = json_decode($data, true); Session::remove('xt-data'); } }
/** * @param xTend\Objects\Route|string $route * @param array $data * @param boolean $inc_url */ public static function navigate($request, $data = [], $inc_url = true) { //set temp data and time to live Session::set('xt-data', json_encode($data)); $host = self::url(); die($host); if (is_string($request)) { header('Location: ' . ($inc_url ? $host . '/' : '') . $request); } elseif ($request instanceof Route && is_string($request->handle())) { header('Location: ' . $host . '/' . $request->handle()); } }