Completed
Push — master ( d750c1...767439 )
by Andrea
37:45 queued 33:43
created

ObjectToTabellaExtension::object2View()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Twig\Extension;
4
5
use Cdf\BiCoreBundle\Utils\Entity\DoctrineFieldReader;
6
7
class ObjectToTabellaExtension extends \Twig\Extension\AbstractExtension
8
{
9
    private $tableprefix;
10
11 25
    public function __construct($tableprefix)
12
    {
13 25
        $this->tableprefix = $tableprefix;
14 25
    }
15
16
    public function getFunctions()
17
    {
18
        return array(
19
            new \Twig_SimpleFunction('object2view', array($this, 'object2View', 'is_safe' => array('html'))),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated: since Twig 2.7, use "Twig\TwigFunction" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

19
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFunction('object2view', array($this, 'object2View', 'is_safe' => array('html'))),
Loading history...
20
            new \Twig_SimpleFunction('field2object', array($this, 'field2Object', 'is_safe' => array('html'))),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated: since Twig 2.7, use "Twig\TwigFunction" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFunction('field2object', array($this, 'field2Object', 'is_safe' => array('html'))),
Loading history...
21
            new \Twig_SimpleFunction('joinfieldid', array($this, 'joinFieldId', 'is_safe' => array('html'))),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated: since Twig 2.7, use "Twig\TwigFunction" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

21
            /** @scrutinizer ignore-deprecated */ new \Twig_SimpleFunction('joinfieldid', array($this, 'joinFieldId', 'is_safe' => array('html'))),
Loading history...
22
        );
23
    }
24
25 7
    public function object2View($object, $type = null, $decodifiche = null)
26
    {
27 7
        $dfr = new DoctrineFieldReader($this->tableprefix);
28
29 7
        return $dfr->object2View($object, $type, $decodifiche);
30
    }
31
32 7
    public function field2Object($fieldname, $object, $decodifiche = null)
33
    {
34 7
        $dfr = new DoctrineFieldReader($this->tableprefix);
35
36 7
        return $dfr->getField2Object($fieldname, $object, $decodifiche);
37
    }
38
39 2
    public function joinFieldId($object)
40
    {
41 2
        $valore = null;
42 2
        if ($object) {
43 1
            $valore = $object->getId();
44
        }
45
46 2
        return $valore;
47
    }
48
}
49