eZObjectWrapperExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 41
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFunctions() 0 6 1
A renderLocation() 0 7 1
A getName() 0 4 1
1
<?php
2
3
namespace Kaliop\eZObjectWrapperBundle\Twig;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
7
class eZObjectWrapperExtension extends \Twig_Extension
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Extension has been deprecated with message: since Twig 2.7, use "Twig\Extension\AbstractExtension" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
8
{
9
    private $container;
10
11
    /**
12
     * @param ContainerInterface $container
13
     */
14
    public function __construct(ContainerInterface $container)
15
    {
16
        $this->container = $container;
17
    }
18
19
    public function getFunctions()
20
    {
21
        return array(
22
            new \Twig_SimpleFunction('render_location', array($this,'renderLocation'), array('is_safe' => array('html'))),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated with message: since Twig 2.7, use "Twig\TwigFunction" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
23
        );
24
    }
25
26
    /**
27
     * Render a location according to the viewType and the ContentType set in override.yml, without doing a sub-request.
28
     * Note: we can NOT inject directly the 'ezpublish.controller.content.view' service because it generates a ServiceCircularReferenceException
29
     *
30
     * @param int $locationID
31
     * @param string $viewType
32
     * @param array $params
33
     * @return string generally it is safe html and does not need to be further encoded/escaped
34
     */
35
    public function renderLocation($locationID, $viewType, $params = array())
36
    {
37
        $rendering = $this->container->get('ezpublish.controller.content.view')
38
            ->viewLocation($locationID, $viewType, false, $params);
39
40
        return $rendering->getContent();
41
    }
42
43
    public function getName()
44
    {
45
        return 'ezobject_wrapper_extension';
46
    }
47
}