|
|
|
@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
use App\Entity\Post;
|
|
|
|
|
use App\Form\PostType;
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
|
|
|
|
|
|
|
class PostController extends AbstractController
|
|
|
|
|
{
|
|
|
|
@ -22,7 +23,8 @@ class PostController extends AbstractController
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/posts', name: 'app_posts')]
|
|
|
|
|
#[Route('/posts', name: 'app_add_posts')]
|
|
|
|
|
#[IsGranted('ROLE_USER', message: 'You must be logged in to access this page.')]
|
|
|
|
|
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
|
|
|
|
{
|
|
|
|
|
$post = new Post();
|
|
|
|
@ -38,7 +40,7 @@ class PostController extends AbstractController
|
|
|
|
|
$entityManager->persist($post);
|
|
|
|
|
$entityManager->flush();
|
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute('app_posts');
|
|
|
|
|
return $this->redirectToRoute('app_add_posts');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->render('post/post.html.twig', [
|
|
|
|
|