-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathReportController.php
More file actions
39 lines (31 loc) · 1020 Bytes
/
ReportController.php
File metadata and controls
39 lines (31 loc) · 1020 Bytes
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\ActivityPub;
use App\Controller\AbstractController;
use App\Entity\Report;
use App\Factory\ActivityPub\FlagFactory;
use GraphQL\Exception\ArgumentException;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ReportController extends AbstractController
{
public function __construct(
private readonly FlagFactory $factory,
) {
}
public function __invoke(
#[MapEntity(mapping: ['report_id' => 'uuid'])]
Report $report,
Request $request,
): Response {
if (!$report) {
throw new ArgumentException('there is no such report');
}
$json = $this->factory->build($report);
$response = new JsonResponse($json);
$response->headers->set('Content-Type', 'application/activity+json');
return $response;
}
}