/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { $id = $this->input->get('id'); $return = $this->input->get('return'); $return = $return ? base64_decode($return) : Router::build('admin:dashboard'); $user = User::get(); $blogModel = new BlogModel(); $blogModel['user.isAdmin'] = false; $blog = $blogModel->getCurrentBlog($user->id, $id); $session = Ioc::getSession(); if (!$blog->isNull()) { $session->set('current.blog', $blog->id); } $this->setRedirect($return); return true; }
/** * getBlog * * @return Data */ public static function get() { if (static::$blog) { return static::$blog; } $session = Ioc::getSession(); $blogId = $session->get('current.blog'); $blogModel = new BlogModel(); $user = User::get(); if ($user->isNull()) { throw new \RuntimeException('No user'); } $blog = $blogModel->getCurrentBlog($user->id, $blogId); $blog->params = json_decode($blog->params); $session->set('current.blog', $blog->id); return static::$blog = $blog; }