View::render($viewTemplate, $viewParameters + ['fullPage' => true]) ]); } catch (StopException $e) { } } public static function execute($uri) { $action = new Actions(); switch($uri) { case '/': return $action->executeHome(); case '/get': return $action->executeGet(); case '/postcommit': return $action->executePostCommit(); default: if (View::exists('page/' . ltrim($uri, '/'))) { return ['page/' . $uri, []]; } else { return ['page/404', []]; } } } public static function redirect($url, $statusCode = 302) { if (empty($url)) { throw new InvalidArgumentException('Cannot redirect to an empty URL.'); } $url = str_replace('&', '&', $url); if ($statusCode == 201 || ($statusCode >= 300 && $statusCode < 400)) { header('Location: ' . $url, true, $statusCode); } else { echo sprintf('
', htmlspecialchars($url, ENT_QUOTES)); } throw new StopException('Time to redirect'); } }