FifreeSystemTables::getSystemEntities()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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 */
0 ignored issues
show
Documentation Bug introduced by
The doc comment $em at position 0 could not be parsed: Unknown type name '$em' at position 0 in $em.
Loading history...
12
    private $em;
13
    private $entities = array();
14
15 2
    public function __construct(Container $container)
16
    {
17 2
        $this->container = $container;
18 2
        $this->em = $this->container->get("doctrine")->getManager();
19 2
        $this->entities["Fi\CoreBundle\Entity\Ruoli"] = array("priority" => 10);
20 2
        $this->entities["Fi\CoreBundle\Entity\Operatori"] = array("priority" => 50);
21 2
        $this->entities["Fi\CoreBundle\Entity\Permessi"] = array("priority" => 100);
22 2
        $this->entities["Fi\CoreBundle\Entity\Storicomodifiche"] = array("priority" => 110);
23 2
        $this->entities["Fi\CoreBundle\Entity\Tabelle"] = array("priority" => 120);
24 2
        $this->entities["Fi\CoreBundle\Entity\OpzioniTabella"] = array("priority" => 150);
25 2
        $this->entities["Fi\CoreBundle\Entity\Ffprincipale"] = array("priority" => 160);
26 2
        $this->entities["Fi\CoreBundle\Entity\Ffsecondaria"] = array("priority" => 170);
27 2
        $this->entities["Fi\CoreBundle\Entity\MenuApplicazione"] = array("priority" => 180);
28
        
29 2
        $this->countEntitiesRows();
30 2
    }
31
32
    /**
33
     * @SuppressWarnings(PHPMD.UnusedLocalVariable)
34
     */
35 2
    public function countEntitiesRows()
36
    {
37 2
        $records = $this->entities;
38 2
        foreach ($records as $entity => $detail) {
39 2
            $qb = $this->em;
40 2
            $numrows = $qb->createQueryBuilder()
41 2
                    ->select('count(table.id)')
42 2
                    ->from($entity, 'table')
43 2
                    ->getQuery()
44 2
                    ->getSingleScalarResult();
45 2
            $this->entities[$entity]["rows"] = $numrows;
46
        }
47 2
    }
48
49 2
    public function dumpSystemEntities()
50
    {
51
        /** @scrutinizer ignore-call */
52 2
        dump($this->entities);
53 2
    }
54
55 2
    public function getSystemEntities()
56
    {
57 2
        return $this->entities;
58
    }
59
60
    public function getDefaultDataSystemEntities()
61
    {
62
        
63
        return $this->entities;
64
    }
65
}
66