public function output()
 {
     $this->view->output();
 }
Exemple #2
0
}, E_ALL ^ E_NOTICE);
require ROOT . 'Settings.php';
$controller = 'Main';
$action = 'Main';
if (!empty($_GET['page'])) {
    $controller = trim($_GET['page']);
}
if (!empty($_GET['action'])) {
    $action = trim($_GET['action']);
}
$controllerClass = '\\ImageTool\\Controller\\' . $controller . 'Controller';
$actionMethod = 'action' . $action;
if (!preg_match('#[a-zA-Z]{1,20}#', $controller) || !class_exists($controllerClass) || !preg_match('#[a-zA-Z]{1,20}#', $action)) {
    Log::get()->debug('Controller does not exist: ' . $controllerClass . '->' . $actionMethod);
    ViewManager::errorPage('Page not found.', ViewManager::CODE_NOT_FOUND);
    exit;
}
$controllerObject = new $controllerClass($settings);
if (!method_exists($controllerObject, $actionMethod)) {
    Log::get()->debug('Action does not exist: ' . $controllerClass . '->' . $actionMethod);
    ViewManager::errorPage('Page not found.', ViewManager::CODE_NOT_FOUND);
    exit;
}
$controllerObject->{$actionMethod}();
try {
    $controllerObject->output();
} catch (\ImageTool\ViewException $e) {
    Log::get()->error('Failed to create view.', $e);
    ViewManager::errorPage('Page not found.', ViewManager::CODE_NOT_FOUND);
    exit;
}