Completed
Push — develop ( 585b00...6ab382 )
by Andrea
65:09
created

ObjectToTabellaExtension::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 3
cp 0
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 7
20
    public function object2View($object, $type = null, $decodifiche = null)
21 7
    {
22 7
        $dfr = new DoctrineFieldReader($this->container);
23
        return $dfr->object2View($object, $type, $decodifiche);
24
    }
25 7
26
    public function field2Object($fieldname, $object, $decodifiche = null)
27 7
    {
28 7
        $dfr = new DoctrineFieldReader($this->container);
29
        return $dfr->getField2Object($fieldname, $object, $decodifiche);
30
    }
31
    public function joinFieldId($object)
32
    {
33
        return $object->getId();
34
    }
35
}
36