|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Symfony-Util package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Jean-Bernard Addor |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace SymfonyUtil\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
15
|
|
|
use Symfony\Component\Templating\EngineInterface; |
|
16
|
|
|
|
|
17
|
|
View Code Duplication |
class VariadicController |
|
18
|
|
|
{ |
|
19
|
|
|
const TEMPLATE = 'index.html.twig'; |
|
20
|
|
|
protected $templating; |
|
21
|
|
|
protected $template; |
|
22
|
|
|
|
|
23
|
3 |
|
public function __construct(EngineInterface $templating, $template = 'index.html.twig') |
|
24
|
|
|
{ |
|
25
|
3 |
|
$this->templating = $templating; |
|
26
|
3 |
|
$this->template = $template; |
|
27
|
3 |
|
} |
|
28
|
|
|
|
|
29
|
2 |
|
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
|
2 |
|
return new Response($this->templating->render($this->template, $arguments)); |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
|