@@ 17-36 (lines=20) @@ | ||
14 | use Symfony\Component\HttpFoundation\Response; |
|
15 | use Symfony\Component\Templating\EngineInterface; |
|
16 | ||
17 | class VariadicController |
|
18 | { |
|
19 | const TEMPLATE = 'index.html.twig'; |
|
20 | protected $templating; |
|
21 | protected $template; |
|
22 | ||
23 | public function __construct(EngineInterface $templating, $template = 'index.html.twig') |
|
24 | { |
|
25 | $this->templating = $templating; |
|
26 | $this->template = $template; |
|
27 | } |
|
28 | ||
29 | public function __invoke(...$arguments) // PHP 5.6+ |
|
30 | { |
|
31 | // Variadic $arguments apparently not supported when empty by Symfony 3.3.6 ArgumentResolver |
|
32 | // and viewed as a regular array by knplabs/rad-resource-resolver v2.1 |
|
33 | ||
34 | return new Response($this->templating->render($this->template, $arguments)); |
|
35 | } |
|
36 | } |
|
37 |
@@ 18-34 (lines=17) @@ | ||
15 | use Symfony\Component\HttpFoundation\Response; |
|
16 | use Symfony\Component\Templating\EngineInterface; |
|
17 | ||
18 | class TemplatingController |
|
19 | { |
|
20 | const TEMPLATE = 'index.html.twig'; |
|
21 | protected $templating; |
|
22 | protected $template; |
|
23 | ||
24 | public function __construct(EngineInterface $templating, string $template = self::TEMPLATE) |
|
25 | { |
|
26 | $this->templating = $templating; |
|
27 | $this->template = $template; |
|
28 | } |
|
29 | ||
30 | public function __invoke(): Response |
|
31 | { |
|
32 | return new Response($this->templating->render($this->template)); |
|
33 | } |
|
34 | } |
|
35 |