mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-20 21:38:41 +00:00
jsOMS response fixes and formatting
This commit is contained in:
parent
02e5185e74
commit
292ac8d739
|
|
@ -115,14 +115,15 @@ class Dispatcher
|
|||
*/
|
||||
private function dispatchString(string $controller, RequestAbstract $request, ResponseAbstract $response, $data = null) : array
|
||||
{
|
||||
$views =[];
|
||||
$views = [];
|
||||
$dispatch = explode(':', $controller);
|
||||
$this->getController($dispatch[0]);
|
||||
|
||||
if (($c = count($dispatch)) == 3) {
|
||||
if (($c = count($dispatch)) === 3) {
|
||||
/* Handling static functions */
|
||||
$views[$controller] = $dispatch[0]::$dispatch[2]();
|
||||
} elseif ($c == 2) {
|
||||
$function = $dispatch[0] . '::' . $dispatch[2];
|
||||
$views[$controller] = $function($request, $response, $data);
|
||||
} elseif ($c === 2) {
|
||||
$views[$controller] = $this->controllers[$dispatch[0]]->{$dispatch[1]}($request, $response, $data);
|
||||
} else {
|
||||
throw new \UnexpectedValueException('Unexpected function.');
|
||||
|
|
@ -215,7 +216,7 @@ class Dispatcher
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ class Request extends RequestAbstract
|
|||
private function initCurrentRequest()
|
||||
{
|
||||
$this->data = $_GET ?? [];
|
||||
$this->files = $_FILES ?? [];
|
||||
|
||||
if (isset($_SERVER['CONTENT_TYPE'])) {
|
||||
if (strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
|
||||
|
|
@ -155,8 +156,6 @@ class Request extends RequestAbstract
|
|||
} elseif (strpos($_SERVER['CONTENT_TYPE'], 'application/x-www-form-urlencoded') !== false) {
|
||||
parse_str(file_get_contents('php://input'), $temp);
|
||||
$this->data += $temp;
|
||||
} elseif (strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false) {
|
||||
$this->files = $_FILES;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class Router
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function importFromFile(string $path)
|
||||
public function importFromFile(string $path)
|
||||
{
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$this->routes += include $path;
|
||||
|
|
@ -69,8 +69,8 @@ class Router
|
|||
* Add route.
|
||||
*
|
||||
* @param string $route Route regex
|
||||
* @param mixed $destination Destination e.g. Module:function & verb
|
||||
* @param string $verb Request verb
|
||||
* @param mixed $destination Destination e.g. Module:function & verb
|
||||
* @param string $verb Request verb
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -80,7 +80,7 @@ class Router
|
|||
public function add(string $route, $destination, string $verb = RouteVerb::GET)
|
||||
{
|
||||
$this->routes[$route][] = [
|
||||
'dest' => $destination,
|
||||
'dest' => $destination,
|
||||
'verb' => $verb,
|
||||
];
|
||||
}
|
||||
|
|
@ -112,9 +112,9 @@ class Router
|
|||
/**
|
||||
* Match route and uri.
|
||||
*
|
||||
* @param string $route Route
|
||||
* @param string $routeVerb GET,POST for this route
|
||||
* @param string $uri Uri
|
||||
* @param string $route Route
|
||||
* @param string $routeVerb GET,POST for this route
|
||||
* @param string $uri Uri
|
||||
* @param string $remoteVerb Verb this request is using
|
||||
*
|
||||
* @return bool
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user