@@ -10,16 +10,16 @@ |
||
10 | 10 | class NotificationService |
11 | 11 | { |
12 | 12 | |
13 | - public function __construct( |
|
13 | + public function __construct( |
|
14 | 14 | private EntityManagerInterface $manager, |
15 | 15 | private Security $security, |
16 | 16 | private RequestStack $requestStack, |
17 | 17 | private PusherService $pusher |
18 | - ) { |
|
19 | - } |
|
18 | + ) { |
|
19 | + } |
|
20 | 20 | |
21 | - public function postPersist(Notification $notification) |
|
22 | - { |
|
21 | + public function postPersist(Notification $notification) |
|
22 | + { |
|
23 | 23 | $this->pusher->push(['company' => 1, 'people' => 1], 'my_topic'); |
24 | - } |
|
24 | + } |
|
25 | 25 | } |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | public function persist(&$entity) |
49 | 49 | { |
50 | - if (self::$persisted == true) |
|
51 | - return; |
|
50 | + if (self::$persisted == true) { |
|
51 | + return; |
|
52 | + } |
|
52 | 53 | self::$persisted = true; |
53 | 54 | |
54 | 55 | //$this->manager->persist($entity); |
@@ -67,15 +68,17 @@ discard block |
||
67 | 68 | } else { |
68 | 69 | $json = json_decode($this->request->getContent(), true); |
69 | 70 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
70 | - if (!$extra_data) |
|
71 | - return; |
|
71 | + if (!$extra_data) { |
|
72 | + return; |
|
73 | + } |
|
72 | 74 | $entity_id = $extra_data['entity_id']; |
73 | 75 | $entity_name = $extra_data['entity_name']; |
74 | 76 | } |
75 | 77 | |
76 | 78 | |
77 | - if (!$entity_id || !$entity_name) |
|
78 | - return; |
|
79 | + if (!$entity_id || !$entity_name) { |
|
80 | + return; |
|
81 | + } |
|
79 | 82 | |
80 | 83 | foreach ($extra_data['data'] as $key => $data) { |
81 | 84 | $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key); |
@@ -86,8 +89,9 @@ discard block |
||
86 | 89 | 'extra_fields' => $extra_fields |
87 | 90 | ]); |
88 | 91 | |
89 | - if (!$extraData) |
|
90 | - $extraData = new ExtraData(); |
|
92 | + if (!$extraData) { |
|
93 | + $extraData = new ExtraData(); |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $extraData->setExtraFields($extra_fields); |
93 | 97 | $extraData->setEntityName($entity_name); |
@@ -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; |
@@ -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 | } |
@@ -26,13 +26,13 @@ |
||
26 | 26 | public function getConfig(People $people, $key, $json = false) |
27 | 27 | { |
28 | 28 | $config = $this->discoveryConfig($people, $key, false); |
29 | - $value = $config ? $config->getConfigValue() : null; |
|
29 | + $value = $config ? $config->getConfigValue() : null; |
|
30 | 30 | return $json ? json_decode($value, true) : $value; |
31 | 31 | } |
32 | 32 | |
33 | 33 | private function discoveryConfig(People $people, $key, $create = true): ?Config |
34 | 34 | { |
35 | - $config = $this->manager->getRepository(Config::class)->findOneBy([ |
|
35 | + $config = $this->manager->getRepository(Config::class)->findOneBy([ |
|
36 | 36 | 'people' => $people, |
37 | 37 | 'configKey' => $key |
38 | 38 | ]); |
@@ -36,8 +36,9 @@ |
||
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); |
@@ -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(preg_replace("/[^0-9]/", "", $json['people'])); |
|
33 | - $module = $this->manager->getRepository(Module::class)->find(preg_replace("/[^0-9]/", "", $json['module'])); |
|
34 | - $configValue = json_decode($json['configValue'], true); |
|
35 | - $config = $this->configService->addConfig( |
|
31 | + $json = json_decode($request->getContent(), true); |
|
32 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
33 | + $module = $this->manager->getRepository(Module::class)->find(preg_replace("/[^0-9]/", "", $json['module'])); |
|
34 | + $configValue = json_decode($json['configValue'], true); |
|
35 | + $config = $this->configService->addConfig( |
|
36 | 36 | $people, |
37 | 37 | $json['configKey'], |
38 | 38 | $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 | } |
@@ -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; |
@@ -37,10 +37,10 @@ |
||
37 | 37 | 'device' => $json['device'] |
38 | 38 | ]); |
39 | 39 | if (!$device) |
40 | - $device = new Device(); |
|
40 | + $device = new Device(); |
|
41 | 41 | |
42 | 42 | foreach ($configs as $key => $config) |
43 | - $device->addConfigs($key, $config); |
|
43 | + $device->addConfigs($key, $config); |
|
44 | 44 | $device->setPeople($people); |
45 | 45 | $device->setDevice($json['device']); |
46 | 46 |
@@ -36,11 +36,13 @@ |
||
36 | 36 | 'people' => $people, |
37 | 37 | 'device' => $json['device'] |
38 | 38 | ]); |
39 | - if (!$device) |
|
40 | - $device = new Device(); |
|
39 | + if (!$device) { |
|
40 | + $device = new Device(); |
|
41 | + } |
|
41 | 42 | |
42 | - foreach ($configs as $key => $config) |
|
43 | - $device->addConfigs($key, $config); |
|
43 | + foreach ($configs as $key => $config) { |
|
44 | + $device->addConfigs($key, $config); |
|
45 | + } |
|
44 | 46 | $device->setPeople($people); |
45 | 47 | $device->setDevice($json['device']); |
46 | 48 |
@@ -17,38 +17,38 @@ |
||
17 | 17 | |
18 | 18 | class AddDeviceConfigAction |
19 | 19 | { |
20 | - public function __construct( |
|
20 | + public function __construct( |
|
21 | 21 | private Security $security, |
22 | 22 | private EntityManagerInterface $manager, |
23 | 23 | private ConfigService $configService, |
24 | 24 | private HydratorService $hydratorService |
25 | - ) {} |
|
25 | + ) {} |
|
26 | 26 | |
27 | - public function __invoke(Request $request): JsonResponse |
|
28 | - { |
|
27 | + public function __invoke(Request $request): JsonResponse |
|
28 | + { |
|
29 | 29 | try { |
30 | - $json = json_decode($request->getContent(), true); |
|
31 | - $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
32 | - $configs = json_decode($json['configs'], true); |
|
33 | - $device = $this->manager->getRepository(Device::class)->findOneBy([ |
|
30 | + $json = json_decode($request->getContent(), true); |
|
31 | + $people = $this->manager->getRepository(People::class)->find(preg_replace("/[^0-9]/", "", $json['people'])); |
|
32 | + $configs = json_decode($json['configs'], true); |
|
33 | + $device = $this->manager->getRepository(Device::class)->findOneBy([ |
|
34 | 34 | 'people' => $people, |
35 | 35 | 'device' => $json['device'] |
36 | - ]); |
|
37 | - if (!$device) |
|
36 | + ]); |
|
37 | + if (!$device) |
|
38 | 38 | $device = new Device(); |
39 | 39 | |
40 | - foreach ($configs as $key => $config) |
|
40 | + foreach ($configs as $key => $config) |
|
41 | 41 | $device->addConfigs($key, $config); |
42 | - $device->setPeople($people); |
|
43 | - $device->setDevice($json['device']); |
|
42 | + $device->setPeople($people); |
|
43 | + $device->setDevice($json['device']); |
|
44 | 44 | |
45 | - $this->manager->persist($device); |
|
46 | - $this->manager->flush(); |
|
45 | + $this->manager->persist($device); |
|
46 | + $this->manager->flush(); |
|
47 | 47 | |
48 | 48 | |
49 | - return new JsonResponse($this->hydratorService->item(Device::class, $device->getId(), "device:read"), Response::HTTP_OK); |
|
49 | + return new JsonResponse($this->hydratorService->item(Device::class, $device->getId(), "device:read"), Response::HTTP_OK); |
|
50 | 50 | } catch (Exception $e) { |
51 | - return new JsonResponse($this->hydratorService->error($e)); |
|
51 | + return new JsonResponse($this->hydratorService->error($e)); |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | } |
@@ -32,17 +32,20 @@ discard block |
||
32 | 32 | foreach ($order->getOrderProducts() as $orderProduct) { |
33 | 33 | $queueEntries = $orderProduct->getOrderProductQueues(); |
34 | 34 | if ($queueEntries->isEmpty()) { |
35 | - if (!isset($queues[$this->noQueue])) |
|
36 | - $queues[$this->noQueue] = []; |
|
35 | + if (!isset($queues[$this->noQueue])) { |
|
36 | + $queues[$this->noQueue] = []; |
|
37 | + } |
|
37 | 38 | $queues[$this->noQueue][] = $orderProduct; |
38 | - } else |
|
39 | - foreach ($queueEntries as $queueEntry) { |
|
39 | + } else { |
|
40 | + foreach ($queueEntries as $queueEntry) { |
|
40 | 41 | $queue = $queueEntry->getQueue(); |
42 | + } |
|
41 | 43 | $queueName = $queue ? $queue->getQueue() : $this->noQueue; |
42 | 44 | |
43 | 45 | |
44 | - if (!isset($queues[$queueName])) |
|
45 | - $queues[$queueName] = []; |
|
46 | + if (!isset($queues[$queueName])) { |
|
47 | + $queues[$queueName] = []; |
|
48 | + } |
|
46 | 49 | |
47 | 50 | $queues[$queueName][] = $orderProduct; |
48 | 51 | } |
@@ -85,8 +88,9 @@ discard block |
||
85 | 88 | |
86 | 89 | foreach ($productGroupProducts as $pgp) { |
87 | 90 | $childProduct = $pgp->getProductChild(); |
88 | - if ($childProduct) |
|
89 | - $this->addLine(" - " . $childProduct->getProduct() . " (" . $pgp->getQuantity() . " " . $childProduct->getProductUnit()->getProductUnit() . ")"); |
|
91 | + if ($childProduct) { |
|
92 | + $this->addLine(" - " . $childProduct->getProduct() . " (" . $pgp->getQuantity() . " " . $childProduct->getProductUnit()->getProductUnit() . ")"); |
|
93 | + } |
|
90 | 94 | } |
91 | 95 | } |
92 | 96 | } |
@@ -96,12 +100,13 @@ discard block |
||
96 | 100 | $this->addLine('', '', '-'); |
97 | 101 | |
98 | 102 | |
99 | - if ($deviceType === 'cielo') |
|
100 | - return [ |
|
103 | + if ($deviceType === 'cielo') { |
|
104 | + return [ |
|
101 | 105 | "operation" => "PRINT_TEXT", |
102 | 106 | "styles" => [[]], |
103 | 107 | "value" => [$this->text] |
104 | 108 | ]; |
109 | + } |
|
105 | 110 | } |
106 | 111 | |
107 | 112 | throw new Exception("Unsupported print type", 1); |