/** * * @param string $method * @param array $arguments * @throws \RuntimeException * @return mixed */ public function __call(string $method, array $arguments) { $methods = $this->viewHelper->getMethods(); $class = $methods[$method] ?? null; if (is_null($class)) { throw new \RuntimeException("Method '{$method}' does not exists"); } else { $instance = $this->registry->register($class); return call_user_func_array([$instance, $method], $arguments); } }
/** * Method checks if admin panel route is open and then valid permission to * stay there. If user is admin (or moderator) method loads necessary extensions */ public function loadAdmin() { if ($this->http->isAdmin()) { // If not logged open login panel if (!$this->user->isUserLoggedIn()) { $this->view->loadFile('../../admin/extensions/Index/login.html'); exit; } // Check permissions if ($this->user->getUserSession()->getRole() != 'admin') { Server::headerLocation(); // Go to main page } // Admin view helper classes $this->viewHelper->add($this->conf['adminViewHelper'] ?? []); $this->registry->set('App\\Admin\\Admin', new Admin($this->adminExtension, $this->yaml)); } }