Completed
Push — master ( fceff2...3eee26 )
by Andrea
19:42 queued 16:23
created

ObjectToTabellaExtension::joinFieldId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
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
8
{
9
    public $container;
10
11
    public function getFunctions()
12
    {
13
        return array(
14
            new \Twig_SimpleFunction('object2view', array($this, 'object2View', 'is_safe' => array('html'))),
15
            new \Twig_SimpleFunction('field2object', array($this, 'field2Object', 'is_safe' => array('html'))),
16
            new \Twig_SimpleFunction('joinfieldid', array($this, 'joinFieldId', 'is_safe' => array('html'))),
17
        );
18
    }
19
20 7
    public function object2View($object, $type = null, $decodifiche = null)
21
    {
22 7
        $dfr = new DoctrineFieldReader($this->container);
23 7
        return $dfr->object2View($object, $type, $decodifiche);
24
    }
25
26 7
    public function field2Object($fieldname, $object, $decodifiche = null)
27
    {
28 7
        $dfr = new DoctrineFieldReader($this->container);
29 7
        return $dfr->getField2Object($fieldname, $object, $decodifiche);
30
    }
31 2
    public function joinFieldId($object)
32
    {
33 2
        $valore = null;
34 2
        if ($object) {
35 1
            $valore = $object->getId();
36
        }
37 2
        return $valore;
38
    }
39
}
40