Esempio n. 1
0
 public function __construct($config, $session)
 {
     $this->config = $config;
     $this->session = $session;
     $this->storage = $this->session->get(self::SESSION_NAME, []);
     if (!isset($this->storage['status'], $this->storage['created_at'], $this->storage['updated_at'], $this->storage['expire'])) {
         $this->storage = [];
     } elseif (-1 != $this->storage['expire'] && APP_TIME - $this->storage['created_at'] > $this->storage['expire']) {
         $this->storage['status'] = false;
     } elseif (APP_TIME - $this->storage['updated_at'] > $this->update) {
         $this->storage['updated_at'] = APP_TIME;
     }
     $this->expire = $this->config->get('auth.expire', ['general' => 7200, 'remember' => 3600 * 24 * 10]);
     $this->model = $this->config->get('auth.model', Swilab::getBaseNamespace() . 'Models\\Users');
     $this->session->set(self::SESSION_NAME, $this->storage);
 }
Esempio n. 2
0
 protected function registerView()
 {
     $view = new View();
     if (!is_dir($viewDir = $this->paths['modules'] . $this->module->getName() . '/Views')) {
         throw new Exception("The modules view directory does not exist.");
     }
     $view->setViewsDir($viewDir);
     $view->registerEngines([(string) $this->config->get('app.view.suffix') => function ($view, $di) {
         $volt = new Volt($view, $di);
         $volt->setOptions(['compiledPath' => $this->paths['storage'] . 'views/', 'compiledExtension' => ".compiled", 'compileAlways' => !$this->config->get('app.view.compile')]);
         return $volt;
     }]);
     return $view;
 }