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."); } }
function createDatabase() { $db = new \PDO(App::getConfig()["dsn"], App::getConfig()["dbUser"], App::getConfig()["dbPass"]); $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $db; }
function __construct() { parent::__construct(); $this->db = App::getContainer()->get('database'); }
function __construct() { $this->latte = App::getContainer()->get("latte"); }
function __construct() { parent::__construct(); $this->authService = App::getContainer()->get('auth'); }
public function __construct() { parent::__construct(); $this->postsRepo = App::getContainer()->get("postsRepository"); $this->ratingService = App::getContainer()->get("rating"); }
function __construct() { $this->db = App::getContainer()->get('database'); $this->user = App::getContainer()->get('user'); }
function __construct() { parent::__construct(); $this->postsRepo = App::getContainer()->get("postsRepository"); }