]> Raphaël G. Git Repositories - treebundle/commitdiff
Add constructor
authorRaphaël Gertz <git@rapsys.eu>
Thu, 10 Oct 2024 21:19:23 +0000 (23:19 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Thu, 10 Oct 2024 21:19:23 +0000 (23:19 +0200)
Add index member function

Controller/TreeController.php

index b51c01d6714f84913cec4fa57eea5e280cea1587..a8f19925ebe27e4f91a1d2cb3998085d54b5a41e 100644 (file)
 
 namespace Rapsys\TreeBundle\Controller;
 
 
 namespace Rapsys\TreeBundle\Controller;
 
+use Psr\Container\ContainerInterface;
+
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+
+use Twig\Environment;
 
 /**
  * {@inheritdoc}
  */
 class TreeController extends AbstractController {
 
 /**
  * {@inheritdoc}
  */
 class TreeController extends AbstractController {
+       /**
+        * Context array
+        */
+       protected array $context = [];
+
        /**
         * Creates a new tree controller
        /**
         * Creates a new tree controller
+        *
+        * @param ContainerInterface $container The ContainerInterface instance
+        * @param Environment $twig The twig environment instance
         */
         */
-       function __construct() {
+       function __construct(protected ContainerInterface $container, protected Environment $twig) {
+       }
+
+       /**
+        * The index page
+        *
+        * Display file tree
+        *
+        * @param Request $request The request instance
+        * @return Response The rendered view
+        */
+       public function index(Request $request, string $path): Response {
+               //Render template
+               $response = $this->twig->render('@RapsysTree/index.html.twig', $this->context);
+               $response->setEtag(md5($response->getContent()));
+               $response->setPublic();
+               $response->isNotModified($request);
+
+               //Return response
+               return $response;
        }
 }
        }
 }