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

AdminBundle/Twig/AdminRouteHelperTwigExtension.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
7
use Kunstmaan\AdminBundle\Helper\AdminRouteHelper;
8
use Symfony\Component\Form\FormView;
9
10
class AdminRouteHelperTwigExtension extends \Twig_Extension
11
{
12
    /** @var AdminRouteHelper $adminRouteHelper */
13
    private $adminRouteHelper;
14
15
    /**
16
     * @param AdminRouteHelper $adminRouteHelper
17
     */
18
    public function __construct(AdminRouteHelper $adminRouteHelper)
19
    {
20
        $this->adminRouteHelper = $adminRouteHelper;
21
    }
22
23
    /**
24
     * Returns a list of functions to add to the existing list.
25
     *
26
     * @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...
27
     */
28
    public function getFunctions()
29
    {
30
        return array(
31
            new \Twig_SimpleFunction('is_admin_route', array($this, 'isAdminRoute')),
32
        );
33
    }
34
35
    /**
36
     * Lets the adminroutehelper determine wether the URI is an admin route
37
     *
38
     * @return boolean
39
     */
40
    public function isAdminRoute($URI)
41
    {
42
        return $this->adminRouteHelper->isAdminRoute($URI);
43
    }
44
45
    /**
46
     * Get the Twig extension name.
47
     *
48
     * @return string
49
     */
50
    public function getName()
51
    {
52
        return 'admin_route_helper_twig_extension';
53
    }
54
}
55