1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Fi\CoreBundle\DependencyInjection\GrigliaUtils; |
6
|
|
|
|
7
|
|
|
class GrigliaParametriUtils |
8
|
|
|
{ |
9
|
|
|
|
10
|
13 |
|
public static function getAliasTestataPerGriglia($paricevuti) |
11
|
|
|
{ |
12
|
13 |
|
$alias = isset($paricevuti['dettaglij']) ? $paricevuti['dettaglij'] : array(); |
13
|
|
|
|
14
|
13 |
|
if (is_object($alias)) { |
15
|
|
|
$alias = get_object_vars($alias); |
16
|
|
|
} |
17
|
|
|
|
18
|
13 |
|
return $alias; |
19
|
|
|
} |
20
|
|
|
|
21
|
13 |
|
public static function getOrdineColonneTestataPerGriglia($paricevuti) |
22
|
|
|
{ |
23
|
13 |
|
$ordinecolonne = isset($paricevuti['ordinecolonne']) ? $paricevuti['ordinecolonne'] : null; |
24
|
13 |
|
if (!isset($ordinecolonne)) { |
25
|
13 |
|
$ordinecolonne = GrigliaUtils::ordinecolonne($paricevuti); |
26
|
13 |
|
} |
27
|
|
|
|
28
|
13 |
|
return $ordinecolonne; |
29
|
|
|
} |
30
|
|
|
|
31
|
13 |
|
public static function getCampiEsclusiTestataPerGriglia($paricevuti) |
32
|
|
|
{ |
33
|
13 |
|
return isset($paricevuti['escludere']) ? $paricevuti['escludere'] : null; |
34
|
|
|
} |
35
|
|
|
|
36
|
13 |
|
public static function getParametriCampiExtraTestataPerGriglia($paricevuti) |
37
|
|
|
{ |
38
|
13 |
|
return isset($paricevuti['campiextra']) ? $paricevuti['campiextra'] : null; |
39
|
|
|
} |
40
|
|
|
|
41
|
13 |
|
public static function getDoctrineByEm($parametri) |
42
|
|
|
{ |
43
|
13 |
|
if (isset($parametri['em'])) { |
44
|
|
|
$doctrine = $parametri['container']->get('doctrine')->getManager($parametri['em']); |
45
|
|
|
} else { |
46
|
13 |
|
$doctrine = $parametri['container']->get('doctrine')->getManager(); |
47
|
|
|
} |
48
|
|
|
|
49
|
13 |
|
return $doctrine; |
50
|
|
|
} |
51
|
|
|
|
52
|
13 |
|
public static function getDoctrineFiCoreByEm($parametri, $doctrine) |
53
|
|
|
{ |
54
|
13 |
|
if (isset($parametri['emficore'])) { |
55
|
|
|
$doctrineficore = $parametri['container']->get('doctrine')->getManager($parametri['emficore']); |
56
|
|
|
} else { |
57
|
13 |
|
$doctrineficore = &$doctrine; |
58
|
|
|
} |
59
|
|
|
|
60
|
13 |
|
return $doctrineficore; |
61
|
|
|
} |
62
|
|
|
|
63
|
13 |
|
public static function getOuputType($parametri) |
64
|
|
|
{ |
65
|
13 |
|
if ((isset($parametri['output'])) && ($parametri['output'] == 'stampa')) { |
66
|
|
|
$output = 'stampa'; |
67
|
|
|
} else { |
68
|
13 |
|
$output = 'index'; |
69
|
|
|
} |
70
|
|
|
|
71
|
13 |
|
return $output; |
72
|
|
|
} |
73
|
|
|
|
74
|
1 |
|
public static function getDatiEscludereDaTabella($parametri) |
75
|
|
|
{ |
76
|
1 |
|
if (!isset($parametri["nometabella"])) { |
77
|
|
|
return false; |
78
|
|
|
} |
79
|
|
|
|
80
|
1 |
|
if ((isset($parametri["output"])) && ($parametri["output"] == "stampa")) { |
81
|
|
|
$output = "stampa"; |
82
|
|
|
} else { |
83
|
1 |
|
$output = "index"; |
84
|
|
|
} |
85
|
|
|
|
86
|
1 |
|
$nometabella = $parametri["nometabella"]; |
87
|
|
|
|
88
|
1 |
|
$container = $parametri['container']; |
89
|
1 |
|
$doctrine = $container->get('doctrine'); |
90
|
|
|
|
91
|
|
|
//$bundle = $parametri["nomebundle"]; |
|
|
|
|
92
|
|
|
//Fisso il CoreBundle perchè si passa sempre da questo bundle per le esclusioni |
93
|
1 |
|
$bundle = "FiCoreBundle"; |
94
|
1 |
|
$gestionepermessi = $container->get("ficorebundle.gestionepermessi"); |
95
|
1 |
|
$operatorecorrente = $gestionepermessi->utentecorrente(); |
96
|
|
|
|
97
|
1 |
|
$escludi = array(); |
98
|
|
|
|
99
|
1 |
|
$q = $doctrine->getRepository($bundle . ":tabelle")->findBy(array("operatori_id" => $operatorecorrente["id"], "nometabella" => $nometabella)); |
100
|
|
|
|
101
|
1 |
|
if (!$q) { |
102
|
1 |
|
unset($q); |
103
|
1 |
|
$q = $doctrine->getRepository($bundle . ":tabelle")->findBy(array("operatori_id" => null, "nometabella" => $nometabella)); |
104
|
1 |
|
} |
105
|
|
|
|
106
|
1 |
|
if ($q) { |
107
|
1 |
|
foreach ($q as $riga) { |
108
|
1 |
|
$escludi[] = GrigliaUtils::getCampiEsclusi($riga, $output); |
109
|
1 |
|
} |
110
|
1 |
|
} |
111
|
|
|
|
112
|
1 |
|
return $escludi; |
113
|
|
|
} |
114
|
|
|
|
115
|
1 |
|
public static function getDatiEscludere($parametri) |
116
|
|
|
{ |
117
|
1 |
|
return isset($parametri['escludere']) ? $parametri['escludere'] : null; |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
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.