Example #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.");
     }
 }
Example #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;
 }
Example #3
0
 function __construct()
 {
     parent::__construct();
     $this->db = App::getContainer()->get('database');
 }
Example #4
0
 function __construct()
 {
     $this->latte = App::getContainer()->get("latte");
 }
Example #5
0
 function __construct()
 {
     parent::__construct();
     $this->authService = App::getContainer()->get('auth');
 }
Example #6
0
 public function __construct()
 {
     parent::__construct();
     $this->postsRepo = App::getContainer()->get("postsRepository");
     $this->ratingService = App::getContainer()->get("rating");
 }
Example #7
0
 function __construct()
 {
     $this->db = App::getContainer()->get('database');
     $this->user = App::getContainer()->get('user');
 }
Example #8
0
 function __construct()
 {
     parent::__construct();
     $this->postsRepo = App::getContainer()->get("postsRepository");
 }