@@ -18,24 +18,24 @@ |
||
18 | 18 | |
19 | 19 | class AddDeviceConfigAction |
20 | 20 | { |
21 | - public function __construct( |
|
21 | + public function __construct( |
|
22 | 22 | private Security $security, |
23 | 23 | private EntityManagerInterface $manager, |
24 | 24 | private ConfigService $configService, |
25 | 25 | private HydratorService $hydratorService, |
26 | 26 | private DeviceService $deviceService |
27 | - ) {} |
|
27 | + ) {} |
|
28 | 28 | |
29 | - public function __invoke(Request $request): JsonResponse |
|
30 | - { |
|
29 | + public function __invoke(Request $request): JsonResponse |
|
30 | + { |
|
31 | 31 | try { |
32 | - $json = json_decode($request->getContent(), true); |
|
33 | - $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
34 | - $configs = json_decode($json['configs'], true); |
|
35 | - $device = $this->deviceService->addDeviceConfigs($people, $configs, $json['device']); |
|
36 | - return new JsonResponse($this->hydratorService->item(Device::class, $device->getId(), "device:read"), Response::HTTP_OK); |
|
32 | + $json = json_decode($request->getContent(), true); |
|
33 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
34 | + $configs = json_decode($json['configs'], true); |
|
35 | + $device = $this->deviceService->addDeviceConfigs($people, $configs, $json['device']); |
|
36 | + return new JsonResponse($this->hydratorService->item(Device::class, $device->getId(), "device:read"), Response::HTTP_OK); |
|
37 | 37 | } catch (Exception $e) { |
38 | - return new JsonResponse($this->hydratorService->error($e)); |
|
38 | + return new JsonResponse($this->hydratorService->error($e)); |
|
39 | + } |
|
39 | 40 | } |
40 | - } |
|
41 | 41 | } |