Add a like button #19

Merged
matis.mazingue merged 6 commits from refs/pull/19/head into main 2024-06-14 09:41:05 +02:00
Showing only changes of commit 2e20f5610e - Show all commits

View File

@@ -172,23 +172,6 @@ class PostController extends AbstractController
return $this->redirectToRoute('app_post_show', ['id' => $comment->getRelatedPost()->getId()]); return $this->redirectToRoute('app_post_show', ['id' => $comment->getRelatedPost()->getId()]);
} }
// #[Route('/post/{id}/like', name: 'app_posts_like', methods: ['POST'])]
// #[IsGranted('ROLE_USER')]
// public function addLike(Post $post, EntityManagerInterface $entityManager, #[CurrentUser] User $user): Response
// {
// $user->addLikedPost($post);
// $entityManager->flush();
// return $this->redirectToRoute('app_post_show', ['id' => $post->getId()], Response::HTTP_SEE_OTHER);
// }
// #[Route('/post/{id}/unlike', name: 'app_posts_unlike', methods: ['POST'])]
// #[IsGranted('ROLE_USER')]
// public function deleteLike(Post $post, EntityManagerInterface $entityManager, #[CurrentUser] User $user): Response
// {
// $user->removeLikedPost($post);
// $entityManager->flush();
// return $this->redirectToRoute('app_post_show', ['id' => $post->getId()], Response::HTTP_SEE_OTHER);
// }
#[Route('/post/{id}/like', name: 'app_posts_like', methods: ['POST'])] #[Route('/post/{id}/like', name: 'app_posts_like', methods: ['POST'])]
#[IsGranted('ROLE_USER')] #[IsGranted('ROLE_USER')]
public function addLike(#[CurrentUser] User $user, Post $post, EntityManagerInterface $entityManager): JsonResponse public function addLike(#[CurrentUser] User $user, Post $post, EntityManagerInterface $entityManager): JsonResponse