Exemplo n.º 1
0
 function run($class, $method)
 {
     $controllerName = App::getConfig()['controllerNamespace'] . "\\" . $class . "Controller";
     $actionMethodName = $method . "Action";
     if (class_exists($controllerName)) {
         $controller = new $controllerName();
         if (!$controller instanceof Controller) {
             throw new ApplicationException("Class {$controller} does not extends Controller");
         }
         $viewName = App::getConfig()["viewsNamespace"] . "\\" . $class . "View";
         if (class_exists($viewName)) {
             $view = new $viewName();
             if (!$view instanceof View) {
                 throw new ApplicationException("Class {$view} does not implements IView");
             }
             $controller->setView($view);
             if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                 if (method_exists($view, $actionMethodName)) {
                     $view->{$actionMethodName}();
                 } else {
                     throw new ApplicationException("Method {$actionMethodName} does not exists.");
                 }
             } else {
                 if (method_exists($controller, $actionMethodName)) {
                     $controller->{$actionMethodName}();
                 } else {
                     throw new ApplicationException("Method {$actionMethodName} does not exists.");
                 }
             }
         } else {
             throw new ApplicationException("Class {$controllerName} does not exists.");
         }
     } else {
         throw new ApplicationException("Class {$controllerName} does not exists.");
     }
 }
Exemplo n.º 2
0
 function createDatabase()
 {
     $db = new \PDO(App::getConfig()["dsn"], App::getConfig()["dbUser"], App::getConfig()["dbPass"]);
     $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     return $db;
 }
Exemplo n.º 3
0
 function __construct()
 {
     parent::__construct();
     $this->db = App::getContainer()->get('database');
 }
Exemplo n.º 4
0
 function __construct()
 {
     $this->latte = App::getContainer()->get("latte");
 }
Exemplo n.º 5
0
 function __construct()
 {
     parent::__construct();
     $this->authService = App::getContainer()->get('auth');
 }
Exemplo n.º 6
0
 public function __construct()
 {
     parent::__construct();
     $this->postsRepo = App::getContainer()->get("postsRepository");
     $this->ratingService = App::getContainer()->get("rating");
 }
Exemplo n.º 7
0
 function __construct()
 {
     $this->db = App::getContainer()->get('database');
     $this->user = App::getContainer()->get('user');
 }
Exemplo n.º 8
0
 function __construct()
 {
     parent::__construct();
     $this->postsRepo = App::getContainer()->get("postsRepository");
 }