protected function __construct() { $this->config = Hayate_Config::load('session'); $driver = isset($this->config->session->driver) ? $this->config->session->driver : 'native'; switch ($driver) { case 'database': // can we get a db connection ? if (null === Hayate_Database::getInstance()) { throw new Hayate_Exception(sprintf(_('%s cannot use "database" driver as it is unable' . ' to retrieve a valid database connection.'), __CLASS__)); } $ses = Hayate_Session_Database::getInstance(); session_set_save_handler(array($ses, 'open'), array($ses, 'close'), array($ses, 'read'), array($ses, 'write'), array($ses, 'destroy'), array($ses, 'gc')); break; case 'native': break; default: throw new Hayate_Exception(sprintf(_('Session driver: "%s" not supported.'), $driver)); } // @see http://php.net/manual/en/function.session-write-close.php Hayate_Event::add('hayate.shutdown', 'session_write_close'); ini_set('session.use_only_cookies', true); ini_set('session.use_trans_sid', 0); session_name($this->config->get('session.name', 'HayateSession')); // session will not work with a domain without top level $domain = $this->config->get('session.domain', $_SERVER['SERVER_NAME']); if (preg_match('/^\\.?.+\\.[a-z]{2,4}$/i', $domain) != 1) { $domain = ''; } session_set_cookie_params((int) $this->config->get('session.lifetime', 0), $this->config->get('session.path', '/'), $domain, $this->config->get('session.secure', false), $this->config->get('session.httponly', false)); session_start(); Hayate_Log::info(sprintf(_('%s initialized.'), __CLASS__)); }
public function __construct() { parent::__construct(); if (true === $this->auto_render) { $this->template = new Hayate_View($this->template); Hayate_Event::add('hayate.render', array($this, '_render')); } }
public function __construct() { $this->request = Hayate_Request::getInstance(); $this->input = Hayate_Input::getInstance(); Hayate_Event::add('hayate.post_dispatch', array($this, '_postDispatch')); }
/** * display templates */ public function render() { Hayate_Event::add('hayate.render', array($this, '_render')); }
public function run() { //$mem = ((memory_get_peak_usage(true) / 1024) / 1024) . 'Mb'; //var_dump($mem); static $run; // there will be only one if (true === $run) { return; } $request = Hayate_Request::getInstance(); $dispatcher = Hayate_Dispatcher::getInstance(); Hayate_Event::run('hayate.pre_dispatch', array($dispatcher)); do { $request->dispatched(true); $dispatcher->dispatch(); if ($request->dispatched()) { Hayate_Event::run('hayate.post_dispatch', array($dispatcher, $request)); } } while (false === $request->dispatched()); Hayate_Event::run('hayate.send_headers'); Hayate_Event::run('hayate.render'); $run = true; Hayate_Event::run('hayate.shutdown'); //$mem = ((memory_get_peak_usage(true) / 1024) / 1024) . 'Mb'; //var_dump($mem); }
public function exceptionDispatch(Exception $ex) { try { if (Hayate_Event::run('hayate.exception', array($this, $ex))) { return; } // try to dispatch to the current module error.php controller $module = $this->module(); $filepath = $this->modulesPath . $module . '/controllers/error.php'; // if the error controller does not exists in the current module // look in the default module if (!is_file($filepath)) { $module = Hayate_Config::getInstance()->get('default_module', 'default'); $filepath = $this->modulesPath . $module . '/controllers/error.php'; } if (is_file($filepath)) { require_once $filepath; $classname = ucfirst($module) . '_ErrorController'; $rfc = new ReflectionClass($classname); if ($rfc->isSubclassOf('Hayate_Controller') && $rfc->isInstantiable()) { $controller = $rfc->newInstance(); $action = $rfc->hasMethod('index') ? $rfc->getMethod('index') : $rfc->getMethod('__call'); if ($action->isPublic()) { $action->invokeArgs($controller, array($ex)); } } } else { $display_errors = Hayate_Config::getInstance()->get('display_errors', false); if ($display_errors && $this->errorReporter) { Hayate_Event::remove('hayate.send_headers'); Hayate_Event::remove('hayate.render'); $this->errorReporter->setException($ex); echo $this->errorReporter->report(); } } } catch (Exception $ex) { } }