|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fi\CoreBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface as Container; |
|
6
|
|
|
|
|
7
|
|
|
class FifreeSystemTables |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
private $container; |
|
11
|
|
|
/* @var $em \Doctrine\ORM\EntityManager */ |
|
12
|
|
|
private $em; |
|
13
|
|
|
private $entities = array(); |
|
14
|
|
|
|
|
15
|
|
|
public function __construct(Container $container) |
|
16
|
|
|
{ |
|
17
|
|
|
$this->container = $container; |
|
|
|
|
|
|
18
|
|
|
$this->em = $this->container->get("doctrine")->getManager(); |
|
|
|
|
|
|
19
|
|
|
$this->entities["Fi\CoreBundle\Entity\Ruoli"] = array("priority" => 10); |
|
|
|
|
|
|
20
|
|
|
$this->entities["Fi\CoreBundle\Entity\Operatori"] = array("priority" => 50); |
|
|
|
|
|
|
21
|
|
|
$this->entities["Fi\CoreBundle\Entity\Permessi"] = array("priority" => 100); |
|
|
|
|
|
|
22
|
|
|
$this->entities["Fi\CoreBundle\Entity\Storicomodifiche"] = array("priority" => 110); |
|
|
|
|
|
|
23
|
|
|
$this->entities["Fi\CoreBundle\Entity\Tabelle"] = array("priority" => 120); |
|
|
|
|
|
|
24
|
|
|
$this->entities["Fi\CoreBundle\Entity\OpzioniTabella"] = array("priority" => 150); |
|
|
|
|
|
|
25
|
|
|
$this->entities["Fi\CoreBundle\Entity\Ffprincipale"] = array("priority" => 160); |
|
|
|
|
|
|
26
|
|
|
$this->entities["Fi\CoreBundle\Entity\Ffsecondaria"] = array("priority" => 170); |
|
|
|
|
|
|
27
|
|
|
$this->entities["Fi\CoreBundle\Entity\MenuApplicazione"] = array("priority" => 180); |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
$this->countEntitiesRows(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @SuppressWarnings(PHPMD.UnusedLocalVariable) |
|
34
|
|
|
*/ |
|
35
|
|
|
public function countEntitiesRows() |
|
36
|
|
|
{ |
|
37
|
|
|
$records = $this->entities; |
|
38
|
|
|
foreach ($records as $entity => $detail) { |
|
39
|
|
|
$qb = $this->em; |
|
|
|
|
|
|
40
|
|
|
$numrows = $qb->createQueryBuilder() |
|
|
|
|
|
|
41
|
|
|
->select('count(table.id)') |
|
42
|
|
|
->from($entity, 'table') |
|
43
|
|
|
->getQuery() |
|
44
|
|
|
->getSingleScalarResult(); |
|
45
|
|
|
$this->entities[$entity]["rows"] = $numrows; |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function dumpSystemEntities() |
|
50
|
|
|
{ |
|
51
|
|
|
dump($this->entities); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getSystemEntities() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->entities; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function getDefaultDataSystemEntities() |
|
60
|
|
|
{ |
|
61
|
|
|
|
|
62
|
|
|
return $this->entities; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
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.