Passed
Push — master ( 5f6dc3...b05beb )
by Andrea
19:20 queued 11s
created

MenuapplicazioneController::index()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 73
Code Lines 58

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 56
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 58
nc 3
nop 2
dl 0
loc 73
ccs 56
cts 57
cp 0.9825
crap 3
rs 8.9163
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
        $query = $this->em->createQueryBuilder()
37 1
                ->select('o')
38 1
                ->from('BiCoreBundle:Menuapplicazione', 'o')
39 1
                ->getQuery()
40
        ;
41 1
        $menuobj = $query->getResult();
42 1
        $menus = [];
43 1
        foreach ($menuobj as $menu) {
44 1
            $menus[$menu->getId()] = $menu->getNome();
45
        }
46
47
        $modellocolonne = array(
48 1
            array('nometabella' => $controller,
49 1
                'nomecampo' => "__bicorebundle_Menuapplicazione.id",
50 1
                'etichetta' => 'Id',
51 1
                'ordine' => 0,
52 1
                'larghezza' => 10,
53
                'escluso' => true),
54 1
            array('nometabella' => $controller, 'nomecampo' =>
55 1
                "__bicorebundle_Menuapplicazione.padre", 'etichetta' => 'Padre',
56 1
                'ordine' => 10, 'larghezza' => 10, 'escluso' => false,
57 1
                'decodifiche' => $menus,
58
            ),
59
        );
60
61 1
        $filtri = [];
62 1
        $prefiltri = [];
63 1
        $entityutils = new EntityUtils($this->get('doctrine')->getManager());
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Bundle\Framework...stractController::get() has been deprecated: since Symfony 5.4, use method or constructor injection in your controller instead ( Ignorable by Annotation )

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

63
        $entityutils = new EntityUtils(/** @scrutinizer ignore-deprecated */ $this->get('doctrine')->getManager());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
64 1
        $tablenamefromentity = $entityutils->getTableFromEntity($entityclass);
65 1
        $colonneordinamento = [$tablenamefromentity . '.id' => 'DESC'];
66 1
        $parametritabella = ['em' => ParametriTabella::setParameter('default'),
67 1
            'tablename' => ParametriTabella::setParameter($tablenamefromentity),
68 1
            'nomecontroller' => ParametriTabella::setParameter($controller),
69 1
            'bundle' => ParametriTabella::setParameter($bundle),
70 1
            'entityname' => ParametriTabella::setParameter($entityclassnotation),
71 1
            'entityclass' => ParametriTabella::setParameter($entityclass),
72 1
            'formclass' => ParametriTabella::setParameter($formclass),
73 1
            'modellocolonne' => ParametriTabella::setParameter(json_encode($modellocolonne)),
74 1
            'permessi' => ParametriTabella::setParameter(json_encode($this->getPermessi()->toJson($controller))),
75 1
            'urltabella' => ParametriTabella::setParameter($assetsmanager->getUrl('') . $controller . '/' . 'tabella'),
76 1
            'baseurl' => ParametriTabella::setParameter($assetsmanager->getUrl('')),
77 1
            'idpassato' => ParametriTabella::setParameter($idpassato),
78 1
            'titolotabella' => ParametriTabella::setParameter('Elenco ' . $controller),
79 1
            'multiselezione' => ParametriTabella::setParameter('0'),
80 1
            'editinline' => ParametriTabella::setParameter('0'),
81 1
            'paginacorrente' => ParametriTabella::setParameter('1'),
82 1
            'paginetotali' => ParametriTabella::setParameter(''),
83 1
            'righetotali' => ParametriTabella::setParameter('0'),
84 1
            'righeperpagina' => ParametriTabella::setParameter('15'),
85 1
            'estraituttirecords' => ParametriTabella::setParameter('0'),
86 1
            'colonneordinamento' => ParametriTabella::setParameter(json_encode($colonneordinamento)),
87 1
            'filtri' => ParametriTabella::setParameter(json_encode($filtri)),
88 1
            'prefiltri' => ParametriTabella::setParameter(json_encode($prefiltri)),
89 1
            'traduzionefiltri' => ParametriTabella::setParameter(''),
90
        ];
91
92 1
        return $this->render($crudtemplate, ['parametritabella' => $parametritabella]);
93
    }
94
}
95