|
15 | 15 |
|
16 | 16 | final readonly class CoursesGetController
|
17 | 17 | {
|
18 |
| - public function __construct(private QueryBus $queryBus) {} |
19 |
| - |
20 |
| - public function __invoke(Request $request): JsonResponse |
21 |
| - { |
22 |
| - $orderBy = $request->query->get('order_by'); |
23 |
| - $order = $request->query->get('order'); |
24 |
| - $limit = $request->query->get('limit'); |
25 |
| - $offset = $request->query->get('offset'); |
26 |
| - |
27 |
| - /** @var BackofficeCoursesResponse $response */ |
28 |
| - $response = $this->queryBus->ask( |
29 |
| - new SearchBackofficeCoursesByCriteriaQuery( |
30 |
| - (array) $request->query->get('filters'), |
31 |
| - $orderBy, |
32 |
| - $order, |
33 |
| - $limit === null ? null : (int) $limit, |
34 |
| - $offset === null ? null : (int) $offset |
35 |
| - ) |
36 |
| - ); |
37 |
| - |
38 |
| - return new JsonResponse( |
39 |
| - map( |
40 |
| - fn (BackofficeCourseResponse $course): array => [ |
41 |
| - 'id' => $course->id(), |
42 |
| - 'name' => $course->name(), |
43 |
| - 'duration' => $course->duration(), |
44 |
| - ], |
45 |
| - $response->courses() |
46 |
| - ), |
47 |
| - 200, |
48 |
| - ['Access-Control-Allow-Origin' => '*'] |
49 |
| - ); |
50 |
| - } |
| 18 | + public function __construct(private QueryBus $queryBus) {} |
| 19 | + |
| 20 | + public function __invoke(Request $request): JsonResponse |
| 21 | + { |
| 22 | + $orderBy = $request->query->get('order_by'); |
| 23 | + $order = $request->query->get('order'); |
| 24 | + $limit = $request->query->get('limit'); |
| 25 | + $offset = $request->query->get('offset'); |
| 26 | + |
| 27 | + /** @var BackofficeCoursesResponse $response */ |
| 28 | + $response = $this->queryBus->ask( |
| 29 | + new SearchBackofficeCoursesByCriteriaQuery( |
| 30 | + (array) $request->query->get('filters'), |
| 31 | + $orderBy, |
| 32 | + $order, |
| 33 | + $limit === null ? null : (int) $limit, |
| 34 | + $offset === null ? null : (int) $offset |
| 35 | + ) |
| 36 | + ); |
| 37 | + |
| 38 | + return new JsonResponse( |
| 39 | + map( |
| 40 | + fn (BackofficeCourseResponse $course): array => [ |
| 41 | + 'id' => $course->id(), |
| 42 | + 'name' => $course->name(), |
| 43 | + 'duration' => $course->duration(), |
| 44 | + ], |
| 45 | + $response->courses() |
| 46 | + ), |
| 47 | + 200, |
| 48 | + ['Access-Control-Allow-Origin' => '*'] |
| 49 | + ); |
| 50 | + } |
51 | 51 | }
|
0 commit comments