Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

AdminBundle/Twig/AdminPermissionsTwigExtension.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\Security\Acl\Permission\PermissionAdmin;
6
use Symfony\Component\Form\FormView;
7
use Twig_Environment;
8
9
/**
10
 * AdminPermissionsTwigExtension
11
 */
12
class AdminPermissionsTwigExtension extends \Twig_Extension
13
{
14
    /**
15
     * Returns a list of functions to add to the existing list.
16
     *
17
     * @return array An array of functions
18
     */
19
    public function getFunctions()
20
    {
21
        return array(
22
            new \Twig_SimpleFunction('permissionsadmin_widget', array($this, 'renderWidget'), 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...
23
        );
24
    }
25
26
    /**
27
     * Renders the permission admin widget.
28
     *
29
     * @param \Twig_Environment $env
30
     * @param PermissionAdmin   $permissionAdmin The permission admin
31
     * @param FormView          $form            The form
32
     * @param array             $parameters      Extra parameters
33
     *
34
     * @return string
35
     */
36
    public function renderWidget(Twig_Environment $env, PermissionAdmin $permissionAdmin, FormView $form, array $parameters = array())
37
    {
38
        $template = $env->loadTemplate('KunstmaanAdminBundle:PermissionsAdminTwigExtension:widget.html.twig');
39
40
        return $template->render(array_merge(array(
41
            'form' => $form,
42
            'permissionadmin' => $permissionAdmin,
43
            'recursiveSupport' => true,
44
        ), $parameters));
45
    }
46
}
47