Passed
Push — master ( a137f9...d5d520 )
by Stepan
04:26
created

DefaultController::shareContactsAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 18
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
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) {
0 ignored issues
show
introduced by
$staticPage is of type object, thus it always evaluated to true.
Loading history...
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