|
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\MenuItem\RecursiveMenuItemIterator; |
|
13
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
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
|
|
|
use AppBundle\Entity\Cat as CategoryEntity; |
|
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
|
|
|
// dump($estates); |
|
|
|
|
|
|
30
|
|
|
// return new Response('ok'); |
|
31
|
|
|
return $this->render("AppBundle::site/index.html.twig", array('estates' => $estates)); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @Route("/menu", name="menu") |
|
36
|
|
|
*/ |
|
37
|
|
|
public function menuAction(Request $request) |
|
38
|
|
|
{ |
|
39
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
40
|
|
|
$categoryEntity = $em->getRepository('AppBundle\Entity\Category'); |
|
41
|
|
|
$categories = $categoryEntity->childrenHierarchy(); |
|
42
|
|
|
return $this->render("AppBundle::includes/menu.html.twig", ['links' => $categories]); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @Route("/tree", name="tree") |
|
47
|
|
|
*/ |
|
48
|
|
|
public function treeAction(Request $request) |
|
49
|
|
|
{ |
|
50
|
|
|
$em = $this->getDoctrine()->getManager(); |
|
51
|
|
|
$repo = $em->getRepository('AppBundle\Entity\Category'); |
|
52
|
|
|
$query = $em |
|
53
|
|
|
->createQueryBuilder() |
|
54
|
|
|
->select('node') |
|
55
|
|
|
->from('AppBundle\Entity\Category', 'node') |
|
56
|
|
|
->orderBy('node.root, node.lft', 'ASC') |
|
57
|
|
|
->where('node.root = 1') |
|
58
|
|
|
->getQuery() |
|
59
|
|
|
; |
|
60
|
|
|
$options = array('decorate' => true); |
|
61
|
|
|
$tree = $repo->buildTree($query->getArrayResult(), $options); |
|
62
|
|
|
return $this->render("AppBundle::tree.html.twig", ['tree' => $tree]); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
} |
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.