diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index 166fcab..848b595 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -17,16 +17,11 @@ class TorrentController extends AbstractController { // Torrent #[Route( - '/{_locale}/torrent/{torrentId}/{page}', + '/{_locale}/torrent/{torrentId}', name: 'torrent_info', requirements: [ 'torrentId' => '\d+', - 'page' => '\d+', - ], - defaults: - [ - 'page' => 1, ], methods: [ @@ -34,7 +29,6 @@ class TorrentController extends AbstractController ] )] public function info( - int $page, Request $request, TranslatorInterface $translator, UserService $userService, @@ -94,6 +88,9 @@ class TorrentController extends AbstractController $user->getEvents() ); + // Init page + $page = $request->get('page') ? (int) $request->get('page') : 1; + // Render template return $this->render('default/torrent/info.html.twig', [ 'torrent' => diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 5eeae8a..a4a81ad 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -39,23 +39,14 @@ class UserController extends AbstractController } #[Route( - '/{_locale}/{page}', + '/{_locale}', name: 'user_dashboard', - requirements: - [ - 'page' => '\d+', - ], - defaults: - [ - 'page' => 1, - ], methods: [ 'GET' ] )] public function index( - int $page, Request $request, UserService $userService, ActivityService $activityService @@ -71,6 +62,8 @@ class UserController extends AbstractController $user->getEvents() ); + $page = $request->get('page') ? (int) $request->get('page') : 1; + return $this->render( 'default/user/dashboard.html.twig', [ @@ -206,22 +199,18 @@ class UserController extends AbstractController } #[Route( - '/{_locale}/profile/{userId}/{page}', + '/{_locale}/profile/{userId}', name: 'user_info', defaults: [ '_locale' => '%app.locale%', 'userId' => 0, - 'page' => 1, ], requirements: [ '_locale' => '%app.locales%', 'userId' => '\d+', - 'page' => '\d+', ], )] public function info( - int $userId, - int $page, Request $request, TranslatorInterface $translator, UserService $userService, @@ -245,7 +234,7 @@ class UserController extends AbstractController // Init target user if (!$userTarget = $userService->getUser( - $userId ? $userId : $user->getId() + $request->get('userId') ? $request->get('userId') : $user->getId() )) { throw $this->createNotFoundException(); @@ -257,6 +246,9 @@ class UserController extends AbstractController $user->getEvents() ); + // Init page + $page = $request->get('page') ? (int) $request->get('page') : 1; + // Render template return $this->render( 'default/user/info.html.twig',