@@ -64,7 +64,7 @@ |
||
64 | 64 | |
65 | 65 | //$this->manager->persist($entity); |
66 | 66 | } else { |
67 | - $json = json_decode($this->request->getContent(), true); |
|
67 | + $json = json_decode($this->request->getContent(), true); |
|
68 | 68 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
69 | 69 | if (!$extra_data) |
70 | 70 | return; |
@@ -36,12 +36,15 @@ discard block |
||
36 | 36 | |
37 | 37 | public function discoveryDevice(&$entity) |
38 | 38 | { |
39 | - if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) |
|
40 | - return; |
|
39 | + if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) { |
|
40 | + return; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | $deviceId = $this->request->headers->get('DEVICE') ?: $this->getUserIp(); |
43 | 44 | if (method_exists($entity, 'setDevice')) { |
44 | - if ($entity->getDevice()) return; |
|
45 | + if ($entity->getDevice()) { |
|
46 | + return; |
|
47 | + } |
|
45 | 48 | $device = $this->deviceService->discoveryDevice($deviceId); |
46 | 49 | $entity->setDevice($device); |
47 | 50 | } |
@@ -49,14 +52,16 @@ discard block |
||
49 | 52 | |
50 | 53 | public function discoveryUser(&$entity) |
51 | 54 | { |
52 | - if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken()) |
|
53 | - $entity->setUser($this->security->getToken()->getUser()); |
|
55 | + if (method_exists($entity, 'setUser') && !$entity->getUser() && $this->security->getToken()) { |
|
56 | + $entity->setUser($this->security->getToken()->getUser()); |
|
57 | + } |
|
54 | 58 | } |
55 | 59 | |
56 | 60 | public function persist(&$entity) |
57 | 61 | { |
58 | - if (self::$persisted == true) |
|
59 | - return; |
|
62 | + if (self::$persisted == true) { |
|
63 | + return; |
|
64 | + } |
|
60 | 65 | self::$persisted = true; |
61 | 66 | |
62 | 67 | //$this->manager->persist($entity); |
@@ -74,15 +79,17 @@ discard block |
||
74 | 79 | } else { |
75 | 80 | $json = json_decode($this->request->getContent(), true); |
76 | 81 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
77 | - if (!$extra_data) |
|
78 | - return; |
|
82 | + if (!$extra_data) { |
|
83 | + return; |
|
84 | + } |
|
79 | 85 | $entity_id = $extra_data['entity_id']; |
80 | 86 | $entity_name = $extra_data['entity_name']; |
81 | 87 | } |
82 | 88 | |
83 | 89 | |
84 | - if (!$entity_id || !$entity_name) |
|
85 | - return; |
|
90 | + if (!$entity_id || !$entity_name) { |
|
91 | + return; |
|
92 | + } |
|
86 | 93 | |
87 | 94 | foreach ($extra_data['data'] as $key => $data) { |
88 | 95 | $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key); |
@@ -93,8 +100,9 @@ discard block |
||
93 | 100 | 'extra_fields' => $extra_fields |
94 | 101 | ]); |
95 | 102 | |
96 | - if (!$extraData) |
|
97 | - $extraData = new ExtraData(); |
|
103 | + if (!$extraData) { |
|
104 | + $extraData = new ExtraData(); |
|
105 | + } |
|
98 | 106 | |
99 | 107 | $extraData->setExtraFields($extra_fields); |
100 | 108 | $extraData->setEntityName($entity_name); |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class ModuleRepository extends ServiceEntityRepository |
16 | 16 | { |
17 | - public function __construct(ManagerRegistry $registry) |
|
18 | - { |
|
17 | + public function __construct(ManagerRegistry $registry) |
|
18 | + { |
|
19 | 19 | parent::__construct($registry, Module::class); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -54,8 +54,9 @@ |
||
54 | 54 | if (method_exists($service, $method)) { |
55 | 55 | $newEntity = $service->$method($entity); |
56 | 56 | |
57 | - if ('postPersist' === $method && $newEntity) |
|
58 | - $this->manager->refresh($newEntity); |
|
57 | + if ('postPersist' === $method && $newEntity) { |
|
58 | + $this->manager->refresh($newEntity); |
|
59 | + } |
|
59 | 60 | } |
60 | 61 | } |
61 | 62 | return $entity; |
@@ -13,22 +13,22 @@ |
||
13 | 13 | |
14 | 14 | class DiscoveryMainConfigsAction |
15 | 15 | { |
16 | - public function __construct( |
|
16 | + public function __construct( |
|
17 | 17 | private EntityManagerInterface $manager, |
18 | 18 | private HydratorService $hydratorService, |
19 | 19 | private ConfigService $configService |
20 | - ) {} |
|
20 | + ) {} |
|
21 | 21 | |
22 | - public function __invoke(Request $request): JsonResponse |
|
23 | - { |
|
22 | + public function __invoke(Request $request): JsonResponse |
|
23 | + { |
|
24 | 24 | try { |
25 | - $json = json_decode($request->getContent(), true); |
|
26 | - $device = $this->manager->getRepository(People::class)->findOneBy(['device' => $request->headers->get('device')]); |
|
27 | - $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
28 | - $configs = $this->configService->discoveryMainConfigs($people, $device); |
|
29 | - return new JsonResponse($this->hydratorService->collectionData($configs, Config::class, 'config:read')); |
|
25 | + $json = json_decode($request->getContent(), true); |
|
26 | + $device = $this->manager->getRepository(People::class)->findOneBy(['device' => $request->headers->get('device')]); |
|
27 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
28 | + $configs = $this->configService->discoveryMainConfigs($people, $device); |
|
29 | + return new JsonResponse($this->hydratorService->collectionData($configs, Config::class, 'config:read')); |
|
30 | 30 | } catch (Exception $e) { |
31 | - return new JsonResponse($this->hydratorService->error($e)); |
|
31 | + return new JsonResponse($this->hydratorService->error($e)); |
|
32 | + } |
|
32 | 33 | } |
33 | - } |
|
34 | 34 | } |
@@ -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 | } |
@@ -51,9 +51,9 @@ |
||
51 | 51 | { |
52 | 52 | $device = $this->discoveryDevice($deviceId); |
53 | 53 | |
54 | - $device_config = $this->discoveryDeviceConfig($device, $people); |
|
54 | + $device_config = $this->discoveryDeviceConfig($device, $people); |
|
55 | 55 | foreach ($configs as $key => $config) |
56 | - $device_config->addConfig($key, $config); |
|
56 | + $device_config->addConfig($key, $config); |
|
57 | 57 | |
58 | 58 | $this->manager->persist($device_config); |
59 | 59 | $this->manager->flush(); |
@@ -22,8 +22,9 @@ discard block |
||
22 | 22 | $devices = []; |
23 | 23 | foreach ($device_configs as $device_config) { |
24 | 24 | $configs = $device_config->getConfigs(true); |
25 | - if (isset($configs['pos-gateway']) && $configs['pos-gateway'] == 'cielo') |
|
26 | - $devices[] = $device_config->getDevice(); |
|
25 | + if (isset($configs['pos-gateway']) && $configs['pos-gateway'] == 'cielo') { |
|
26 | + $devices[] = $device_config->getDevice(); |
|
27 | + } |
|
27 | 28 | } |
28 | 29 | return $devices; |
29 | 30 | } |
@@ -64,8 +65,9 @@ discard block |
||
64 | 65 | $device = $this->discoveryDevice($deviceId); |
65 | 66 | |
66 | 67 | $device_config = $this->discoveryDeviceConfig($device, $people); |
67 | - foreach ($configs as $key => $config) |
|
68 | - $device_config->addConfig($key, $config); |
|
68 | + foreach ($configs as $key => $config) { |
|
69 | + $device_config->addConfig($key, $config); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | $this->manager->persist($device_config); |
71 | 73 | $this->manager->flush(); |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | public function getConfig(People $people, $key, $json = false) |
20 | 20 | { |
21 | 21 | $config = $this->discoveryConfig($people, $key, false); |
22 | - $value = $config ? $config->getConfigValue() : null; |
|
22 | + $value = $config ? $config->getConfigValue() : null; |
|
23 | 23 | return $json ? json_decode($value, true) : $value; |
24 | 24 | } |
25 | 25 | |
26 | 26 | private function discoveryConfig(People $people, $key, $create = true): ?Config |
27 | 27 | { |
28 | - $config = $this->manager->getRepository(Config::class)->findOneBy([ |
|
28 | + $config = $this->manager->getRepository(Config::class)->findOneBy([ |
|
29 | 29 | 'people' => $people, |
30 | 30 | 'configKey' => $key |
31 | 31 | ]); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | private function discoveryInfinitePayWallet(People $company) |
151 | 151 | { |
152 | - $paymentTypes = [ |
|
152 | + $paymentTypes = [ |
|
153 | 153 | [ |
154 | 154 | 'paymentType' => 'Débito', |
155 | 155 | 'frequency' => 'single', |
@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | 'people' => $people, |
30 | 30 | 'configKey' => $key |
31 | 31 | ]); |
32 | - if ($config) |
|
33 | - return $config; |
|
32 | + if ($config) { |
|
33 | + return $config; |
|
34 | + } |
|
34 | 35 | if ($create) { |
35 | 36 | $config = new Config(); |
36 | 37 | $config->setConfigKey($key); |
@@ -108,12 +109,13 @@ discard block |
||
108 | 109 | 'private' |
109 | 110 | ); |
110 | 111 | |
111 | - foreach ($paymentTypes as $paymentType) |
|
112 | - $this->walletService->discoverWalletPaymentType( |
|
112 | + foreach ($paymentTypes as $paymentType) { |
|
113 | + $this->walletService->discoverWalletPaymentType( |
|
113 | 114 | $wallet, |
114 | 115 | $this->walletService->discoverPaymentType($company, $paymentType), |
115 | 116 | $paymentType['paymentCode'] |
116 | 117 | ); |
118 | + } |
|
117 | 119 | } |
118 | 120 | |
119 | 121 | private function discoveryWithdrawlWallet(People $company) |
@@ -139,12 +141,13 @@ discard block |
||
139 | 141 | $module, |
140 | 142 | 'private' |
141 | 143 | ); |
142 | - foreach ($paymentTypes as $paymentType) |
|
143 | - $this->walletService->discoverWalletPaymentType( |
|
144 | + foreach ($paymentTypes as $paymentType) { |
|
145 | + $this->walletService->discoverWalletPaymentType( |
|
144 | 146 | $wallet, |
145 | 147 | $this->walletService->discoverPaymentType($company, $paymentType), |
146 | 148 | $paymentType['paymentCode'] |
147 | 149 | ); |
150 | + } |
|
148 | 151 | } |
149 | 152 | |
150 | 153 | private function discoveryInfinitePayWallet(People $company) |
@@ -184,12 +187,13 @@ discard block |
||
184 | 187 | 'private' |
185 | 188 | ); |
186 | 189 | |
187 | - foreach ($paymentTypes as $paymentType) |
|
188 | - $this->walletService->discoverWalletPaymentType( |
|
190 | + foreach ($paymentTypes as $paymentType) { |
|
191 | + $this->walletService->discoverWalletPaymentType( |
|
189 | 192 | $wallet, |
190 | 193 | $this->walletService->discoverPaymentType($company, $paymentType), |
191 | 194 | $paymentType['paymentCode'] |
192 | 195 | ); |
196 | + } |
|
193 | 197 | } |
194 | 198 | |
195 | 199 | private function discoveryCieloWallet(People $company) |
@@ -261,11 +265,12 @@ discard block |
||
261 | 265 | 'private' |
262 | 266 | ); |
263 | 267 | |
264 | - foreach ($paymentTypes as $paymentType) |
|
265 | - $this->walletService->discoverWalletPaymentType( |
|
268 | + foreach ($paymentTypes as $paymentType) { |
|
269 | + $this->walletService->discoverWalletPaymentType( |
|
266 | 270 | $wallet, |
267 | 271 | $this->walletService->discoverPaymentType($company, $paymentType), |
268 | 272 | $paymentType['paymentCode'] |
269 | 273 | ); |
274 | + } |
|
270 | 275 | } |
271 | 276 | } |
@@ -6,21 +6,21 @@ |
||
6 | 6 | use Doctrine\ORM\EntityManagerInterface; |
7 | 7 | use Symfony\Component\HttpFoundation\RequestStack; |
8 | 8 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
9 | - AS Security; |
|
9 | + AS Security; |
|
10 | 10 | |
11 | 11 | class NotificationService |
12 | 12 | { |
13 | 13 | |
14 | - public function __construct( |
|
14 | + public function __construct( |
|
15 | 15 | private EntityManagerInterface $manager, |
16 | 16 | private Security $security, |
17 | 17 | private RequestStack $requestStack, |
18 | 18 | private PusherService $pusher |
19 | - ) { |
|
20 | - } |
|
19 | + ) { |
|
20 | + } |
|
21 | 21 | |
22 | - public function postPersist(Notification $notification) |
|
23 | - { |
|
22 | + public function postPersist(Notification $notification) |
|
23 | + { |
|
24 | 24 | $this->pusher->push(['company' => 1, 'people' => 1], 'my_topic'); |
25 | - } |
|
25 | + } |
|
26 | 26 | } |
@@ -13,37 +13,37 @@ |
||
13 | 13 | use Exception; |
14 | 14 | use Symfony\Component\HttpFoundation\JsonResponse; |
15 | 15 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
16 | - AS Security; |
|
16 | + AS Security; |
|
17 | 17 | |
18 | 18 | |
19 | 19 | |
20 | 20 | class AddAppConfigAction |
21 | 21 | { |
22 | - public function __construct( |
|
22 | + public function __construct( |
|
23 | 23 | private Security $security, |
24 | 24 | private EntityManagerInterface $manager, |
25 | 25 | private ConfigService $configService, |
26 | 26 | private HydratorService $hydratorService |
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 | - $module = $this->manager->getRepository(Module::class)->find(preg_replace("/[^0-9]/", "", $json['module'])); |
|
35 | - $configValue = json_decode($json['configValue'], true); |
|
36 | - $config = $this->configService->addConfig( |
|
32 | + $json = json_decode($request->getContent(), true); |
|
33 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
34 | + $module = $this->manager->getRepository(Module::class)->find(preg_replace("/[^0-9]/", "", $json['module'])); |
|
35 | + $configValue = json_decode($json['configValue'], true); |
|
36 | + $config = $this->configService->addConfig( |
|
37 | 37 | $people, |
38 | 38 | $json['configKey'], |
39 | 39 | $configValue, |
40 | 40 | $module, |
41 | 41 | $json['visibility'] |
42 | - ); |
|
42 | + ); |
|
43 | 43 | |
44 | - return new JsonResponse($this->hydratorService->item(Config::class, $config->getId(), "config:read"), Response::HTTP_OK); |
|
44 | + return new JsonResponse($this->hydratorService->item(Config::class, $config->getId(), "config:read"), Response::HTTP_OK); |
|
45 | 45 | } catch (Exception $e) { |
46 | - return new JsonResponse($this->hydratorService->error($e)); |
|
46 | + return new JsonResponse($this->hydratorService->error($e)); |
|
47 | + } |
|
47 | 48 | } |
48 | - } |
|
49 | 49 | } |