Browse Source

remove page attribute from url sef routing

main
ghost 1 year ago
parent
commit
d2cb66f51d
  1. 11
      src/Controller/TorrentController.php
  2. 24
      src/Controller/UserController.php

11
src/Controller/TorrentController.php

@ -17,16 +17,11 @@ class TorrentController extends AbstractController @@ -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 @@ -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 @@ -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' =>

24
src/Controller/UserController.php

@ -39,23 +39,14 @@ class UserController extends AbstractController @@ -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 @@ -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 @@ -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 @@ -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 @@ -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',

Loading…
Cancel
Save