Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Legacy | |
100.00% |
12 / 12 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFunctions | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
getPage | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Engelsystem\Renderer\Twig\Extensions; |
6 | |
7 | use Engelsystem\Http\Request; |
8 | use Twig\Extension\AbstractExtension as TwigExtension; |
9 | use Twig\TwigFunction; |
10 | |
11 | class Legacy extends TwigExtension |
12 | { |
13 | public function __construct(protected Request $request) |
14 | { |
15 | } |
16 | |
17 | /** |
18 | * @return TwigFunction[] |
19 | */ |
20 | public function getFunctions(): array |
21 | { |
22 | $isSafeHtml = ['is_safe' => ['html']]; |
23 | return [ |
24 | new TwigFunction('menu', 'make_navigation', $isSafeHtml), |
25 | new TwigFunction('menuUserShiftState', 'User_shift_state_render', $isSafeHtml), |
26 | new TwigFunction('menuUserHints', 'header_render_hints', $isSafeHtml), |
27 | new TwigFunction('menuLanguages', 'make_language_select', $isSafeHtml), |
28 | new TwigFunction('page', [$this, 'getPage']), |
29 | ]; |
30 | } |
31 | |
32 | public function getPage(): string |
33 | { |
34 | if ($this->request->has('p')) { |
35 | return $this->request->get('p'); |
36 | } |
37 | |
38 | return $this->request->path(); |
39 | } |
40 | } |