getTopics(); $this->view->setVar('pager', $pager); } /** * @Get("/add", name="admin.topic.add") */ public function addAction() { } /** * @Post("/create", name="admin.topic.create") */ public function createAction() { $topicService = new TopicService(); $topic = $topicService->createTopic(); $location = $this->url->get([ 'for' => 'admin.topic.edit', 'id' => $topic->id, ]); $content = [ 'location' => $location, 'msg' => '创建话题成功', ]; return $this->ajaxSuccess($content); } /** * @Get("/{id:[0-9]+}/edit", name="admin.topic.edit") */ public function editAction($id) { $topicService = new TopicService(); $topic = $topicService->getTopic($id); $xmCourses = $topicService->getXmCourses($id); $this->view->setVar('topic', $topic); $this->view->setVar('xm_courses', $xmCourses); } /** * @Post("/{id:[0-9]+}/update", name="admin.topic.update") */ public function updateAction($id) { $topicService = new TopicService(); $topicService->updateTopic($id); $content = ['msg' => '更新话题成功']; return $this->ajaxSuccess($content); } /** * @Post("/{id:[0-9]+}/delete", name="admin.topic.delete") */ public function deleteAction($id) { $topicService = new TopicService(); $topicService->deleteTopic($id); $content = [ 'location' => $this->request->getHTTPReferer(), 'msg' => '删除话题成功', ]; return $this->ajaxSuccess($content); } /** * @Post("/{id:[0-9]+}/restore", name="admin.topic.restore") */ public function restoreAction($id) { $topicService = new TopicService(); $topicService->restoreTopic($id); $content = [ 'location' => $this->request->getHTTPReferer(), 'msg' => '还原话题成功', ]; return $this->ajaxSuccess($content); } }