Completed
Push — master ( 770316...74fc07 )
by Jeroen
09:08 queued 02:44
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
/**
9
 * Extension to render blocks of twig templates
10
 */
11
class ToolbarTwigExtension extends Twig_Extension
12
{
13
    /**
14
     * Returns a list of functions to add to the existing list.
15
     *
16
     * @return array An array of functions
17
     */
18
    public function getFunctions()
19
    {
20
        return array(
21
            new \Twig_SimpleFunction('block_render', array($this, 'renderBlock'), array('needs_environment' => true, '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...
22
        );
23
    }
24
25
    /**
26
     * @param Twig_Environment $env
27
     * @param $template
28
     * @param $block
29
     * @param $context
30
     *
31
     * @return string
32
     */
33
    public function renderBlock(Twig_Environment $env, $template, $block, $context)
34
    {
35
        $template = $env->loadTemplate($template);
36
        $context = $env->mergeGlobals($context);
37
38
        return $template->renderBlock($block, $context);
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function getName()
45
    {
46
        return 'toolbar_twig_extension';
47
    }
48
}
49