1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\Utils\Tabella; |
4
|
|
|
|
5
|
|
|
use Fi\CoreBundle\Utils\Tabella\ParametriTabella; |
6
|
|
|
use Fi\CoreBundle\Utils\Entity\EntityUtils; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @SuppressWarnings(PHPMD.TooManyFields) |
10
|
|
|
*/ |
11
|
|
|
class TabellaBase |
12
|
|
|
{ |
13
|
|
|
protected $parametri; |
14
|
|
|
protected $colonnedatabase; |
15
|
|
|
protected $opzionitabellacore; |
16
|
|
|
protected $configurazionecolonnetabella; |
17
|
|
|
protected $entityname; |
18
|
|
|
protected $tablename; |
19
|
|
|
protected $modellocolonne; |
20
|
|
|
protected $paginacorrente; |
21
|
|
|
protected $righeperpagina; |
22
|
|
|
protected $estraituttirecords; |
23
|
|
|
protected $prefiltri; |
24
|
|
|
protected $filtri; |
25
|
|
|
protected $wheremanuale; |
26
|
|
|
protected $colonneordinamento; |
27
|
|
|
protected $permessi; |
28
|
|
|
protected $records; |
29
|
|
|
protected $paginetotali; |
30
|
|
|
protected $righetotali; |
31
|
|
|
protected $traduzionefiltri; |
32
|
|
|
protected $em; |
33
|
|
|
protected $user; |
34
|
|
|
|
35
|
12 |
|
public function __construct($doctrine, $parametri = '{}') |
36
|
|
|
{ |
37
|
12 |
|
$this->parametri = $parametri; |
38
|
12 |
|
if (isset($this->parametri['em'])) { |
39
|
12 |
|
$this->em = $doctrine->getManager(ParametriTabella::getParameter($this->parametri['em'])); |
40
|
|
|
} else { |
41
|
|
|
$this->em = $doctrine->getManager(); |
42
|
|
|
} |
43
|
|
|
|
44
|
12 |
|
$this->tablename = $this->getTabellaParameter("tablename"); |
|
|
|
|
45
|
12 |
|
$this->entityname = $this->getTabellaParameter("entityclass"); |
|
|
|
|
46
|
12 |
|
$this->entityname = str_replace("FiCoreBundle", "CoreBundle", $this->entityname); |
|
|
|
|
47
|
12 |
|
$this->permessi = json_decode($this->getTabellaParameter("permessi")); |
|
|
|
|
48
|
12 |
|
$this->modellocolonne = json_decode($this->getTabellaParameter('modellocolonne', array()), true); |
|
|
|
|
49
|
12 |
|
$this->paginacorrente = $this->getTabellaParameter("paginacorrente"); |
|
|
|
|
50
|
12 |
|
$this->paginetotali = $this->getTabellaParameter("paginetotali"); |
|
|
|
|
51
|
12 |
|
$this->righeperpagina = $this->getTabellaParameter('righeperpagina', 15); |
52
|
|
|
|
53
|
12 |
|
$this->estraituttirecords = $this->getTabellaParameter('estraituttirecords', 0) === "1" ? true : false; |
|
|
|
|
54
|
12 |
|
$this->colonneordinamento = json_decode($this->getTabellaParameter('colonneordinamento', array()), true); |
55
|
12 |
|
$this->prefiltri = json_decode($this->getTabellaParameter('prefiltri', array()), true); |
|
|
|
|
56
|
12 |
|
$this->filtri = json_decode($this->getTabellaParameter('filtri', array()), true); |
|
|
|
|
57
|
12 |
|
$this->wheremanuale = $this->getTabellaParameter("wheremanuale", null); |
|
|
|
|
58
|
12 |
|
$this->user = $this->parametri["user"]; |
|
|
|
|
59
|
|
|
|
60
|
12 |
|
$utils = new EntityUtils($this->em, $this->entityname); |
|
|
|
|
61
|
12 |
|
$this->colonnedatabase = $utils->getEntityColumns($this->entityname); |
|
|
|
|
62
|
12 |
|
$this->opzionitabellacore = $this->getOpzionitabellaFromCore(); |
|
|
|
|
63
|
12 |
|
$this->configurazionecolonnetabella = $this->getAllOpzioniTabella(); |
|
|
|
|
64
|
12 |
|
} |
65
|
12 |
|
private function getTabellaParameter($name, $default = null) |
66
|
|
|
{ |
67
|
12 |
|
$risposta = null; |
68
|
12 |
|
if (isset($this->parametri[$name])) { |
69
|
12 |
|
$risposta = ParametriTabella::getParameter($this->parametri[$name]); |
70
|
|
|
} else { |
71
|
12 |
|
$risposta = $default; |
72
|
|
|
} |
73
|
12 |
|
return $risposta; |
74
|
|
|
} |
75
|
12 |
|
public function getPaginacorrente() |
76
|
|
|
{ |
77
|
12 |
|
return $this->paginacorrente; |
78
|
|
|
} |
79
|
7 |
|
public function getPaginetotali() |
80
|
|
|
{ |
81
|
7 |
|
return $this->paginetotali; |
82
|
|
|
} |
83
|
12 |
|
public function getRigheperpagina() |
84
|
|
|
{ |
85
|
12 |
|
return $this->righeperpagina; |
86
|
|
|
} |
87
|
12 |
|
public function getRighetotali() |
88
|
|
|
{ |
89
|
12 |
|
return $this->righetotali; |
90
|
|
|
} |
91
|
7 |
|
public function getTraduzionefiltri() |
92
|
|
|
{ |
93
|
7 |
|
return $this->traduzionefiltri; |
94
|
|
|
} |
95
|
10 |
|
public function getConfigurazionecolonnetabella() |
96
|
|
|
{ |
97
|
10 |
|
return $this->configurazionecolonnetabella; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.