1 | <?php |
||
2 | /** |
||
3 | * UrlResolver.php |
||
4 | * |
||
5 | * @since 12/10/16 |
||
6 | * @author gseidel |
||
7 | */ |
||
8 | |||
9 | namespace Enhavo\Bundle\RoutingBundle\Twig; |
||
10 | |||
11 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
||
12 | use Enhavo\Bundle\RoutingBundle\Router\Router; |
||
13 | use Twig\Extension\AbstractExtension; |
||
14 | use Twig\TwigFunction; |
||
15 | |||
16 | class RouterExtension extends AbstractExtension |
||
17 | { |
||
18 | /** |
||
19 | * @var Router |
||
20 | */ |
||
21 | private $router; |
||
22 | |||
23 | /** |
||
24 | * RouterExtension constructor. |
||
25 | * |
||
26 | * @param Router $router |
||
27 | */ |
||
28 | public function __construct(Router $router) |
||
29 | { |
||
30 | $this->router = $router; |
||
31 | } |
||
32 | |||
33 | public function getFunctions() |
||
34 | { |
||
35 | return array( |
||
36 | new TwigFunction('router', array($this, 'generate')), |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param $resource |
||
42 | * @param array $parameters |
||
43 | * @param int $referenceType |
||
44 | * @param string $type |
||
45 | * @return string |
||
46 | */ |
||
47 | public function generate($resource , $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH, $type = 'default') |
||
0 ignored issues
–
show
|
|||
48 | { |
||
49 | return $this->router->generate($resource , $parameters, $referenceType, $type = 'default'); |
||
50 | } |
||
51 | } |
||
52 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.