Passed
Push — 4.1 ( 15ef68...fe3b41 )
by Andrea
13:13
created

ObjectToTabellaExtension::object2View()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Fi\CoreBundle\Twig\Extension;
4
5
use Fi\CoreBundle\Utils\Entity\DoctrineFieldReader;
6
7
class ObjectToTabellaExtension extends \Twig_Extension
8
{
9
10
    protected $fifreetableprefix;
11
12 13
    public function __construct($fifreetableprefix)
13
    {
14 13
        $this->fifreetableprefix = $fifreetableprefix;
15 13
    }
16
17
    public function getFunctions()
18
    {
19
        return array(
20
            new \Twig_SimpleFunction('object2view', array($this, 'object2View', 'is_safe' => array('html'))),
21
            new \Twig_SimpleFunction('field2object', array($this, 'field2Object', 'is_safe' => array('html'))),
22
        );
23
    }
24
25 6
    public function object2View($object, $type = null)
26
    {
27 6
        $dfr = new DoctrineFieldReader($object, $this->fifreetableprefix);
28 6
        return $dfr->object2View($object, $type);
29
    }
30
31 6
    public function field2Object($fieldtoobj, $object)
32
    {
33 6
        $dfr = new DoctrineFieldReader($object, $this->fifreetableprefix);
34 6
        return $dfr->getField2Object($fieldtoobj);
35
    }
36
}
37