|
|
|
@ -34,16 +34,13 @@ class PostController extends AbstractController
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/post', name: 'app_post_index', methods: ['GET'])]
|
|
|
|
|
#[Route('/posts', name: 'app_post_index', methods: ['GET'])]
|
|
|
|
|
public function table(PostRepository $repository): Response
|
|
|
|
|
{
|
|
|
|
|
$posts = $repository->findAll();
|
|
|
|
|
return $this->render('post/table.html.twig', [
|
|
|
|
|
'posts' => $posts,
|
|
|
|
|
]);
|
|
|
|
|
return $this->redirectToRoute('app_posts', [], Response::HTTP_SEE_OTHER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/post/new', name: 'app_post_new', methods: ['GET', 'POST'])]
|
|
|
|
|
#[Route('/posts/new', name: 'app_post_new', methods: ['GET', 'POST'])]
|
|
|
|
|
#[IsGranted('ROLE_USER')]
|
|
|
|
|
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
|
|
|
|
{
|
|
|
|
@ -64,7 +61,7 @@ class PostController extends AbstractController
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/post/{id}', name: 'app_post_show', methods: ['GET'])]
|
|
|
|
|
#[Route('/posts/{id}', name: 'app_post_show', methods: ['GET'])]
|
|
|
|
|
public function show(Post $post): Response
|
|
|
|
|
{
|
|
|
|
|
$form = $this->createForm(CommentType::class, new Comment(), [
|
|
|
|
@ -76,7 +73,7 @@ class PostController extends AbstractController
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/post/{id}/edit', name: 'app_post_edit', methods: ['GET', 'POST'])]
|
|
|
|
|
#[Route('/posts/{id}/edit', name: 'app_post_edit', methods: ['GET', 'POST'])]
|
|
|
|
|
#[IsGranted('ROLE_USER')]
|
|
|
|
|
public function edit(Request $request, Post $post, EntityManagerInterface $entityManager): Response
|
|
|
|
|
{
|
|
|
|
@ -95,7 +92,7 @@ class PostController extends AbstractController
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/post/{id}', name: 'app_post_delete', methods: ['POST'])]
|
|
|
|
|
#[Route('/posts/{id}', name: 'app_post_delete', methods: ['POST'])]
|
|
|
|
|
#[IsGranted('ROLE_USER')]
|
|
|
|
|
public function delete(Request $request, Post $post, EntityManagerInterface $entityManager): Response
|
|
|
|
|
{
|
|
|
|
@ -107,7 +104,7 @@ class PostController extends AbstractController
|
|
|
|
|
return $this->redirectToRoute('app_posts', [], Response::HTTP_SEE_OTHER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/post/{id}/comment', name: 'app_post_comment', methods: ['POST'])]
|
|
|
|
|
#[Route('/posts/{id}/comment', name: 'app_post_comment', methods: ['POST'])]
|
|
|
|
|
public function publishComment(Request $request, Post $post, EntityManagerInterface $entityManager, #[CurrentUser] User $user): Response
|
|
|
|
|
{
|
|
|
|
|
$comment = new Comment();
|
|
|
|
|