Upgraded to Symfony 2.1-beta2
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace KekRozsak\FrontBundle\Controller;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
|
||||
use KekRozsak\FrontBundle\Entity\ForumPost;
|
||||
use KekRozsak\FrontBundle\Form\Type\ForumPostType;
|
||||
@@ -16,40 +17,42 @@ class ForumController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("", name="KekRozsakFrontBundle_forum_main")
|
||||
* @Template("KekRozsakFrontBundle:Forum:topic_group_list.html.twig")
|
||||
*/
|
||||
public function mainAction()
|
||||
{
|
||||
// TODO: Protect this controller with roles? It is also defined in security.yml
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
|
||||
|
||||
// TODO: ORDER the topic list by last post date
|
||||
$topicGroups = $groupRepo->findAll();
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Forum:topic_group_list.html.twig', array(
|
||||
return array(
|
||||
'topicGroups' => $topicGroups,
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{topicGroupSlug}", name="KekRozsakFrontBundle_forum_topic_list")
|
||||
* @Template("KekRozsakFrontBundle:Forum:topic_list.html.twig")
|
||||
*/
|
||||
public function topicListAction($topicGroupSlug)
|
||||
{
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
|
||||
|
||||
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
|
||||
throw $this->createNotFoundException('A kért témakör nem létezik!');
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Forum:topic_list.html.twig', array(
|
||||
return array(
|
||||
'topicGroup' => $topicGroup,
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{topicGroupSlug}/{topicSlug}", name="KekRozsakFrontBundle_forum_post_list")
|
||||
* @Template("KekRozsakFrontBundle:Forum:post_list.html.twig")
|
||||
*/
|
||||
public function postListAction($topicGroupSlug, $topicSlug)
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
// Get the topic group based on slug
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
|
||||
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
|
||||
@@ -68,6 +71,7 @@ class ForumController extends Controller
|
||||
$post = new ForumPost();
|
||||
$form = $this->createForm(new ForumPostType($topicGroup->getId(), $topic->getId()), $post);
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
$form->bindRequest($request);
|
||||
@@ -89,12 +93,11 @@ class ForumController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Forum:post_list.html.twig', array(
|
||||
return array(
|
||||
'topicGroup' => $topicGroup,
|
||||
'topic' => $topic,
|
||||
'posts' => $posts,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user