mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
implement events pagination
This commit is contained in:
parent
cc6c68957c
commit
995d4bde54
10 changed files with 388 additions and 22 deletions
|
|
@ -17,11 +17,16 @@ class TorrentController extends AbstractController
|
|||
{
|
||||
// Torrent
|
||||
#[Route(
|
||||
'/{_locale}/torrent/{torrentId}',
|
||||
'/{_locale}/torrent/{torrentId}/{page}',
|
||||
name: 'torrent_info',
|
||||
requirements:
|
||||
[
|
||||
'torrentId' => '\d+'
|
||||
'torrentId' => '\d+',
|
||||
'page' => '\d+',
|
||||
],
|
||||
defaults:
|
||||
[
|
||||
'page' => 1,
|
||||
],
|
||||
methods:
|
||||
[
|
||||
|
|
@ -29,6 +34,7 @@ class TorrentController extends AbstractController
|
|||
]
|
||||
)]
|
||||
public function info(
|
||||
int $page,
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
|
|
@ -82,6 +88,12 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
// Get total activities
|
||||
$total = $activityService->findActivitiesTotalByTorrentId(
|
||||
$torrent->getId(),
|
||||
$user->getEvents()
|
||||
);
|
||||
|
||||
// Render template
|
||||
return $this->render('default/torrent/info.html.twig', [
|
||||
'torrent' =>
|
||||
|
|
@ -166,6 +178,18 @@ class TorrentController extends AbstractController
|
|||
// 'magnet' => $file->getMagnetLink()
|
||||
],
|
||||
'trackers' => explode('|', $this->getParameter('app.trackers')),
|
||||
'activities' => $activityService->findLastActivitiesByTorrentId(
|
||||
$torrent->getId(),
|
||||
$user->getEvents(),
|
||||
$this->getParameter('app.pagination'),
|
||||
($page - 1) * $this->getParameter('app.pagination')
|
||||
),
|
||||
'pagination' =>
|
||||
[
|
||||
'page' => $page,
|
||||
'pages' => ceil($total / $this->getParameter('app.pagination')),
|
||||
'total' => $total
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue