Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
created

Kunstmaan/AdminBundle/Twig/TabsTwigExtension.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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