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