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