|
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
|
|
|
} |