1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\Request; |
6
|
|
|
use Fi\CoreBundle\DependencyInjection\GestionePermessi; |
7
|
|
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Ffprincipale controller. |
11
|
|
|
*/ |
12
|
|
|
class FfprincipaleController extends FiCoreController |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Lists all tables entities. |
17
|
|
|
*/ |
18
|
|
|
/* @var $em \Doctrine\ORM\EntityManager */ |
19
|
15 |
|
public function indexAction(Request $request) |
20
|
|
|
{ |
21
|
15 |
|
$this->setup($request); |
22
|
15 |
|
$namespace = $this->getNamespace(); |
|
|
|
|
23
|
15 |
|
$bundle = $this->getBundle(); |
|
|
|
|
24
|
15 |
|
$controller = $this->getController(); |
25
|
15 |
|
$container = $this->container; |
|
|
|
|
26
|
|
|
|
27
|
15 |
|
$gestionepermessi = $this->get("ficorebundle.gestionepermessi"); |
|
|
|
|
28
|
15 |
|
$canRead = ($gestionepermessi->leggere(array('modulo' => $controller)) ? 1 : 0); |
|
|
|
|
29
|
|
|
|
30
|
15 |
|
$nomebundle = $namespace . $bundle . 'Bundle'; |
31
|
|
|
|
32
|
15 |
|
$em = $container->get('doctrine')->getManager(); |
|
|
|
|
33
|
15 |
|
$entities = $em->getRepository($nomebundle . ':' . $controller)->findAll(); |
34
|
|
|
|
35
|
15 |
|
$paricevuti = array('nomebundle' => $nomebundle, 'nometabella' => $controller, 'container' => $container); |
36
|
|
|
|
37
|
15 |
|
$testatagriglia = Griglia::testataPerGriglia($paricevuti); |
38
|
|
|
|
39
|
15 |
|
$testatagriglia['multisearch'] = 1; |
|
|
|
|
40
|
15 |
|
$testatagriglia['showconfig'] = 1; |
|
|
|
|
41
|
15 |
|
$testatagriglia['showexcel'] = 1; |
|
|
|
|
42
|
15 |
|
$testatagriglia['showimportexcel'] = 1; |
|
|
|
|
43
|
15 |
|
$testatagriglia['larghezzagriglia'] = 700; |
44
|
15 |
|
$testatagriglia['overlayopen'] = 1; |
|
|
|
|
45
|
|
|
|
46
|
15 |
|
$testatagriglia['parametritesta'] = json_encode($paricevuti); |
47
|
|
|
|
48
|
15 |
|
$this->setParametriGriglia(array('request' => $request)); |
49
|
|
|
|
50
|
15 |
|
$testatagriglia['parametrigriglia'] = json_encode(self::$parametrigriglia); |
51
|
|
|
|
52
|
|
|
/* @var $qb \Doctrine\ORM\QueryBuilder */ |
53
|
15 |
|
$qb = $em->createQueryBuilder(); |
54
|
15 |
|
$qb->select(array('a')); |
55
|
15 |
|
$qb->from('FiCoreBundle:OpzioniTabella', 'a'); |
56
|
15 |
|
$qb->leftJoin('a.tabelle', 't'); |
57
|
15 |
|
$qb->where('t.nometabella = :tabella'); |
58
|
15 |
|
$qb->andWhere("t.nomecampo is null or t.nomecampo = ''"); |
59
|
15 |
|
$qb->setParameter('tabella', $controller); |
60
|
15 |
|
$opzioni = $qb->getQuery()->getResult(); |
61
|
15 |
|
foreach ($opzioni as $opzione) { |
62
|
|
|
$testatagriglia[$opzione->getParametro()] = $opzione->getValore(); |
63
|
15 |
|
} |
64
|
|
|
|
65
|
15 |
|
$testata = json_encode($testatagriglia); |
|
|
|
|
66
|
|
|
$twigparms = array( |
67
|
15 |
|
'entities' => $entities, |
68
|
15 |
|
'nomecontroller' => $controller, |
69
|
15 |
|
'testata' => $testata, |
70
|
15 |
|
'canread' => $canRead, |
71
|
15 |
|
); |
72
|
|
|
|
73
|
15 |
|
if (!$canRead) { |
74
|
12 |
|
throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto"); |
|
|
|
|
75
|
|
|
} else { |
76
|
3 |
|
return $this->render($nomebundle . ':' . $controller . ':index.html.twig', $twigparms); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
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.