1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\Bundle\DefaultBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class DefaultController. |
11
|
|
|
*/ |
12
|
|
|
class DefaultController extends Controller |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @Route("/", name="homepage", options = {"expose"=true}) |
16
|
|
|
* |
17
|
|
|
* @return Response |
18
|
|
|
*/ |
19
|
|
|
public function indexAction() |
20
|
|
|
{ |
21
|
|
|
$events = $this->getDoctrine() |
22
|
|
|
->getRepository('StfalconEventBundle:Event') |
23
|
|
|
->findBy(['active' => true], ['date' => 'ASC']); |
24
|
|
|
|
25
|
|
|
return $this->render('ApplicationDefaultBundle:Default:index.html.twig', ['events' => $events]); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @Route("/page/{slug}", name="page") |
30
|
|
|
* |
31
|
|
|
* @param string $slug |
32
|
|
|
* |
33
|
|
|
* @return Response |
34
|
|
|
*/ |
35
|
|
|
public function pageAction($slug) |
36
|
|
|
{ |
37
|
|
|
$staticPage = $this->getDoctrine()->getRepository('StfalconEventBundle:Page') |
38
|
|
|
->findOneBy(['slug' => $slug]); |
39
|
|
|
if (!$staticPage) { |
|
|
|
|
40
|
|
|
throw $this->createNotFoundException(sprintf('Page not found! %s', $slug)); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return $this->render('@ApplicationDefault/Page/index.html.twig', ['text' => $staticPage->getText()]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @todo wtf? |
48
|
|
|
* @return Response |
49
|
|
|
*/ |
50
|
|
|
public function renderMicrolayoutAction() |
51
|
|
|
{ |
52
|
|
|
$events = $this->getDoctrine() |
53
|
|
|
->getRepository('StfalconEventBundle:Event') |
54
|
|
|
->findClosesActiveEvents(3); |
55
|
|
|
|
56
|
|
|
return $this->render('ApplicationDefaultBundle::microlayout.html.twig', ['events' => $events]); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|