Skip to content

Commit 701f9d0

Browse files
committed
feature #1448 303 redirections (Arkounay)
This PR was merged into the main branch. Discussion ---------- 303 redirections This PR provides 303 redirections, see issue #1433 Commits ------- bc55637 303 redirections #1433
2 parents a3e22b2 + bc55637 commit 701f9d0

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/Controller/Admin/BlogController.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ public function new(
103103
$submit = $form->get('saveAndCreateNew');
104104

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

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

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

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

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

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

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

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

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

src/Controller/BlogController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function commentNew(
129129
// See https://symfony.com/doc/current/messenger.html
130130
$eventDispatcher->dispatch(new CommentCreatedEvent($comment));
131131

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

135135
return $this->render('blog/comment_form_error.html.twig', [

src/Controller/UserController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function edit(
4848

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

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

5454
return $this->render('user/edit.html.twig', [

tests/Controller/Admin/BlogControllerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testAdminNewPost(): void
105105
'post[content]' => $postContent,
106106
]);
107107

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

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

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

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

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

188188
/** @var PostRepository $postRepository */
189189
$postRepository = static::getContainer()->get(PostRepository::class);

tests/Controller/UserControllerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testEditUser(): void
7373
'user[email]' => $newUserEmail,
7474
]);
7575

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

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

0 commit comments

Comments
 (0)