/** * doExecute * * @return bool|string * * @throws \Exception */ protected function doExecute() { $view = new PostHtmlView($this->data); $model = new PostModel(); $id = $this->input->get('id'); $alias = $this->input->getString('alias'); $type = $this->input->get('type'); $view['type'] = $type; $view['post'] = $post = $model->getItem($id); $view['postAuthor'] = Author::getPostAuthor($post->author); $view['avatar'] = Author::getAvatar($view['postAuthor']->id, 200); if ($post->isNull()) { throw new \Exception('Post not found', 404); } if ($post->blog != $view['blog']->id) { throw new \Exception('Post not found', 404); } if (urldecode($alias) != $view['post']->alias) { $get = $this->input->get; $get->set('_rawRoute', null); $queries = $this->input->get->getArray(); $queries['alias'] = $view['post']->alias; $this->app->redirect(Router::buildHttp('front:post_default', $queries), true); return false; } return $view->render(); }
/** * prepareData * * @param \Windwalker\Data\Data $data * * @return void */ protected function prepareData($data) { $data['avatar'] = Author::getAvatar($data['item']->id ?: -1, 650); }