From 1435b8e007c1ccf148c1da1aed443edc225d752d Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 20 Sep 2016 14:54:45 +0200 Subject: [PATCH] school shit --- utility.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utility.php b/utility.php index c225e4d..b83f19d 100644 --- a/utility.php +++ b/utility.php @@ -3,6 +3,8 @@ * A set of utility helper functions */ +use Phroute\Phroute\Exception\HttpMethodNotAllowedException; +use Phroute\Phroute\Exception\HttpRouteNotFoundException; use Sakura\Config; use Sakura\Exceptions\ConfigValueNotFoundException; use Sakura\Net; @@ -52,6 +54,20 @@ function view($name, $vars = []) return Template::render($name); } +// Abort response +function abort($status = 200) +{ + http_response_code($status); + + switch ($status) { + case 403: + throw new HttpMethodNotAllowedException; + + case 404: + throw new HttpRouteNotFoundException; + } +} + function clean_string($string, $lower = false, $noSpecial = false, $replaceSpecial = '') { // Run common sanitisation function over string