Total Complexity | 5 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | final class UrlGeneratorExtension extends AbstractExtension |
||
15 | { |
||
16 | /** |
||
17 | * @var UrlGeneratorInterface |
||
18 | */ |
||
19 | private $urlGenerator; |
||
20 | |||
21 | public function __construct(UrlGeneratorInterface $urlGenerator) |
||
22 | { |
||
23 | $this->urlGenerator = $urlGenerator; |
||
24 | } |
||
25 | |||
26 | public function getFunctions(): array |
||
27 | { |
||
28 | return [ |
||
29 | new TwigFunction('site_path', [$this, 'generateSitePath']), |
||
30 | new TwigFunction('site_url', [$this, 'generateSiteUrl']), |
||
31 | ]; |
||
32 | } |
||
33 | |||
34 | public function generateSitePath(string $name, array $parameters = []): string |
||
35 | { |
||
36 | return $this->urlGenerator->generate($name, $parameters); |
||
37 | } |
||
38 | |||
39 | public function generateSiteUrl($site, string $name, array $parameters = [], $schemeRelative = false): string |
||
47 | ); |
||
48 | } |
||
49 | } |
||
50 |