public function __construct() { $this->benchmark =& getBenchmarkInstance(); $this->output =& getOutputInstance(); $this->benchmark->mark("controller_construct"); $this->db = new Db(); }
public function init() { $benchmark =& getBenchmarkInstance(); $benchmark->mark("application_start"); $output =& getOutputInstance(); $url = isset($_GET['url']) ? $_GET['url'] : ''; $this->getRouter()->setUrl($url); $controller = $this->getRouter()->getController(); $action = $this->getRouter()->getAction(); $parameters = $this->getRouter()->getParameters(); // Verifico que este autorizado if (is_null($this->getSecurity()) || $this->getSecurity()->isAuthorized($controller, $action, $parameters)) { // Verifico cache if ($this->getCache()->exists($controller, $action, $parameters)) { $time = $this->getCache()->getExpiration($controller, $action, $parameters); $fileName = $this->getCache()->getFilename($controller, $action, $parameters); if ($output->displayFromCache($fileName, $time)) { // Imprimo desde cache y salgo exit; } } $benchmark->mark("controller_start c:{$controller} a:{$action}"); $this->getRouter()->dispatch(); $benchmark->mark("controller_end"); $benchmark->mark("controller_end"); $benchmark->mark("application_end"); if ($output->hasContent()) { $output->display(); } } else { $url = $this->getSecurity()->getAccessDeniedUrl(); if (!is_null($url)) { header('Location: ' . $url); } else { header("HTTP/1.1 401 Unauthorized"); } exit; } }