Completed
Push — master ( 2ff726...1b8ace )
by Andrea
09:31
created

FfsecondariaController::setParametriGriglia()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 53
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 36
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 53
ccs 36
cts 36
cp 1
rs 8.9849
c 0
b 0
f 0
cc 4
eloc 34
nc 6
nop 1
crap 4

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 Fi\CoreBundle\Controller;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
7
8
/**
9
 * Ffsecondaria controller.
10
 */
11
class FfsecondariaController extends FiCoreController
12
{
13
14 1
    public function indexAction(Request $request)
15
    {
16
17 1
        $this->setup($request);
18 1
        $namespace = $this->getNamespace();
19 1
        $bundle = $this->getBundle();
20 1
        $controller = $this->getController();
21 1
        $container = $this->container;
22
23 1
        $nomebundle = $namespace . $bundle . 'Bundle';
24
25
        $dettaglij = array(
26
            'descsec' => array(
27 1
                array('nomecampo' => 'descsec',
28 1
                    'lunghezza' => '400',
29 1
                    'descrizione' => 'Descrizione tabella secondaria',
30 1
                    'tipo' => 'text',),),
31
            'ffprincipale_id' => array(
32 1
                array('nomecampo' => 'ffprincipale.descrizione',
33 1
                    'lunghezza' => '400',
34 1
                    'descrizione' => 'Descrizione record principale',
35 1
                    'tipo' => 'text',),
36 1
            ),
37 1
        );
38 1
        $escludi = array('nota');
39
40
        $campiextra = array(
41 1
            array('nomecampo' => 'lunghezzanota', 'descrizione' => 'Lunghezza Nota', 'tipo' => 'integer'),
42 1
            array('nomecampo' => 'attivoToString', 'lunghezza' => '80', 'descrizione' => 'Attivo string', 'tipo' => 'text'),
43 1
        );
44
45
        $paricevuti = array(
46 1
            'nomebundle' => $nomebundle,
47 1
            'nometabella' => $controller,
48 1
            'dettaglij' => $dettaglij,
49 1
            'campiextra' => $campiextra,
50 1
            'escludere' => $escludi,
51 1
            'container' => $container,);
52
53 1
        $testatagriglia = Griglia::testataPerGriglia($paricevuti);
54
55 1
        $testatagriglia['multisearch'] = 1;
56 1
        $testatagriglia['showconfig'] = 1;
57 1
        $testatagriglia['showadd'] = 1;
58 1
        $testatagriglia['showedit'] = 1;
59 1
        $testatagriglia['showdel'] = 1;
60
61 1
        $testatagriglia['showexcel'] = 1;
62 1
        $testatagriglia['showimportexcel'] = 1;
63
64
        //$testatagriglia["filterToolbar_stringResult"] = false;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
65 1
        $testatagriglia["filterToolbar_searchOnEnter"] = true;
66 1
        $testatagriglia["filterToolbar_searchOperators"] = true;
67
        //$testatagriglia["filterToolbar_clearSearch"] = false;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
68
69 1
        $testatagriglia['parametritesta'] = json_encode($paricevuti);
70 1
        $this->setParametriGriglia(array('request' => $request));
71 1
        $testatagriglia['parametrigriglia'] = json_encode(self::$parametrigriglia);
72
73 1
        $gestionepermessi = $this->get("ficorebundle.gestionepermessi");
74 1
        $canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0);
75
76 1
        $testata = json_encode($testatagriglia);
77
        $twigparms = array(
78 1
            'nomecontroller' => $controller,
79 1
            'testata' => $testata,
80 1
            'canread' => $canRead,
81 1
        );
82
83 1
        if (!$canRead) {
84
            throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto");
85
        } else {
86 1
            return $this->render($nomebundle . ':' . $controller . ':index.html.twig', $twigparms);
87
        }
88
    }
89
90 4
    public function setParametriGriglia($prepar = array())
91
    {
92 4
        $this->setup($prepar['request']);
93 4
        $namespace = $this->getNamespace();
94 4
        $bundle = $this->getBundle();
95 4
        $controller = $this->getController();
96
97 4
        $gestionepermessi = $this->get("ficorebundle.gestionepermessi");
98 4
        $canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0);
99 4
        if (!$canRead) {
100 1
            throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto");
101
        }
102
103 3
        $nomebundle = $namespace . $bundle . 'Bundle';
104 3
        $escludi = array('nota', 'ffprincipale');
105 3
        $tabellej = array();
106 3
        $precondizioniAvanzate = array();
107 3
        $tabellej['ffprincipale_id'] = array('tabella' => 'ffprincipale', 'campi' => array('descrizione'));
108
109 3
        $campiextra = array(array('lunghezzanota'), array('attivoToString'));
110
        //$campiextra = array(array("lunghezzanota"));
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% 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...
111
        //$campiextra = array("lunghezzanota");
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
112
113 3
        $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria',
114 3
            'nomecampo' => 'intero',
115 3
            'operatore' => '>=',
116 3
            'valorecampo' => 1,);
117 3
        $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria',
118 3
            'nomecampo' => 'data',
119 3
            'operatore' => '<=',
120 3
            'valorecampo' => date('Y-m-d'),
121 3
            'operatorelogico' => 'AND',);
122
123
        /* $precondizioniAvanzate[] = array('nometabella' => 'Ffsecondaria',
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
124
          'nomecampo' => 'attivo',
125
          'operatore' => '=',
126
          'valorecampo' => true,
127
          'operatorelogico' => 'AND',); */
128
129 3
        $paricevuti = array('container' => $this->container,
130 3
            'nomebundle' => $nomebundle,
131 3
            'tabellej' => $tabellej,
132 3
            'nometabella' => $controller,
133 3
            'campiextra' => $campiextra,
134 3
            'escludere' => $escludi,
135 3
            'precondizioniAvanzate' => $precondizioniAvanzate,);
136
137 3
        if (! empty($prepar)) {
138 3
            $paricevuti = array_merge($paricevuti, $prepar);
139 3
        }
140
141 3
        self::$parametrigriglia = $paricevuti;
142 3
    }
143
}
144