@@ -36,12 +36,15 @@ discard block |
||
36 | 36 | |
37 | 37 | public function discoveryDevice(&$entity) |
38 | 38 | { |
39 | - if ($entity instanceof Device || $entity instanceof DeviceConfig) |
|
40 | - return; |
|
39 | + if ($entity instanceof Device || $entity instanceof DeviceConfig) { |
|
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()) |
|
53 | - $entity->setUser($this->security->getToken()->getUser()); |
|
55 | + if (method_exists($entity, 'setUser') && !$entity->getUser()) { |
|
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); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function addLine($prefix = '', $suffix = '', $delimiter = ' ') |
27 | 27 | { |
28 | 28 | $initialSpace = str_repeat(" ", $this->initialSpace); |
29 | - $count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
|
29 | + $count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
|
30 | 30 | if ($count > 0) |
31 | 31 | $delimiter = str_repeat($delimiter, $count); |
32 | 32 | $this->text .= $initialSpace . $prefix . $delimiter . $suffix . "\n"; |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | public function generatePrintData(Device $device, People $provider): Spool |
45 | 45 | { |
46 | 46 | $printer = null; |
47 | - $device_config = $this->deviceService->discoveryDeviceConfig($device, $provider)->getConfigs(true); |
|
47 | + $device_config = $this->deviceService->discoveryDeviceConfig($device, $provider)->getConfigs(true); |
|
48 | 48 | if (isset($device_config['printer'])) |
49 | 49 | $printer = $this->deviceService->discoveryDevice($device_config['printer']); |
50 | 50 | |
51 | - $content = [ |
|
51 | + $content = [ |
|
52 | 52 | "operation" => "PRINT_TEXT", |
53 | 53 | "styles" => [[]], |
54 | 54 | "value" => [$this->text] |
@@ -27,8 +27,9 @@ discard block |
||
27 | 27 | { |
28 | 28 | $initialSpace = str_repeat(" ", $this->initialSpace); |
29 | 29 | $count = $this->totalChars - $this->initialSpace - strlen($prefix) - strlen($suffix); |
30 | - if ($count > 0) |
|
31 | - $delimiter = str_repeat($delimiter, $count); |
|
30 | + if ($count > 0) { |
|
31 | + $delimiter = str_repeat($delimiter, $count); |
|
32 | + } |
|
32 | 33 | $this->text .= $initialSpace . $prefix . $delimiter . $suffix . "\n"; |
33 | 34 | } |
34 | 35 | |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | { |
46 | 47 | $printer = null; |
47 | 48 | $device_config = $this->deviceService->discoveryDeviceConfig($device, $provider)->getConfigs(true); |
48 | - if (isset($device_config['printer'])) |
|
49 | - $printer = $this->deviceService->discoveryDevice($device_config['printer']); |
|
49 | + if (isset($device_config['printer'])) { |
|
50 | + $printer = $this->deviceService->discoveryDevice($device_config['printer']); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $content = [ |
52 | 54 | "operation" => "PRINT_TEXT", |
@@ -56,8 +58,9 @@ discard block |
||
56 | 58 | |
57 | 59 | $printData = $this->addToSpool($printer ?: $device, json_encode($content)); |
58 | 60 | |
59 | - if ($printer != $device) |
|
60 | - $x = ''; |
|
61 | + if ($printer != $device) { |
|
62 | + $x = ''; |
|
63 | + } |
|
61 | 64 | |
62 | 65 | return $printData; |
63 | 66 | } |