function runController($route) { global $twig; list($controller, $params, $permission) = routeResolve($route); if (is_null($controller)) { throw new Exception("Error: Route not found"); } list($controllerClassName, $actionID) = explode(':', $controller); $main = new $controllerClassName($actionID, $twig, $params); }
function runController($route) { global $twig; list($controller, $params, $permission) = routeResolve($route); if (is_null($controller)) { throw new Exception("Error: Route not found - " . $route); } list($controllerClassName, $actionID) = explode(':', $controller); if (is_authorized()) { $main = new $controllerClassName($actionID, $twig, $params); } else { if ($actionID == 'registration' or $actionID == 'setRegistration') { $main = new mainController($actionID, $twig, $params); } elseif ($actionID == 'getPrices') { $main = new mainController($actionID, $twig, $params); } else { if (is_authorized() === false and $route != '/' and $route != '/login/') { header("Location: /"); exit; } $main = new mainController('login', $twig, $params); } } }