jsOMS response fixes and formatting

This commit is contained in:
Dennis Eichhorn 2016-05-03 20:52:00 +02:00
parent 02e5185e74
commit 292ac8d739
3 changed files with 14 additions and 14 deletions

View File

@ -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.');

View File

@ -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;
}
}