-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathAdminReportController.php
More file actions
39 lines (32 loc) · 1.17 KB
/
AdminReportController.php
File metadata and controls
39 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
namespace App\Controller\Admin;
use App\Controller\AbstractController;
use App\Repository\NotificationRepository;
use App\Repository\ReportRepository;
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class AdminReportController extends AbstractController
{
public function __construct(
private readonly ReportRepository $repository,
private readonly NotificationRepository $notificationRepository,
) {
}
#[IsGranted(new Expression('is_granted("ROLE_ADMIN") or is_granted("ROLE_MODERATOR")'))]
public function __invoke(Request $request, string $status): Response
{
$page = (int) $request->get('p', 1);
//TODO rest api for this
$reports = $this->repository->findAllPaginated($page, $status);
$this->notificationRepository->markReportNotificationsAsRead($this->getUserOrThrow());
return $this->render(
'admin/reports.html.twig',
[
'reports' => $reports,
]
);
}
}