diff --git a/src/Controller/FavoriteController.php b/src/Controller/FavoriteController.php index fad2908..1801205 100644 --- a/src/Controller/FavoriteController.php +++ b/src/Controller/FavoriteController.php @@ -8,73 +8,73 @@ use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\HttpFoundation\Request; use Doctrine\ORM\EntityManagerInterface; use App\Entity\Album; -Use App\Utils; +use App\Utils; #[Route('/favorite')] class FavoriteController extends AbstractController { #[Route('/remove/{album_id}', name: 'app_remove_favorite')] - public function removeFromFavorites(int $album_id ): Response + public function removeFromFavorites(int $album_id): Response { $user = $this->getUser(); $album = $entityManager->getRepository(Album::class)->findBy( ['album_id' => $album_id] //['album_id' => $request->query->get('album_id')] ); - - if (count($album) == 0) { + + if (count($album) == 0) { return new Response("ca pas a marche"); } - + $user->removeLiked($album[0]); $entityManager->persist($user); $entityManager->flush(); - + return new Response("ca a marche"); } - + #[Route('/add/{album_id}', name: 'app_add_favorite')] - public function addToFavorites(int $album_id ,Request $request, EntityManagerInterface $entityManager): Response + public function addToFavorites(int $album_id, Request $request, EntityManagerInterface $entityManager): Response { - + $user = $this->getUser(); $album = $entityManager->getRepository(Album::class)->findBy( ['album_id' => $album_id] //['album_id' => $request->query->get('album_id')] ); - - if (count($album) == 0) { + + if (count($album) == 0) { return new Response("ca pas a marche"); } $user->addLiked($album[0]); $entityManager->persist($user); $entityManager->flush(); - + return new Response("ca a marche"); } - #[Route('/', name: 'app_favorites')] + #[Route('/', name: 'app_favorite')] public function index(Request $request): Response { $user = $this->getUser(); $all_liked = array(); - foreach($user->getLiked() as $liked){ - $release = Utils::makeRequest("GET", "/releases/".strval($liked->getAlbumId()), []); + foreach ($user->getLiked() as $liked) { + $release = Utils::makeRequest("GET", "/releases/" . strval($liked->getAlbumId()), []); $release = array_merge( - $release, - ["fruit" => $liked->getFruits()] - ); + $release, + ["fruit" => $liked->getFruits()] + ); array_push( $all_liked, $release, ); } - + return $this->render('favorite/index.html.twig', [ 'controller_name' => 'FavoriteController', 'favorites' => $all_liked ]); - } + } } diff --git a/templates/base.html.twig b/templates/base.html.twig index ea9fd2f..88b50c0 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -1,4 +1,4 @@ - +
@@ -41,16 +41,19 @@