@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $class = $this->getEntityName($entity); |
48 | 48 | |
49 | - $extraData = $this->getEntityByExtraData($extraFields, $entityId, $entity); |
|
49 | + $extraData = $this->getEntityByExtraData($extraFields, $entityId, $entity); |
|
50 | 50 | if ($extraData) return $extraData; |
51 | 51 | |
52 | 52 | $extraData = new ExtraData(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return $this->manager->getRepository($class->getName())->find($extraData->getEntityId()); |
61 | 61 | } |
62 | 62 | |
63 | - public function discoveryExtraFields(string $fieldName, string $context, ?string $configs = '{}', ?string $fieldType = 'text', ?bool $required = false): ExtraFields |
|
63 | + public function discoveryExtraFields(string $fieldName, string $context, ?string $configs = '{}', ?string $fieldType = 'text', ?bool $required = false): ExtraFields |
|
64 | 64 | { |
65 | 65 | |
66 | 66 | $extraFields = $this->manager->getRepository(ExtraFields::class)->findOneBy([ |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | //$this->manager->persist($entity); |
138 | 138 | } else { |
139 | - $json = json_decode($this->request->getContent(), true); |
|
139 | + $json = json_decode($this->request->getContent(), true); |
|
140 | 140 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
141 | 141 | if (!$extra_data) |
142 | 142 | return; |
@@ -35,8 +35,9 @@ discard block |
||
35 | 35 | 'entity_name' => $class->getShortName(), |
36 | 36 | 'entity_id' => $entityId |
37 | 37 | ]); |
38 | - if ($extraData) |
|
39 | - return $this->manager->getRepository($class->getName())->find($extraData->getEntityId()); |
|
38 | + if ($extraData) { |
|
39 | + return $this->manager->getRepository($class->getName())->find($extraData->getEntityId()); |
|
40 | + } |
|
40 | 41 | |
41 | 42 | return null; |
42 | 43 | } |
@@ -47,7 +48,9 @@ discard block |
||
47 | 48 | $class = $this->getEntityName($entity); |
48 | 49 | |
49 | 50 | $extraData = $this->getEntityByExtraData($extraFields, $entityId, $entity); |
50 | - if ($extraData) return $extraData; |
|
51 | + if ($extraData) { |
|
52 | + return $extraData; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | $extraData = new ExtraData(); |
53 | 56 | $extraData->setEntityId($entityId); |
@@ -69,8 +72,9 @@ discard block |
||
69 | 72 | 'context' => $context |
70 | 73 | ]); |
71 | 74 | |
72 | - if (!$extraFields) |
|
73 | - $extraFields = new ExtraFields(); |
|
75 | + if (!$extraFields) { |
|
76 | + $extraFields = new ExtraFields(); |
|
77 | + } |
|
74 | 78 | |
75 | 79 | $extraFields->setName($fieldName); |
76 | 80 | $extraFields->setContext($context); |
@@ -91,12 +95,15 @@ discard block |
||
91 | 95 | |
92 | 96 | public function discoveryDevice(&$entity) |
93 | 97 | { |
94 | - if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) |
|
95 | - return; |
|
98 | + if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) { |
|
99 | + return; |
|
100 | + } |
|
96 | 101 | |
97 | 102 | $deviceId = $this->request->headers->get('DEVICE') ?: $this->getUserIp(); |
98 | 103 | if (method_exists($entity, 'setDevice')) { |
99 | - if ($entity->getDevice()) return; |
|
104 | + if ($entity->getDevice()) { |
|
105 | + return; |
|
106 | + } |
|
100 | 107 | $device = $this->deviceService->discoveryDevice($deviceId); |
101 | 108 | $entity->setDevice($device); |
102 | 109 | } |
@@ -107,14 +114,16 @@ discard block |
||
107 | 114 | $token = $this->security->getToken(); |
108 | 115 | $user = $token ? $token->getUser() : $this->skyNetService->getBotUser(); |
109 | 116 | |
110 | - if (method_exists($entity, 'setUser') && !$entity->getUser()) |
|
111 | - $entity->setUser($user); |
|
117 | + if (method_exists($entity, 'setUser') && !$entity->getUser()) { |
|
118 | + $entity->setUser($user); |
|
119 | + } |
|
112 | 120 | } |
113 | 121 | |
114 | 122 | public function persist(&$entity) |
115 | 123 | { |
116 | - if (self::$persisted == true) |
|
117 | - return; |
|
124 | + if (self::$persisted == true) { |
|
125 | + return; |
|
126 | + } |
|
118 | 127 | self::$persisted = true; |
119 | 128 | |
120 | 129 | //$this->manager->persist($entity); |
@@ -138,15 +147,17 @@ discard block |
||
138 | 147 | } else { |
139 | 148 | $json = json_decode($this->request->getContent(), true); |
140 | 149 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
141 | - if (!$extra_data) |
|
142 | - return; |
|
150 | + if (!$extra_data) { |
|
151 | + return; |
|
152 | + } |
|
143 | 153 | $entity_id = $extra_data['entity_id']; |
144 | 154 | $entity_name = $extra_data['entity_name']; |
145 | 155 | } |
146 | 156 | |
147 | 157 | |
148 | - if (!$entity_id || !$entity_name) |
|
149 | - return; |
|
158 | + if (!$entity_id || !$entity_name) { |
|
159 | + return; |
|
160 | + } |
|
150 | 161 | |
151 | 162 | foreach ($extra_data['data'] as $key => $data) { |
152 | 163 | $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key); |
@@ -157,8 +168,9 @@ discard block |
||
157 | 168 | 'extra_fields' => $extra_fields |
158 | 169 | ]); |
159 | 170 | |
160 | - if (!$extraData) |
|
161 | - $extraData = new ExtraData(); |
|
171 | + if (!$extraData) { |
|
172 | + $extraData = new ExtraData(); |
|
173 | + } |
|
162 | 174 | |
163 | 175 | $extraData->setExtraFields($extra_fields); |
164 | 176 | $extraData->setEntityName($entity_name); |