Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

303 redirections #1448

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Controller/Admin/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ public function new(
$submit = $form->get('saveAndCreateNew');

if ($submit->isClicked()) {
return $this->redirectToRoute('admin_post_new');
return $this->redirectToRoute('admin_post_new', [], Response::HTTP_SEE_OTHER);
}

return $this->redirectToRoute('admin_post_index');
return $this->redirectToRoute('admin_post_index', [], Response::HTTP_SEE_OTHER);
}

return $this->render('admin/blog/new.html.twig', [
Expand Down Expand Up @@ -144,7 +144,7 @@ public function edit(Request $request, Post $post, EntityManagerInterface $entit
$entityManager->flush();
$this->addFlash('success', 'post.updated_successfully');

return $this->redirectToRoute('admin_post_edit', ['id' => $post->getId()]);
return $this->redirectToRoute('admin_post_edit', ['id' => $post->getId()], Response::HTTP_SEE_OTHER);
}

return $this->render('admin/blog/edit.html.twig', [
Expand All @@ -164,7 +164,7 @@ public function delete(Request $request, Post $post, EntityManagerInterface $ent
$token = $request->request->get('token');

if (!$this->isCsrfTokenValid('delete', $token)) {
return $this->redirectToRoute('admin_post_index');
return $this->redirectToRoute('admin_post_index', [], Response::HTTP_SEE_OTHER);
}

// Delete the tags associated with this blog post. This is done automatically
Expand All @@ -177,6 +177,6 @@ public function delete(Request $request, Post $post, EntityManagerInterface $ent

$this->addFlash('success', 'post.deleted_successfully');

return $this->redirectToRoute('admin_post_index');
return $this->redirectToRoute('admin_post_index', [], Response::HTTP_SEE_OTHER);
}
}
2 changes: 1 addition & 1 deletion src/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function commentNew(
// See https://symfony.com/doc/current/messenger.html
$eventDispatcher->dispatch(new CommentCreatedEvent($comment));

return $this->redirectToRoute('blog_post', ['slug' => $post->getSlug()]);
return $this->redirectToRoute('blog_post', ['slug' => $post->getSlug()], Response::HTTP_SEE_OTHER);
}

return $this->render('blog/comment_form_error.html.twig', [
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function edit(

$this->addFlash('success', 'user.updated_successfully');

return $this->redirectToRoute('user_edit');
return $this->redirectToRoute('user_edit', [], Response::HTTP_SEE_OTHER);
}

return $this->render('user/edit.html.twig', [
Expand Down
6 changes: 3 additions & 3 deletions tests/Controller/Admin/BlogControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testAdminNewPost(): void
'post[content]' => $postContent,
]);

$this->assertResponseRedirects('/en/admin/post/', Response::HTTP_FOUND);
$this->assertResponseRedirects('/en/admin/post/', Response::HTTP_SEE_OTHER);

/** @var PostRepository $postRepository */
$postRepository = static::getContainer()->get(PostRepository::class);
Expand Down Expand Up @@ -161,7 +161,7 @@ public function testAdminEditPost(): void
'post[title]' => $newBlogPostTitle,
]);

$this->assertResponseRedirects('/en/admin/post/1/edit', Response::HTTP_FOUND);
$this->assertResponseRedirects('/en/admin/post/1/edit', Response::HTTP_SEE_OTHER);

/** @var PostRepository $postRepository */
$postRepository = static::getContainer()->get(PostRepository::class);
Expand All @@ -183,7 +183,7 @@ public function testAdminDeletePost(): void
$crawler = $this->client->request('GET', '/en/admin/post/1');
$this->client->submit($crawler->filter('#delete-form')->form());

$this->assertResponseRedirects('/en/admin/post/', Response::HTTP_FOUND);
$this->assertResponseRedirects('/en/admin/post/', Response::HTTP_SEE_OTHER);

/** @var PostRepository $postRepository */
$postRepository = static::getContainer()->get(PostRepository::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testEditUser(): void
'user[email]' => $newUserEmail,
]);

$this->assertResponseRedirects('/en/profile/edit', Response::HTTP_FOUND);
$this->assertResponseRedirects('/en/profile/edit', Response::HTTP_SEE_OTHER);

/** @var User $user */
$user = $userRepository->findOneByEmail($newUserEmail);
Expand Down