/** * @Route("/detail/id/{id}",defaults={"id":1},requirements={"id"="\d+"}) * @ParamConverter("article",class="TarsierHomeBundle:article") * @Method("GET") * @Template() */ public function detailAction(article $article) { $data['article'] = $article; if ($this->getRequest()->cookies->get('userName') == null && $article->getStatus() != 1) { return $this->redirect($this->generateUrl('indexPage')); } $tagsArr = []; foreach ($article->getTag() as $tag) { $tagsArr[] = $tag->getName(); } if (empty($tagsArr)) { $tagsArr[] = 'detail'; } $c = new Common(); $current_month = $c->getCurrentMonth(); $em = $this->getDoctrine()->getManager(); $tags = $this->getTags($em); $hot_article = $em->getRepository("TarsierHomeBundle:article")->getHotArticle(); $nav_tags = array_intersect($tagsArr, $this->nav_arr); $data['current_month'] = $current_month; $data['tagsArr'] = $tagsArr; //面包屑导航 $data['tags'] = $tags; //标签云 $data['sid'] = md5($article->getTitle() . 'http://huajie1988.net/detail/id/' . $article->getId()); $data['nav_tags'] = current($nav_tags); //导航栏 $data['hot_article'] = $hot_article; //导航栏 $data['friendlink'] = $this->getFriendLink(); $data['is_mobile'] = $this->isMobile(); $em = $this->getDoctrine()->getManager(); $article->setClick($article->getClick() + 1); $em->persist($article); $em->flush(); return $data; }