+ *
+ * @param ContainerInterface $container The ContainerInterface instance
+ * @param RouterInterface $router The router instance
+ * @param RequestStack $stack The stack instance
+ * @param TranslatorInterface $translator The translator instance
+ * @param Environment $twig The twig environment instance
+ */
+ function __construct(protected ContainerInterface $container, protected RouterInterface $router, protected RequestStack $stack, protected TranslatorInterface $translator, protected Environment $twig) {
+ //Retrieve config
+ $this->config = $container->getParameter(RapsysTreeBundle::getAlias());
+
+ //Get main request
+ $this->request = $this->stack->getMainRequest();
+
+ //Get current locale
+ $this->locale = $this->request->getLocale();
+
+ //Set canonical
+ $canonical = null;
+
+ //Set alternates
+ $alternates = [];
+
+ //Set route
+ //TODO: default to not found route ???
+ //TODO: pour une url not found, cet attribut n'est pas défini, comment on fait ???
+ //XXX: on génère une route bidon par défaut ???
+ $this->route = $this->request->attributes->get('_route');
+
+ //Set route params
+ $this->routeParams = $this->request->attributes->get('_route_params');
+
+ //With route and routeParams
+ if ($this->route !== null && $this->routeParams !== null) {
+ //Set canonical
+ $canonical = $this->router->generate($this->route, $this->routeParams, UrlGeneratorInterface::ABSOLUTE_URL);
+
+ //Set alternates
+ $alternates = [
+ substr($this->locale, 0, 2) => [
+ 'absolute' => $canonical
+ ]
+ ];
+ }
+
+ //Set the context
+ $this->context = [
+ 'alternates' => $alternates,
+ 'canonical' => $canonical,
+ 'contact' => [
+ 'address' => $this->config['contact']['address'],
+ 'name' => $this->translator->trans($this->config['contact']['name'])
+ ],
+ 'copy' => [
+ 'by' => $this->translator->trans($this->config['copy']['by']),
+ 'link' => $this->config['copy']['link'],
+ 'long' => $this->translator->trans($this->config['copy']['long']),
+ 'short' => $this->translator->trans($this->config['copy']['short']),
+ 'title' => $this->config['copy']['title']
+ ],
+ 'description' => null,
+ 'donate' => $this->config['donate'],
+ 'facebook' => [
+ 'og:type' => 'article',
+ 'og:site_name' => $title = $this->translator->trans($this->config['title']),
+ 'og:url' => $canonical,
+ #'fb:admins' => $this->config['facebook']['admins'],
+ 'fb:app_id' => $this->config['facebook']['apps']
+ ],
+ //XXX: TODO: only generate it when fb robot request the url ???
+ 'fbimage' => [
+ 'texts' => [
+ $title => [
+ 'font' => 'irishgrover',
+ 'size' => 110
+ ]
+ ]
+ ],
+ 'icon' => $this->config['icon'],
+ 'keywords' => null,
+ 'locale' => str_replace('_', '-', $this->locale),
+ 'logo' => $this->config['logo'],
+ 'forms' => [],
+ 'root' => $this->router->generate($this->config['root']),
+ 'title' => [
+ 'page' => null,
+ 'section' => null,
+ 'site' => $title
+ ]
+ ];
+ }
+
+ /**
+ * The index page
+ *
+ * Display index
+ *
+ * @param Request $request The request instance
+ * @return Response The rendered view
+ */
+ public function index(Request $request): Response {
+ //Get roots
+ $this->context['roots'] = $this->config['roots'];
+
+ //Render template
+ $response = $this->render('@RapsysTree/index.html.twig', $this->context);
+
+ $response->setEtag(md5($response->getContent()));
+ $response->setPublic();
+ $response->isNotModified($request);
+
+ //Return response
+ return $response;
+ }
+
+ /**
+ * The directory page
+ *
+ * Display directory
+ *
+ * @param Request $request The request instance
+ * @param string $path The directory path
+ * @return Response The rendered view
+ */
+ public function directory(Request $request, string $path): Response {
+ header('Content-Type: text/plain');
+ var_dump($path);
+ exit;
+
+ //Render template
+ $response = $this->render('@RapsysTree/directory.html.twig', $this->context);
+
+ $response->setEtag(md5($response->getContent()));
+ $response->setPublic();
+ $response->isNotModified($request);
+
+ //Return response
+ return $response;
+ }
+
+ /**
+ * The document page
+ *
+ * Display document
+ *
+ * @param Request $request The request instance
+ * @param string $path The directory path
+ * @return Response The rendered view