Completed
Pull Request — master (#2)
by Kate
03:11
created

SiteController::showRentAction()   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 2
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')->findBy(array('exclusive' => true));
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_rent/{slug}", name="show_rent")
56
     */
57
    public function showRentAction(Request $request, $slug)
58
    {
59
        $em = $this->getDoctrine()->getManager();
60
        $estates = $em->getRepository('AppBundle\Entity\Estate')->getEstateForRent($slug);
61
        dump($estates);
62
        return new Response('ok');
63
    }
64
65
    /**
66
     * @Route("/show_estate/{slug}", name="show_estate")
67
     * @ParamConverter("estate", options={"mapping": {"slug": "slug"}})
68
     */
69
    public function showEstateAction(Request $request, Estate $estate)
70
    {
71
        return $this->render('AppBundle:site:show_estate.html.twig', array('estate' => $estate));
72
    }
73
74
    /**
75
     * @Route("/slideshow", name="slideshow")
76
     */
77
    public function gallerySlideAction(Request $request)
78
    {
79
        $em = $this->getDoctrine()->getManager();
80
        $estate = $em->getRepository('AppBundle:Estate')->findOneBy(array('id' => 1));
81
        return $this->render("AppBundle::slideshow.html.twig", array('estate' => $estate));
82
    }
83
}