Completed
Push — master ( 166881...6b19b1 )
by Andrea
09:19
created

PermessiController::indexAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 50
ccs 21
cts 21
cp 1
rs 9.3333
c 0
b 0
f 0
cc 1
eloc 37
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Fi\CoreBundle\Controller;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Fi\CoreBundle\Entity\Permessi;
7
8
/**
9
 * Permessi controller.
10
 */
11
class PermessiController extends FiCoreController
12
{
13
14
    /**
15
     * Lists all Ffprincipale entities.
16
     */
17 1
    public function indexAction(Request $request)
18
    {
19 1
        $this->setup($request);
20 1
        $namespace = $this->getNamespace();
21 1
        $bundle = $this->getBundle();
22 1
        $controller = $this->getController();
23 1
        $container = $this->container;
24
25 1
        $nomebundle = $namespace . $bundle . 'Bundle';
26
27 1
        $em = $this->getDoctrine()->getManager();
28 1
        $entities = $em->getRepository($nomebundle . ':' . $controller)->findAll();
29
30
        $dettaglij = array(
31 1
            'operatori_id' => array(
32
                array('nomecampo' => 'operatori.username',
33
                    'lunghezza' => '200',
34
                    'descrizione' => 'Username',
35
                    'tipo' => 'text',),
36
                array('nomecampo' => 'operatori.operatore',
37
                    'lunghezza' => '200',
38
                    'descrizione' => 'Operatore',
39
                    'tipo' => 'text',),
40
            ),
41
            'ruoli_id' => array(
42
                array('nomecampo' => 'ruoli.ruolo',
43
                    'lunghezza' => '200',
44
                    'descrizione' => 'Ruolo',
45
                    'tipo' => 'text',),
46
            ),
47
        );
48
49
        $paricevuti = array(
50 1
            'doctrine' => $em,
51 1
            'nomebundle' => $nomebundle,
52 1
            'nometabella' => $controller,
53 1
            'dettaglij' => $dettaglij,
54 1
            'container' => $container,);
55
56 1
        $testatagriglia = Griglia::testataPerGriglia($paricevuti);
57
58 1
        $testata = json_encode($testatagriglia);
59
        $twigparms = array(
60 1
            'entities' => $entities,
61 1
            'nomecontroller' => $controller,
62 1
            'testata' => $testata,
63
        );
64
65 1
        return $this->render($nomebundle . ':' . $controller . ':index.html.twig', $twigparms);
66
    }
67
68
    public function setParametriGriglia($prepar = array())
69
    {
70
        $this->setup($prepar['request']);
71
        $namespace = $this->getNamespace();
72
        $bundle = $this->getBundle();
73
        $controller = $this->getController();
74
75
        $nomebundle = $namespace . $bundle . 'Bundle';
76
        $escludi = array();
77
        $tabellej['operatori_id'] = array('tabella' => 'operatori', 'campi' => array('username', 'operatore'));
0 ignored issues
show
Coding Style Comprehensibility introduced by
$tabellej was never initialized. Although not strictly required by PHP, it is generally a good practice to add $tabellej = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
78
        $tabellej['ruoli_id'] = array('tabella' => 'ruoli', 'campi' => array('ruolo'));
79
80
        $paricevuti = array(
81
            'container' => $this->container,
82
            'nomebundle' => $nomebundle,
83
            'tabellej' => $tabellej,
84
            'nometabella' => $controller,
85
            'escludere' => $escludi,
86
        );
87
88
        if (! empty($prepar)) {
89
            $paricevuti = array_merge($paricevuti, $prepar);
90
        }
91
92
        self::$parametrigriglia = $paricevuti;
93
    }
94
}
95