Mithril as main method

This commit is contained in:
2017-10-25 12:08:41 +07:00
parent 6040809710
commit d1d5ee1b0c
157 changed files with 19593 additions and 716 deletions

View File

@@ -2,11 +2,23 @@
namespace Core;
use App\Controllers\Api;
use App\Controllers\Home;
class RouterApi extends Router
{
public function dispatchApi($url)
{
if (isset($_SERVER['HTTP_X_TOKEN']) && Token::validate($_SERVER['HTTP_X_TOKEN']) != true) {
// Logout
$obj = new Home();
$obj->logout();
header('Location: /mithril');
}
// $request = Token::generate(2);
// var_dump($request, Token::validate($request));
// return true;
$object = new Api();
if (isset($this->params['action'])) {
$action = $this->params['action'];
@@ -14,11 +26,10 @@ class RouterApi extends Router
} else {
$method = $_SERVER['REQUEST_METHOD'];
$model = $this->params['model'];
return (isset($this->params['id'])) ?
$object->$method($model, $this->params['id'])
:
$object->$method($model);
}
return (isset($this->params['id'])) ?
$object->$method($model, $this->params['id'])
:
$object->$method($model, "", (Input::exists('get')) ? $_GET : []);
}
}