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