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