Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * this class provides the methods for begin application
- *
- * @author Leonardo Poletto
- * @version 1.0
- * @category Application
- */
- class Application {
- /*
- * The construct method is marked as private, not to be built
- */
- private function __construct() {}
- /*
- * This Method Uses all methods this class
- */
- public static function Run($classDefault, $settings)
- {
- Loader::Start();
- try{
- Db_Transaction::open($settings);
- $actions = $_GET;
- $controller = isset ($actions['controller']) && $actions['controller'] != null ? ucfirst($actions['controller']) : $classDefault;
- $action = isset ($actions['action']) && $actions['action'] != null ? $actions['action'] : 'index';
- $controllerClassString = $controller.'Controller';
- if( !isset($_SESSION['cadastroRevenda']['user']) && $controllerClassString != 'LoginController'){
- header('location:index.php?controller=login');
- }
- if(!class_exists($controllerClassString))
- throw new Exception('404');
- $controllerClass = new $controllerClassString;
- if(!method_exists($controllerClass, $action.'Action'))
- throw new Exception('404');
- call_user_func(array($controllerClass, $action.'Action'));
- $controllerClass->view->render( $controller, $action);
- Db_Transaction::close();
- }catch(Exception $exe){
- $controllerError = new ErrorController($exe->getMessage());
- $controllerError->indexAction();
- $controllerError->view->render('error' , 'index');
- Db_Transaction::rollback();
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment