Completed
Push — master ( 770316...74fc07 )
by Jeroen
09:08 queued 02:44
created

AdminBundle/Twig/AdminRouteHelperTwigExtension.php (3 issues)

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