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

AdminPermissionsTwigExtension::renderWidget()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 4
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
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Extension has been deprecated with message: since Twig 2.7, use "Twig\Extension\AbstractExtension" 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...
13
{
14
    /**
15
     * Returns a list of functions to add to the existing list.
16
     *
17
     * @return array An array of functions
0 ignored issues
show
Documentation introduced by
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...
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