forked from cystbear/ForumBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCategoryController.php
More file actions
59 lines (45 loc) · 2.12 KB
/
Copy pathCategoryController.php
File metadata and controls
59 lines (45 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Herzult\Bundle\ForumBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class CategoryController extends Controller
{
public function listAction()
{
$categories = $this->get('herzult_forum.repository.category')->findAll();
$template = sprintf('%s:list.html.%s', $this->container->getParameter('herzult_forum.templating.location.category'), $this->getRenderer());
return $this->get('templating')->renderResponse($template, array('categories' => $categories));
}
public function showAction($slug)
{
$category = $this->get('herzult_forum.repository.category')->findOneBySlug($slug);
if (!$category) {
throw new NotFoundHttpException(sprintf('The category %s does not exist.', $slug));
}
$template = sprintf('%s:show.%s.%s', $this->container->getParameter('herzult_forum.templating.location.category'), $this->get('request')->getRequestFormat(), $this->getRenderer());
return $this->get('templating')->renderResponse($template, array(
'category' => $category,
'page' => $this->get('request')->query->get('page', 1)
));
}
public function topicNewAction($slug)
{
$category = $this->get('herzult_forum.repository.category')->findOneBySlug($slug);
if (!$category) {
throw new NotFoundHttpException(sprintf('The category "%s" does not exist.', $slug));
}
return $this->forward('HerzultForumBundle:Topic:new', array('category' => $category));
}
public function topicCreateAction($slug)
{
$category = $this->get('herzult_forum.repository.category')->findOneBySlug($slug);
if (!$category) {
throw new NotFoundHttpException(sprintf('The category "%s" does not exist.', $slug));
}
return $this->forward('HerzultForumBundle:Topic:create', array('category' => $category));
}
protected function getRenderer()
{
return $this->container->getParameter('herzult_forum.templating.engine');
}
}