Conditions | 2 |
Paths | 2 |
Total Lines | 81 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
21 | public function index(Request $request, Packages $assetsmanager) |
||
22 | { |
||
23 | $bundle = $this->getBundle(); |
||
|
|||
24 | $controller = $this->getController(); |
||
25 | $idpassato = $request->get('id'); |
||
26 | |||
27 | if (!$this->getPermessi()->canRead($this->getController())) { |
||
28 | throw new AccessDeniedException('Non si hanno i permessi per visualizzare questo contenuto'); |
||
29 | } |
||
30 | $crudtemplate = $this->getCrudTemplate($bundle, $controller, $this->getThisFunctionName()); |
||
31 | |||
32 | //$entityclassnotation = $this->getEntityClassNotation(); |
||
33 | //$entityclass = $this->getEntityClassName(); |
||
34 | |||
35 | $entityclassnotation = 'App:'.$this->model; |
||
36 | // Variable containing API controller |
||
37 | |||
38 | $modellocolonne = [ |
||
39 | /* |
||
40 | $controller . ".nominativo" => array( |
||
41 | "nometabella" => $controller, |
||
42 | "nomecampo" => "nominativo", |
||
43 | "etichetta" => "Nominativo", |
||
44 | "ordine" => 10, |
||
45 | "larghezza" => 200, |
||
46 | "escluso" => false |
||
47 | ), |
||
48 | $controller . ".datanascita" => array( |
||
49 | "nometabella" => $controller, |
||
50 | "nomecampo" => "datanascita", |
||
51 | "etichetta" => "Data di nascita", |
||
52 | "ordine" => 20, |
||
53 | "larghezza" => 100, |
||
54 | "escluso" => false |
||
55 | ), |
||
56 | |||
57 | */ |
||
58 | ]; |
||
59 | |||
60 | //append automatic computed enum options |
||
61 | $modellocolonne = array_merge($modellocolonne, $this->enumOptions); |
||
62 | |||
63 | //dump($modellocolonne); |
||
64 | //dump($this->enumOptions); |
||
65 | |||
66 | $filtri = []; |
||
67 | $prefiltri = []; |
||
68 | //$entityutils = new EntityUtils($this->get('doctrine')->getManager()); |
||
69 | //$tablenamefromentity = $entityutils->getTableFromEntity($entityclass); |
||
70 | $tablenamefromentity = $controller; |
||
71 | $colonneordinamento = [$tablenamefromentity.'.id' => 'DESC']; |
||
72 | $parametritabella = ['em' => ParametriTabella::setParameter('default'), |
||
73 | 'tablename' => ParametriTabella::setParameter($tablenamefromentity), |
||
74 | 'nomecontroller' => ParametriTabella::setParameter($controller), |
||
75 | 'bundle' => ParametriTabella::setParameter($bundle), |
||
76 | 'entityname' => ParametriTabella::setParameter($entityclassnotation), |
||
77 | 'entityclass' => ParametriTabella::setParameter($this->controllerItem), |
||
78 | 'formclass' => ParametriTabella::setParameter($this->formClass), |
||
79 | 'modellocolonne' => ParametriTabella::setParameter(json_encode($modellocolonne)), |
||
80 | 'permessi' => ParametriTabella::setParameter(json_encode($this->getPermessi()->toJson($controller))), |
||
81 | 'urltabella' => ParametriTabella::setParameter($assetsmanager->getUrl('/').$controller.'/'.'tabella'), |
||
82 | 'baseurl' => ParametriTabella::setParameter($assetsmanager->getUrl('/')), |
||
83 | 'idpassato' => ParametriTabella::setParameter($idpassato), |
||
84 | 'titolotabella' => ParametriTabella::setParameter('Elenco '.$controller), |
||
85 | 'multiselezione' => ParametriTabella::setParameter('0'), |
||
86 | 'editinline' => ParametriTabella::setParameter('0'), |
||
87 | 'paginacorrente' => ParametriTabella::setParameter('1'), |
||
88 | 'paginetotali' => ParametriTabella::setParameter(''), |
||
89 | 'righetotali' => ParametriTabella::setParameter('0'), |
||
90 | 'righeperpagina' => ParametriTabella::setParameter('15'), |
||
91 | 'estraituttirecords' => ParametriTabella::setParameter('0'), |
||
92 | 'colonneordinamento' => ParametriTabella::setParameter(json_encode($colonneordinamento)), |
||
93 | 'filtri' => ParametriTabella::setParameter(json_encode($filtri)), |
||
94 | 'prefiltri' => ParametriTabella::setParameter(json_encode($prefiltri)), |
||
95 | 'traduzionefiltri' => ParametriTabella::setParameter(''), |
||
96 | 'isApi' => ParametriTabella::setParameter('1'), |
||
97 | 'apicontroller' => ParametriTabella::setParameter($this->apiController), |
||
98 | 'apicollection' => ParametriTabella::setParameter($this->collection) |
||
99 | ]; |
||
100 | |||
101 | return $this->render($crudtemplate, ['parametritabella' => $parametritabella]); |
||
102 | } |
||
282 |