/** * Initialise the library * * @return void */ public function __construct() { // Ensure configuration has been defined if (!Config::value('authentication')) { throw new \Exception('You must define configuration for the authentication library.'); } // Set configuration $this->config = (object) array_merge(array('user_table' => 'user', 'username_field' => 'username', 'password_field' => 'password', 'password_cost' => 16, 'session_name' => 'jv_authentication'), (array) clone Config::value('authentication')); // Ensure a secret key has been set if (!isset($this->config->secret_key)) { throw new \Exception('You must define a secret key.'); } // Start the users session @session_start(); }
/** * Initialise the library * * @return void */ public function __construct($view) { // Set view $this->view = $view; // Set configuration $config = Config::value('template'); $this->config = $config ? clone $config : false; // Ensure there is a valid views directory if (!isset($this->config->views_directory)) { throw new \Exception('You must define a view path.'); } $this->config->views_directory = realpath($this->config->views_directory); if (!$this->config->views_directory) { throw new \Exception('The view path must be valid.'); } // Ensure the view exists if (!file_exists($this->view_path())) { throw new \Exception('The view must exist.'); } }