1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\Request; |
6
|
|
|
use Symfony\Component\HttpFoundation\Response; |
7
|
|
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
8
|
|
|
|
9
|
|
|
class FiController extends FiCrudController |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
public static $namespace; |
13
|
|
|
public static $bundle; |
14
|
|
|
public static $controller; |
15
|
|
|
public static $action; |
16
|
|
|
public static $parametrigriglia; |
17
|
|
|
|
18
|
4 |
|
protected function setup(Request $request) |
19
|
|
|
{ |
20
|
4 |
|
$matches = array(); |
21
|
4 |
|
$controllo = new \ReflectionClass(get_class($this)); |
22
|
|
|
|
23
|
4 |
|
preg_match('/(.*)\\\(.*)Bundle\\\Controller\\\(.*)Controller/', $controllo->name, $matches); |
24
|
|
|
|
25
|
4 |
|
self::$namespace = $matches[1]; |
26
|
4 |
|
self::$bundle = $matches[2]; |
27
|
4 |
|
self::$controller = $matches[3]; |
28
|
4 |
|
self::$action = substr($request->attributes->get('_controller'), strrpos($request->attributes->get('_controller'), ':') + 1); |
29
|
4 |
|
} |
30
|
|
|
|
31
|
1 |
|
protected function setParametriGriglia($prepar = array()) |
32
|
|
|
{ |
33
|
1 |
|
$this->setup($prepar['request']); |
34
|
1 |
|
$namespace = $this->getNamespace(); |
35
|
1 |
|
$bundle = $this->getBundle(); |
36
|
1 |
|
$controller = $this->getController(); |
37
|
|
|
|
38
|
1 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
39
|
1 |
|
$canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0); |
40
|
1 |
|
if (!$canRead) { |
41
|
|
|
throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto"); |
42
|
|
|
} |
43
|
|
|
|
44
|
1 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
45
|
1 |
|
$escludi = array(); |
46
|
|
|
|
47
|
1 |
|
$paricevuti = array('container' => $this->container, 'nomebundle' => $nomebundle, 'nometabella' => $controller, 'escludere' => $escludi); |
48
|
|
|
|
49
|
1 |
|
if (! empty($prepar)) { |
50
|
1 |
|
$paricevuti = array_merge($paricevuti, $prepar); |
51
|
|
|
} |
52
|
|
|
|
53
|
1 |
|
self::$parametrigriglia = $paricevuti; |
54
|
1 |
|
} |
55
|
|
|
|
56
|
1 |
|
public function grigliaAction(Request $request) |
57
|
|
|
{ |
58
|
1 |
|
$this->setParametriGriglia(array('request' => $request)); |
59
|
1 |
|
$paricevuti = self::$parametrigriglia; |
60
|
|
|
|
61
|
1 |
|
return new Response(Griglia::datiPerGriglia($paricevuti)); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
protected function elencoModifiche($nomebundle, $controller, $id) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$controllerStorico = 'Storicomodifiche'; |
67
|
|
|
$em = $this->getDoctrine()->getManager(); |
68
|
|
|
$risultato = $em->getRepository('FiCoreBundle:' . $controllerStorico)->findBy( |
69
|
|
|
array( |
70
|
|
|
'nometabella' => $controller, |
71
|
|
|
'idtabella' => $id, |
72
|
|
|
) |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
return $risultato; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
protected function getParametersTestataPerGriglia($request, $container, $em, $paricevuti) |
79
|
|
|
{ |
80
|
|
|
$parametritestarequest = $request->get('parametritesta'); |
81
|
|
|
$parametritesta = array(); |
82
|
|
|
if ($parametritestarequest) { |
83
|
|
|
$jsonparms = json_decode($parametritestarequest); |
84
|
|
|
$parametritesta = get_object_vars($jsonparms); |
85
|
|
|
$parametritesta['container'] = $container; |
86
|
|
|
$parametritesta['doctrine'] = $em; |
87
|
|
|
$parametritesta['request'] = $request; |
88
|
|
|
$parametritesta['output'] = 'stampa'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $parametritestarequest ? $parametritesta : $paricevuti; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
protected function getParametersDatiPerGriglia($request, $container, $em, $paricevuti) |
95
|
|
|
{ |
96
|
|
|
$parametrigriglia = $request->get('parametrigriglia'); |
97
|
|
|
if ($parametrigriglia) { |
98
|
|
|
$jsonparms = json_decode($parametrigriglia); |
99
|
|
|
$parametrigriglia = get_object_vars($jsonparms); |
100
|
|
|
$parametrigriglia['container'] = $container; |
101
|
|
|
$parametrigriglia['doctrine'] = $em; |
102
|
|
|
$parametrigriglia['request'] = $request; |
103
|
|
|
$parametrigriglia['output'] = 'stampa'; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
return $parametrigriglia ? $parametrigriglia : $paricevuti; |
107
|
|
|
} |
108
|
|
|
|
109
|
4 |
|
protected function getNamespace() |
110
|
|
|
{ |
111
|
4 |
|
return self::$namespace; |
112
|
|
|
} |
113
|
|
|
|
114
|
4 |
|
protected function getBundle() |
115
|
|
|
{ |
116
|
4 |
|
return self::$bundle; |
117
|
|
|
} |
118
|
|
|
|
119
|
4 |
|
protected function getController() |
120
|
|
|
{ |
121
|
4 |
|
return self::$controller; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
protected function getAction() |
125
|
|
|
{ |
126
|
|
|
return self::$action; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.