Commit 3d3fe131 authored by Emma's avatar Emma 🏳🌈

undo front page redirect

it's bad due to browser history/redirect-after-login stuff
parent 344e7dde
Pipeline #58719255 passed with stage
in 1 minute and 22 seconds
front:
controller: App\Controller\FrontController::front
path: /
methods: [GET]
front_sort_index:
controller: App\Controller\FrontController::front
methods: [GET]
defaults: { sortBy: ~ }
path: /{sortBy}
methods: [GET]
requirements: { sortBy: "%submission_sort_modes%" }
featured:
......
......@@ -24,15 +24,22 @@ final class FrontController extends AbstractController {
*/
private $submissions;
/**
* @var UserRepository
*/
private $users;
public function __construct(
ForumRepository $forums,
SubmissionRepository $submissions
SubmissionRepository $submissions,
UserRepository $users
) {
$this->forums = $forums;
$this->submissions = $submissions;
$this->users = $users;
}
public function front(string $sortBy = null): Response {
public function front(string $sortBy = null, Request $request): Response {
if ($this->isGranted('ROLE_USER')) {
/* @var \App\Entity\User $user */
$user = $this->getUser();
......@@ -51,14 +58,14 @@ final class FrontController extends AbstractController {
$sortBy = $sortBy ?? Submission::SORT_HOT;
}
return $this->redirectToRoute($listing, ['sortBy' => $sortBy]);
return [$this, $listing]($sortBy, $request);
}
public function featured(string $sortBy, Request $request, UserRepository $users): Response {
public function featured(string $sortBy, Request $request): Response {
$forums = $this->forums->findFeaturedForumNames();
if ($this->isGranted('ROLE_USER')) {
$excludedForums = $users->findHiddenForumIdsByUser($this->getUser());
$excludedForums = $this->users->findHiddenForumIdsByUser($this->getUser());
}
$submissions = $this->submissions->findSubmissions($sortBy, [
......@@ -77,7 +84,7 @@ final class FrontController extends AbstractController {
/**
* @IsGranted("ROLE_USER")
*/
public function subscribed(string $sortBy, Request $request, UserRepository $users): Response {
public function subscribed(string $sortBy, Request $request): Response {
$forums = $this->forums->findSubscribedForumNames($this->getUser());
if (\count($forums) === 0) {
......@@ -98,9 +105,9 @@ final class FrontController extends AbstractController {
]);
}
public function all(string $sortBy, Request $request, UserRepository $users): Response {
public function all(string $sortBy, Request $request): Response {
if ($this->isGranted('ROLE_USER')) {
$excludedForums = $users->findHiddenForumIdsByUser($this->getUser());
$excludedForums = $this->users->findHiddenForumIdsByUser($this->getUser());
}
$submissions = $this->submissions->findSubmissions($sortBy, [
......
......@@ -72,6 +72,12 @@ class ApplicationAvailabilityTest extends WebTestCase {
* database.
*/
public function publicUrlProvider() {
yield ['/'];
yield ['/hot'];
yield ['/new'];
yield ['/top'];
yield ['/controversial'];
yield ['/most_commented'];
yield ['/all/hot'];
yield ['/all/new'];
yield ['/all/top'];
......@@ -118,12 +124,6 @@ class ApplicationAvailabilityTest extends WebTestCase {
}
public function redirectUrlProvider() {
yield ['/featured', '/'];
yield ['/featured', '/hot'];
yield ['/featured/new', '/new'];
yield ['/featured/top', '/top'];
yield ['/featured/controversial', '/controversial'];
yield ['/featured/most_commented', '/most_commented'];
yield ['/f/news', '/f/NeWs/hot'];
yield ['/f/news/new', '/f/NeWs/new'];
yield ['/f/news/top', '/f/NeWs/top'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment