diff options
| author | Kevin J Hoerr <kjhoerr@submelon.tech> | 2018-08-26 01:38:28 -0400 |
|---|---|---|
| committer | Kevin Hoerr <kjhoerr@submelon.tech> | 2018-08-31 23:24:45 -0400 |
| commit | 0965d62be00a7820f97284704dc71f37e661b412 (patch) | |
| tree | 5a5c9d69062e24aa926eb30447c5ff27e0a65492 /private/Controller/Controller.php | |
| parent | 1e3946f04b5b602d3869a285d897acb0ba2b3c35 (diff) | |
| download | august-offensive-0965d62be00a7820f97284704dc71f37e661b412.tar.gz august-offensive-0965d62be00a7820f97284704dc71f37e661b412.tar.bz2 august-offensive-0965d62be00a7820f97284704dc71f37e661b412.zip | |
Begin migration to Rust; Add actix-web, diesel as main dependencies
Diffstat (limited to 'private/Controller/Controller.php')
| -rw-r--r-- | private/Controller/Controller.php | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/private/Controller/Controller.php b/private/Controller/Controller.php deleted file mode 100644 index 586be15..0000000 --- a/private/Controller/Controller.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace AugustOffensive\Controller; - -use AugustOffensive\Model; - -/** - * Static controller class for interfacing between the view and the model. - */ -class Controller -{ - /** - * Initiates connection with the database. - * - * While errors are ideally handled by the controller, this instantiation - * will likely throw a \PDOException which should be handled by the front- - * end due to this being a fatal error and generally unrecoverable. - * - * @return Model\Connection - */ - public static function initiateConnection (): Model\Connection - { - return new Model\Connection(); - } - - /** - * Creates and returns a Query object. - * - * If the creation results in an error, a different query object is - * returned with the error message. - * - * @param array $path The array that holds the original request structure. - * @param string $request The request method made to the server. - * @param array $content The content object sent by the request. - * - * @return Model\Query - */ - public static function createQuery ( - array $path, - string $request, - array $content - ): Model\Query { - try { - return new Model\Query($path, $request, $content); - } catch (\Exception $err) { - return new Model\Query(array(), "", array("ERROR" => $err->getMessage())); - } - } - - /** - * Creates and returns a Result object. - * - * @param string $resultType The type of result to send back to the client. - * @param array $result The result object to send back to the client. - * - * @return Model\Result - */ - public static function createResult ( - string $resultType, - array $result - ): Model\Result { - try { - return new Model\Result($resultType, $result); - } catch (\Exception $err) { - return new Model\Result("ERROR", array($err->getMessage())); - } - } - - /** - * Obtain the error result based on the exception that was thrown. - * - * @param \Exception $err the error that was thrown. - * - * @return Model\Result - */ - public static function errorResult (\Exception $err): Model\Result - { - $errorType = ""; - // Juggle error: objective is to sort error type - try { - throw $err; - } catch (\PDOException $e) { - $errorType = "DATABASE_ERROR"; - } catch (\Exception $e) { - $errorType = "ERROR"; - } - - return new Model\Result($errorType, array("error" => $err->getMessage())); - } -} |
