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

SiteController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 13
Bugs 0 Features 8
Metric Value
wmc 5
c 13
b 0
f 8
lcom 1
cbo 1
dl 0
loc 56
ccs 0
cts 31
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 6 1
A menuAction() 0 7 1
A showCategoryAction() 0 7 1
A showEstateAction() 0 8 1
A gallerySlideAction() 0 6 1
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
}