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')); }