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

SiteController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 8
Bugs 0 Features 5
Metric Value
wmc 3
c 8
b 0
f 5
lcom 1
cbo 1
dl 0
loc 46
ccs 0
cts 29
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 8 1
A menuAction() 0 7 1
A treeAction() 0 16 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\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);
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...
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
}