Completed
Push — master ( 06c1ce...67d37c )
by Jeroen
06:20
created

TabsTwigExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 6 1
A renderWidget() 0 8 1
1
<?php
2
3
namespace Kunstmaan\AdminBundle\Twig;
4
5
use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\TabPane;
6
use Twig\Environment;
7
use Twig\Extension\AbstractExtension;
8
use Twig\TwigFunction;
9
10
/**
11
 * Extension to render tabs
12
 *
13
 * @final since 5.4
14
 */
15
class TabsTwigExtension extends AbstractExtension
16
{
17
    /**
18
     * Returns a list of functions to add to the existing list.
19
     *
20
     * @return array An array of functions
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use TwigFunction[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
21
     */
22
    public function getFunctions()
23
    {
24
        return array(
25
            new TwigFunction('tabs_widget', array($this, 'renderWidget'), array('needs_environment' => true, 'is_safe' => array('html'))),
26
        );
27
    }
28
29
    /**
30
     * @param Environment $env
31
     * @param TabPane     $tabPane  The tab pane
32
     * @param array       $options  The extra options
33
     * @param string      $template The template
34
     *
35
     * @return string
36
     */
37
    public function renderWidget(Environment $env, TabPane $tabPane, $options = array(), $template = '@KunstmaanAdmin/TabsTwigExtension/widget.html.twig')
38
    {
39
        $template = $env->load($template);
40
41
        return $template->render(array_merge($options, array(
42
            'tabPane' => $tabPane,
43
        )));
44
    }
45
}
46