]> Raphaël G. Git Repositories - treebundle/blob - Controller/TreeController.php
Add constructor
[treebundle] / Controller / TreeController.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys TreeBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
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 Rapsys\TreeBundle\Controller;
13
14 use Psr\Container\ContainerInterface;
15
16 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
17 use Symfony\Component\HttpFoundation\Request;
18 use Symfony\Component\HttpFoundation\Response;
19
20 use Twig\Environment;
21
22 /**
23 * {@inheritdoc}
24 */
25 class TreeController extends AbstractController {
26 /**
27 * Context array
28 */
29 protected array $context = [];
30
31 /**
32 * Creates a new tree controller
33 *
34 * @param ContainerInterface $container The ContainerInterface instance
35 * @param Environment $twig The twig environment instance
36 */
37 function __construct(protected ContainerInterface $container, protected Environment $twig) {
38 }
39
40 /**
41 * The index page
42 *
43 * Display file tree
44 *
45 * @param Request $request The request instance
46 * @return Response The rendered view
47 */
48 public function index(Request $request, string $path): Response {
49 //Render template
50 $response = $this->twig->render('@RapsysTree/index.html.twig', $this->context);
51 $response->setEtag(md5($response->getContent()));
52 $response->setPublic();
53 $response->isNotModified($request);
54
55 //Return response
56 return $response;
57 }
58 }