Created API for API requests
This commit is contained in:
24
Core/RouterApi.php
Normal file
24
Core/RouterApi.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Core;
|
||||
|
||||
use App\Controllers\Api;
|
||||
|
||||
class RouterApi extends Router
|
||||
{
|
||||
public function dispatchApi($url)
|
||||
{
|
||||
$object = new Api();
|
||||
if (isset($this->params['action'])) {
|
||||
$action = $this->params['action'];
|
||||
return $object->$action();
|
||||
} else {
|
||||
$method = $_SERVER['REQUEST_METHOD'];
|
||||
$model = $this->params['model'];
|
||||
|
||||
return (isset($this->params['id'])) ?
|
||||
$object->$method($model, $this->params['id'])
|
||||
:
|
||||
$object->$method($model);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user