From 6813b883156e847e6523b9942d0842b1908ef8c5 Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Thu, 30 Aug 2012 11:13:05 +0200 Subject: [PATCH] Fixed ForumController's hierarchical ParamConverter problem Signed-off-by: Gergely Polonkai --- .../FrontBundle/Controller/ForumController.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/KekRozsak/FrontBundle/Controller/ForumController.php b/src/KekRozsak/FrontBundle/Controller/ForumController.php index c62ef61..12ae011 100644 --- a/src/KekRozsak/FrontBundle/Controller/ForumController.php +++ b/src/KekRozsak/FrontBundle/Controller/ForumController.php @@ -116,11 +116,19 @@ class ForumController extends Controller * * @Route("/{topicGroupSlug}/{topicSlug}/", name="KekRozsakFrontBundle_forumPostList") * @Template() - * @ParamConverter("topic", options={"mapping"={"topicGroup"="topicGroup", "topicSlug"="slug"}}) - * @ParamConverter("topicGroup", options={"mapping"={"topicGroupSlug"="slug"}}) */ - public function postListAction(ForumTopicGroup $topicGroup, ForumTopic $topic) + public function postListAction($topicGroupSlug, $topicSlug) { + $topicGroupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup'); + if (null === $topicGroup = $topicGroupRepo->findOneBySlug($topicGroupSlug)) { + throw $this->createNotFoundException('Ilyen témakör nem létezik!'); + } + + $topicRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopic'); + if (null === $topic = $topicRepo->findOneBy(array('slug' => $topicSlug, 'topicGroup' => $topicGroup))) { + throw $this->createNotFoundException('Ilyen téma nem létezik!'); + } + // Get the list of posts in the requested topic $postRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumPost'); $posts = $postRepo->findBy(