From f6f7edcf34e2e4f1a0fb8988023dcb31a4655231 Mon Sep 17 00:00:00 2001 From: Kilian Beraud Date: Thu, 30 Jan 2025 11:37:05 +0100 Subject: [PATCH] - Ajout des favoris --- src/Controller/FavorisController.php | 35 ++++++++++++++++++++++++++++ templates/favoris/index.html.twig | 19 +++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/Controller/FavorisController.php create mode 100644 templates/favoris/index.html.twig diff --git a/src/Controller/FavorisController.php b/src/Controller/FavorisController.php new file mode 100644 index 0000000..d0a2680 --- /dev/null +++ b/src/Controller/FavorisController.php @@ -0,0 +1,35 @@ +googleBooksService = $googleBooksService; + } + + #[Route('/favoris', name: 'app_favoris')] + public function index(FavorisRepository $favorisRepository): Response + { + $favorisUser = $favorisRepository->findBy(['user' => $this->getUser()]); + foreach ($favorisUser as $favori) { + array_push($this->favorisResult, $this->googleBooksService->searchBooks($favori->getIdGoogle(), 'fr', 0)); + + } + return $this->render('favoris/index.html.twig', [ + 'controller_name' => 'FavorisController', + 'datas' => $this->favorisResult, + + ]); + } +} \ No newline at end of file diff --git a/templates/favoris/index.html.twig b/templates/favoris/index.html.twig new file mode 100644 index 0000000..ea09521 --- /dev/null +++ b/templates/favoris/index.html.twig @@ -0,0 +1,19 @@ +{% extends 'base.html.twig' %} + +{% block title %}Mes favoris{% endblock %} + +{% block body %} +
+ {% for data in datas %} + {% if data.items is defined %} + {% for book in data.items %} + {% if book.volumeInfo.authors is defined %} +

{{ book.volumeInfo.title }} - {{ book.volumeInfo.authors | join(", ") }}

+ {% endif %} + + {% endfor %} + {% endif %} + + {% endfor %} +
+{% endblock %}