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($classPrefix, $classDefault, $settings)
- {
- Loader::Start();
- try{
- Db_Transaction::open($settings);
- $router = new Helpers_Router();
- $router->get('class');
- $class = $router->getParam('class') ? $classPrefix.ucfirst($router->getParam('class')) : $classPrefix.$classDefault;
- $method = $router->getParam('method') ? $router->getParam('method') : 'index';
- //Rota para o Controle de produtos
- if( $class == 'PublicProdutos' ) $method = 'index';
- $class = str_replace("-", "_", $class);
- $method = str_replace("-", "_", $method);
- if(!class_exists($class))
- $class = 'PublicPagina';
- $controller = new $class;
- $controller->onLoad();
- if(!method_exists($controller, $method))
- throw new Exception('404M');
- call_user_func(array($controller, $method));
- Db_Transaction::close();
- }catch(Exception $exe){
- $error = $exe->getTraceAsString();
- $controller = new PublicError($error);
- $controller->index();
- Db_Transaction::rollback();
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment