/** * Instantiates the ACL * @param \Lyra\Interfaces\Container $container */ public function __construct(\Lyra\Interfaces\Container &$container) { $this->container = $container; \Profiler::setTime('ACL::constructor'); // is the player logged in? $sessionModel = \App::getModel('Session'); \Profiler::setTime('ACL::_construct SessionModel loaded'); $playerModel = \App::getModel('Player'); \Profiler::setTime('ACL::_construct playerModel loaded'); if ($sessionModel->isLoggedIn()) { $this->setPlayer($playerModel->find($sessionModel->getPlayerId())); \Profiler::setTime('ACL::_construct setPlayer to Loggedin'); } else { $this->setPlayer($playerModel->findGuest()); \Profiler::setTime('ACL::_construct setPlayer as Guest'); } // lookup in cache for roles if (\Config::get('cache.use') === true && isset($container['cache']['acl_player_' . $this->player['player_id'] . '_roles'])) { $roles = \Cache::get('acl_player_' . $this->player['player_id'] . '_roles'); \Profiler::setTime('ACL::_construct CacheUse is true, set roles'); } else { $roles = \App::getModel('PlayerRole')->findAllForPlayer($this->player['player_id']); \Profiler::setTime('ACL::_construct CacheUse is false, set roles'); if (\Config::get('cache.use') === true) { $container['cache']['acl_player_' . $this->player['player_id'] . '_roles'] = $roles; } } $this->addRoles($roles); \Profiler::setTime('ACL::_construct addRoles'); $container['acl'] = $this; }
public function __construct(\Lyra\Interfaces\Container $container) { $this->container = $container; $container['view'] = $this; $this->data = array(); $this->registerHelpers(); $this->loadData(); $this->modPath = 'modules/'; $this->themePath = 'themes/'; //Always set by default $this->theme = \Config::get('site.theme'); //Load from Config $this->adminTheme = \Config::get('site.adminTheme'); }
/** * Serve the page * @return App */ public function serve() { \View::initTwigEnv(); \View::set('config', $this->getConfig()); if (!defined('INSTALL')) { $menus = $this->getModel('Menu'); \View::set('menu', $menus->getMenu()); $player = \App::getModel('session'); \View::set('loggedIn', $player->isLoggedIn()); \Acl::setPlayer($player); $role = \Acl::getRoles(); if (!empty($role)) { \View::set('playerRole', $role[0]->metadata['role_id']); } } if ($this->adminTheme) { \View::setTheme(\Config::get('site.adminTheme')); } if ($this->view->template == '') { \View::setTemplate($this->module . '.twig'); } echo \View::render(); return $this; }