@@ -18,31 +18,31 @@ |
||
18 | 18 | |
19 | 19 | class AddAppConfigAction |
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 | + ) {} |
|
27 | 27 | |
28 | - public function __invoke(Request $request): JsonResponse |
|
29 | - { |
|
28 | + public function __invoke(Request $request): JsonResponse |
|
29 | + { |
|
30 | 30 | try { |
31 | - $json = json_decode($request->getContent(), true); |
|
32 | - $people = $this->manager->getRepository(People::class)->find($json['people']); |
|
33 | - $module = $this->manager->getRepository(Module::class)->find($json['module']); |
|
31 | + $json = json_decode($request->getContent(), true); |
|
32 | + $people = $this->manager->getRepository(People::class)->find($json['people']); |
|
33 | + $module = $this->manager->getRepository(Module::class)->find($json['module']); |
|
34 | 34 | |
35 | - $config = $this->configService->addConfig( |
|
35 | + $config = $this->configService->addConfig( |
|
36 | 36 | $people, |
37 | 37 | $json['configKey'], |
38 | 38 | $json['configValue'], |
39 | 39 | $module, |
40 | 40 | $json['visibility'] |
41 | - ); |
|
41 | + ); |
|
42 | 42 | |
43 | - return new JsonResponse($this->hydratorService->item(Config::class, $config->getId(), "config:read"), Response::HTTP_OK); |
|
43 | + return new JsonResponse($this->hydratorService->item(Config::class, $config->getId(), "config:read"), Response::HTTP_OK); |
|
44 | 44 | } catch (Exception $e) { |
45 | - return new JsonResponse($this->hydratorService->error($e)); |
|
45 | + return new JsonResponse($this->hydratorService->error($e)); |
|
46 | + } |
|
46 | 47 | } |
47 | - } |
|
48 | 48 | } |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | 'people' => $people, |
37 | 37 | 'configKey' => $key |
38 | 38 | ]); |
39 | - if ($config) |
|
40 | - return $config; |
|
39 | + if ($config) { |
|
40 | + return $config; |
|
41 | + } |
|
41 | 42 | if ($create) { |
42 | 43 | $config = new Config(); |
43 | 44 | $config->setConfigKey($key); |
@@ -55,14 +56,16 @@ discard block |
||
55 | 56 | ) { |
56 | 57 | $config = $this->discoveryConfig($people, $key); |
57 | 58 | $newValue = json_decode($config->getConfigValue()) || []; |
58 | - if (!is_array($newValue)) |
|
59 | - $newValue = [$newValue]; |
|
59 | + if (!is_array($newValue)) { |
|
60 | + $newValue = [$newValue]; |
|
61 | + } |
|
60 | 62 | |
61 | - if (is_array($values)) |
|
62 | - foreach ($values as $key => $value) |
|
63 | + if (is_array($values)) { |
|
64 | + foreach ($values as $key => $value) |
|
63 | 65 | $newValue[$key] = $value; |
64 | - else |
|
65 | - $newValue[] = $values; |
|
66 | + } else { |
|
67 | + $newValue[] = $values; |
|
68 | + } |
|
66 | 69 | |
67 | 70 | $config->setConfigValue(json_encode($newValue)); |
68 | 71 | $config->setVisibility($visibility); |