Completed
Push — master ( 91fdab...75a7b9 )
by
unknown
13:37
created

AdminBundle/Twig/ToolbarTwigExtension.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 Twig_Environment;
6
use Twig_Extension;
7
8
use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\TabPane;
9
10
/**
11
 * Extension to render blocks of twig templates
12
 */
13
class ToolbarTwigExtension extends Twig_Extension
14
{
15
    /**
16
     * Returns a list of functions to add to the existing list.
17
     *
18
     * @return array An array of functions
0 ignored issues
show
Consider making the return type a bit more specific; maybe use \Twig_SimpleFunction[].

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...
19
     */
20
    public function getFunctions()
21
    {
22
        return array(
23
            new \Twig_SimpleFunction('block_render', array($this, 'renderBlock'), array('needs_environment' => true, 'is_safe' => array('html')))
24
        );
25
    }
26
27
    /**
28
     * @param Twig_Environment $env
29
     * @param $template
30
     * @param $block
31
     * @param $context
32
     * @return string
33
     */
34
    public function renderBlock(Twig_Environment $env, $template, $block, $context)
35
    {
36
        $template = $env->loadTemplate($template);
37
        $context = $env->mergeGlobals($context);
38
39
        return $template->renderBlock($block, $context);
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getName()
46
    {
47
        return 'toolbar_twig_extension';
48
    }
49
50
}
51