-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathCoursesCounterGetController.php
More file actions
36 lines (30 loc) · 916 Bytes
/
CoursesCounterGetController.php
File metadata and controls
36 lines (30 loc) · 916 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
<?php
declare(strict_types=1);
namespace CodelyTv\Apps\Mooc\Backend\Controller\CoursesCounter;
use CodelyTv\Mooc\CoursesCounter\Application\Find\CoursesCounterResponse;
use CodelyTv\Mooc\CoursesCounter\Application\Find\FindCoursesCounterQuery;
use CodelyTv\Mooc\CoursesCounter\Domain\CoursesCounterNotExist;
use CodelyTv\Shared\Infrastructure\Symfony\ApiController;
use Override;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
final class CoursesCounterGetController extends ApiController
{
public function __invoke(): JsonResponse
{
/** @var CoursesCounterResponse $response */
$response = $this->ask(new FindCoursesCounterQuery());
return new JsonResponse(
[
'total' => $response->total(),
]
);
}
#[Override]
protected function exceptions(): array
{
return [
CoursesCounterNotExist::class => Response::HTTP_NOT_FOUND,
];
}
}