Passed
Push — master ( 046444...56e09b )
by Andrea
28:16 queued 22:41
created

MenuapplicazioneController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Test Coverage

Coverage 98.28%

Importance

Changes 0
Metric Value
eloc 60
c 0
b 0
f 0
dl 0
loc 80
ccs 57
cts 58
cp 0.9828
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B index() 0 74 3
1
<?php
2
3
namespace Cdf\BiCoreBundle\Controller;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\Asset\Packages;
7
use Cdf\BiCoreBundle\Utils\Entity\EntityUtils;
8
use Cdf\BiCoreBundle\Utils\Tabella\ParametriTabella;
9
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
10
11
/**
12
 * Menuapplicazione controller.
13
 */
14
class MenuapplicazioneController extends FiController
15
{
16
17
    /**
18
     * Lists all tables entities.
19
     */
20 1
    public function index(Request $request, Packages $assetsmanager)
21
    {
22 1
        $bundle = $this->getBundle();
23 1
        $controller = $this->getController();
24 1
        $idpassato = $request->get('id');
25
26 1
        if (!$this->getPermessi()->canRead($this->getController())) {
27
            throw new AccessDeniedException('Non si hanno i permessi per visualizzare questo contenuto');
28
        }
29 1
        $crudtemplate = $this->getCrudTemplate($bundle, $controller, $this->getThisFunctionName());
30
31 1
        $entityclassnotation = $this->getEntityClassNotation();
32 1
        $entityclass = $this->getEntityClassName();
33
34 1
        $formclass = str_replace('Entity', 'Form', $entityclass);
35
36 1
        $em = $this->getDoctrine()->getManager();
37 1
        $query = $em->createQueryBuilder()
0 ignored issues
show
Bug introduced by
The method createQueryBuilder() does not exist on Doctrine\Persistence\ObjectManager. It seems like you code against a sub-type of said class. However, the method does not exist in Doctrine\Persistence\ObjectManagerDecorator. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        $query = $em->/** @scrutinizer ignore-call */ createQueryBuilder()
Loading history...
38 1
                ->select('o')
39 1
                ->from('BiCoreBundle:Menuapplicazione', 'o')
40 1
                ->getQuery()
41
        ;
42 1
        $menuobj = $query->getResult();
43 1
        $menus = [];
44 1
        foreach ($menuobj as $menu) {
45 1
            $menus[$menu->getId()] = $menu->getNome();
46
        }
47
48
        $modellocolonne = array(
49 1
            array('nometabella' => $controller,
50 1
                'nomecampo' => "__bicorebundle_Menuapplicazione.id",
51 1
                'etichetta' => 'Id',
52 1
                'ordine' => 0,
53 1
                'larghezza' => 10,
54
                'escluso' => true),
55 1
            array('nometabella' => $controller, 'nomecampo' =>
56 1
                "__bicorebundle_Menuapplicazione.padre", 'etichetta' => 'Padre',
57 1
                'ordine' => 10, 'larghezza' => 10, 'escluso' => false,
58 1
                'decodifiche' => $menus,
59
            ),
60
        );
61
62 1
        $filtri = [];
63 1
        $prefiltri = [];
64 1
        $entityutils = new EntityUtils($this->get('doctrine')->getManager());
65 1
        $tablenamefromentity = $entityutils->getTableFromEntity($entityclass);
66 1
        $colonneordinamento = [$tablenamefromentity . '.id' => 'DESC'];
67 1
        $parametritabella = ['em' => ParametriTabella::setParameter('default'),
68 1
            'tablename' => ParametriTabella::setParameter($tablenamefromentity),
69 1
            'nomecontroller' => ParametriTabella::setParameter($controller),
70 1
            'bundle' => ParametriTabella::setParameter($bundle),
71 1
            'entityname' => ParametriTabella::setParameter($entityclassnotation),
72 1
            'entityclass' => ParametriTabella::setParameter($entityclass),
73 1
            'formclass' => ParametriTabella::setParameter($formclass),
74 1
            'modellocolonne' => ParametriTabella::setParameter(json_encode($modellocolonne)),
75 1
            'permessi' => ParametriTabella::setParameter(json_encode($this->getPermessi()->toJson($controller))),
76 1
            'urltabella' => ParametriTabella::setParameter($assetsmanager->getUrl('') . $controller . '/' . 'tabella'),
77 1
            'baseurl' => ParametriTabella::setParameter($assetsmanager->getUrl('')),
78 1
            'idpassato' => ParametriTabella::setParameter($idpassato),
79 1
            'titolotabella' => ParametriTabella::setParameter('Elenco ' . $controller),
80 1
            'multiselezione' => ParametriTabella::setParameter('0'),
81 1
            'editinline' => ParametriTabella::setParameter('0'),
82 1
            'paginacorrente' => ParametriTabella::setParameter('1'),
83 1
            'paginetotali' => ParametriTabella::setParameter(''),
84 1
            'righetotali' => ParametriTabella::setParameter('0'),
85 1
            'righeperpagina' => ParametriTabella::setParameter('15'),
86 1
            'estraituttirecords' => ParametriTabella::setParameter('0'),
87 1
            'colonneordinamento' => ParametriTabella::setParameter(json_encode($colonneordinamento)),
88 1
            'filtri' => ParametriTabella::setParameter(json_encode($filtri)),
89 1
            'prefiltri' => ParametriTabella::setParameter(json_encode($prefiltri)),
90 1
            'traduzionefiltri' => ParametriTabella::setParameter(''),
91
        ];
92
93 1
        return $this->render($crudtemplate, ['parametritabella' => $parametritabella]);
94
    }
95
}
96