Completed
Push — master ( 06c1ce...67d37c )
by Jeroen
06:20
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 Kunstmaan\AdminBundle\Helper\AdminRouteHelper;
6
use Twig\Extension\AbstractExtension;
7
use Twig\TwigFunction;
8
9
/**
10
 * @final since 5.4
11
 */
12
class AdminRouteHelperTwigExtension extends AbstractExtension
13
{
14
    /** @var AdminRouteHelper */
15
    private $adminRouteHelper;
16
17
    /**
18
     * @param AdminRouteHelper $adminRouteHelper
19
     */
20
    public function __construct(AdminRouteHelper $adminRouteHelper)
21
    {
22
        $this->adminRouteHelper = $adminRouteHelper;
23
    }
24
25
    /**
26
     * Returns a list of functions to add to the existing list.
27
     *
28
     * @return array An array of functions
0 ignored issues
show
Consider making the return type a bit more specific; maybe use TwigFunction[].

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...
29
     */
30
    public function getFunctions()
31
    {
32
        return array(
33
            new TwigFunction('is_admin_route', array($this, 'isAdminRoute')),
34
        );
35
    }
36
37
    /**
38
     * Lets the adminroutehelper determine wether the URI is an admin route
39
     *
40
     * @return bool
41
     */
42
    public function isAdminRoute($URI)
43
    {
44
        return $this->adminRouteHelper->isAdminRoute($URI);
45
    }
46
47
    /**
48
     * Get the Twig extension name.
49
     *
50
     * @return string
51
     */
52
    public function getName()
53
    {
54
        return 'admin_route_helper_twig_extension';
55
    }
56
}
57