Completed
Pull Request — master (#2)
by Kate
04:26
created

SiteController::menuAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: kate
5
 * Date: 17.02.16
6
 * Time: 9:30
7
 */
8
9
namespace AppBundle\Controller;
10
11
12
use AppBundle\Entity\Estate;
13
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
14
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
15
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
19
20
class SiteController extends Controller
21
{
22
    /**
23
     * @Route("/", name="homepage")
24
     */
25
    public function indexAction(Request $request)
26
    {
27
        $em = $this->getDoctrine()->getManager();
28
        $estates = $em->getRepository('AppBundle:Estate')->getEstateExclusiveWithFiles();
29
        return $this->render("AppBundle::site/index.html.twig", array('estates' => $estates));
30
    }
31
32
    /**
33
     * @Route("/menu", name="menu")
34
     */
35
    public function menuAction(Request $request)
36
    {
37
        $em = $this->getDoctrine()->getManager();
38
        $categoryEntity = $em->getRepository('AppBundle\Entity\Category');
39
        $categories = $categoryEntity->childrenHierarchy();
40
        return $this->render("AppBundle::includes/menu.html.twig", ['links' => $categories]);
41
    }
42
43
    /**
44
     * @Route("/show_category/{slug}", name="show_category")
45
     */
46
    public function showCategoryAction(Request $request, $slug)
47
    {
48
        $em = $this->getDoctrine()->getManager();
49
        $estates = $em->getRepository('AppBundle\Entity\Estate')->getEstateFromCategory($slug);
50
51
        return $this->render("AppBundle::site/index.html.twig", array('estates' => $estates));
52
    }
53
54
    /**
55
     * @Route("/show_estate/{slug}", name="show_estate")
56
     */
57
    public function showEstateAction(Request $request, $slug)
58
    {
59
        $em = $this->getDoctrine()->getManager();
60
        $estate = $em->getRepository('AppBundle\Entity\Estate')->getEstateWithDistrictComment($slug);
61
//       dump($estate);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
62
//        return new Response('ok');
63
        return $this->render('AppBundle:site:show_estate.html.twig', array('estate' => $estate[0]));
64
    }
65
66
    /**
67
     * @Route("/slideshow", name="slideshow")
68
     */
69
    public function gallerySlideAction(Request $request)
70
    {
71
        $em = $this->getDoctrine()->getManager();
72
        $estate = $em->getRepository('AppBundle:Estate')->findOneBy(array('id' => 1));
73
        return $this->render("AppBundle::slideshow.html.twig", array('estate' => $estate));
74
    }
75
}