public function newsAction(News $news, $prefix = "", $link = false, $more = false) { return $this->render("ADHNewsBundle:Block:news.html.twig", array("news" => $news, "id" => $prefix . "news-block-" . $news->getId(), "link" => $link, "more" => $more, "category_field" => $this->createForm(new FilterNewsType())->createView()->offsetGet("category")->vars["full_name"])); }
/** * page de changement d'état d'une News * * @Security("has_role('ROLE_ADMIN')") * @Route("/state/{news}", name="adh_news_etat") * @Method({"GET","POST"}) * * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function stateAction(Request $request, News $news) { if (!($news->getEtat() == 0 && $news->getAuteur() != $this->getUser())) { $form = $this->createForm(new EtatNewsType($this->getUser()), $news); if ($request->isMethod("POST")) { $form->handleRequest($request); if ($form->isValid()) { switch ($news->getEtat()) { case 4: break; case 3: $news->setPublicationdate(new \DateTime()); default: $news->setMotifRefus(null); break; } $this->getDoctrine()->getManager()->flush(); $this->addFlash("success", "L'état de la news a bien été mis à jour."); return $this->redirect($this->generateUrl("adh_news_default")); } } return $this->render("ADHNewsBundle:News:etat.html.twig", array("form" => $form->createView(), "news" => $news)); } $this->addFlash("danger", "Cette news n'est pas encore prête a être publiée."); return $this->redirect($this->generateUrl("adh_news_default")); }