@@ -35,8 +35,9 @@ discard block |
||
35 | 35 | 'entity_name' => $class->getShortName(), |
36 | 36 | 'value' => $code |
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, $code, $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); |
@@ -91,12 +94,15 @@ discard block |
||
91 | 94 | |
92 | 95 | public function discoveryDevice(&$entity) |
93 | 96 | { |
94 | - if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) |
|
95 | - return; |
|
97 | + if ($entity instanceof Device || $entity instanceof DeviceConfig || !$this->request->headers) { |
|
98 | + return; |
|
99 | + } |
|
96 | 100 | |
97 | 101 | $deviceId = $this->request->headers->get('DEVICE') ?: $this->getUserIp(); |
98 | 102 | if (method_exists($entity, 'setDevice')) { |
99 | - if ($entity->getDevice()) return; |
|
103 | + if ($entity->getDevice()) { |
|
104 | + return; |
|
105 | + } |
|
100 | 106 | $device = $this->deviceService->discoveryDevice($deviceId); |
101 | 107 | $entity->setDevice($device); |
102 | 108 | } |
@@ -107,14 +113,16 @@ discard block |
||
107 | 113 | $token = $this->security->getToken(); |
108 | 114 | $user = $token ? $token->getUser() : $this->skyNetService->getBotUser(); |
109 | 115 | |
110 | - if (method_exists($entity, 'setUser') && !$entity->getUser()) |
|
111 | - $entity->setUser($user); |
|
116 | + if (method_exists($entity, 'setUser') && !$entity->getUser()) { |
|
117 | + $entity->setUser($user); |
|
118 | + } |
|
112 | 119 | } |
113 | 120 | |
114 | 121 | public function persist(&$entity) |
115 | 122 | { |
116 | - if (self::$persisted == true) |
|
117 | - return; |
|
123 | + if (self::$persisted == true) { |
|
124 | + return; |
|
125 | + } |
|
118 | 126 | self::$persisted = true; |
119 | 127 | |
120 | 128 | //$this->manager->persist($entity); |
@@ -138,18 +146,21 @@ discard block |
||
138 | 146 | } else { |
139 | 147 | $json = json_decode($this->request->getContent(), true); |
140 | 148 | $extra_data = isset($json['extra-data']) ? $json['extra-data'] : null; |
141 | - if (!$extra_data) |
|
142 | - return; |
|
149 | + if (!$extra_data) { |
|
150 | + return; |
|
151 | + } |
|
143 | 152 | $entity_id = $extra_data['entity_id']; |
144 | 153 | $entity_name = $extra_data['entity_name']; |
145 | 154 | } |
146 | 155 | |
147 | 156 | |
148 | - if (!$entity_id || !$entity_name) |
|
149 | - return; |
|
157 | + if (!$entity_id || !$entity_name) { |
|
158 | + return; |
|
159 | + } |
|
150 | 160 | |
151 | - if (!isset($extra_data) || !isset($extra_data['data'])) |
|
152 | - return; |
|
161 | + if (!isset($extra_data) || !isset($extra_data['data'])) { |
|
162 | + return; |
|
163 | + } |
|
153 | 164 | |
154 | 165 | foreach ($extra_data['data'] as $key => $data) { |
155 | 166 | $extra_fields = $this->manager->getRepository(ExtraFields::class)->find($key); |
@@ -160,8 +171,9 @@ discard block |
||
160 | 171 | 'extra_fields' => $extra_fields |
161 | 172 | ]); |
162 | 173 | |
163 | - if (!$extraData) |
|
164 | - $extraData = new ExtraData(); |
|
174 | + if (!$extraData) { |
|
175 | + $extraData = new ExtraData(); |
|
176 | + } |
|
165 | 177 | |
166 | 178 | $extraData->setExtraFields($extra_fields); |
167 | 179 | $extraData->setEntityName($entity_name); |