From 2d796d48df6f4371111bcbc776ea781e4f45c831 Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sat, 8 Jul 2017 11:11:53 -0400 Subject: Expand on query and result, begin sql design --- private/View/Main.php | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 private/View/Main.php (limited to 'private/View') diff --git a/private/View/Main.php b/private/View/Main.php new file mode 100644 index 0000000..1dcd760 --- /dev/null +++ b/private/View/Main.php @@ -0,0 +1,78 @@ +query = Controller\Controller::createQuery( + explode('/', trim($_SERVER['PATH_INFO'] ?? '/api', '/')), + $_SERVER['REQUEST_METHOD'], + $this->generateContent($_SERVER['REQUEST_METHOD']) + ); + + return $this; + } + + /** + * Generates the content of the query based on the request type. + * + * @param string $request The request method on which to base the content. + * + * @return array + */ + public function generateContent (string $request): array + { + $content; + switch ($request) { + case "GET": // GET should always be empty + case "POST": // POST contains moves, account info, etc. + default: + $content = $_REQUEST; + } + return $content; + } + + /** + * Communicates with the controller to generate the JSON result. + * + * @return string + */ + public function generateResult (): string + { + $this->result = Controller\Controller::createResult( + "", + array() + ); + + // generate result + return json_encode(array( + "Result-Type" => $this->result->getResultType(), + "Content" => $this->result->getResult() + )); + } +} -- cgit