@@ -47,11 +47,13 @@ discard block |
||
47 | 47 | |
48 | 48 | $people = $this->getDocument($document)?->getPeople(); |
49 | 49 | |
50 | - if (!$people) |
|
51 | - $people = $this->getEmail($email)?->getPeople(); |
|
50 | + if (!$people) { |
|
51 | + $people = $this->getEmail($email)?->getPeople(); |
|
52 | + } |
|
52 | 53 | |
53 | - if (!$people) |
|
54 | - $people = $this->getPhone($phone['ddd'], $phone['phone'])?->getPeople(); |
|
54 | + if (!$people) { |
|
55 | + $people = $this->getPhone($phone['ddd'], $phone['phone'])?->getPeople(); |
|
56 | + } |
|
55 | 57 | |
56 | 58 | if (!$people) { |
57 | 59 | $people = new People(); |
@@ -62,12 +64,15 @@ discard block |
||
62 | 64 | $this->manager->flush(); |
63 | 65 | } |
64 | 66 | |
65 | - if ($document) |
|
66 | - $this->addDocument($people, $document); |
|
67 | - if ($email) |
|
68 | - $this->addEmail($people, $email); |
|
69 | - if ($phone) |
|
70 | - $this->addPhone($people, $phone); |
|
67 | + if ($document) { |
|
68 | + $this->addDocument($people, $document); |
|
69 | + } |
|
70 | + if ($email) { |
|
71 | + $this->addEmail($people, $email); |
|
72 | + } |
|
73 | + if ($phone) { |
|
74 | + $this->addPhone($people, $phone); |
|
75 | + } |
|
71 | 76 | |
72 | 77 | |
73 | 78 | return $people; |
@@ -77,8 +82,9 @@ discard block |
||
77 | 82 | { |
78 | 83 | $phone = $this->getPhone($phone_number['ddd'], $phone_number['phone']); |
79 | 84 | if ($phone && $phone->getPeople()) { |
80 | - if ($phone->getPeople()->getId() != $people->getId()) |
|
81 | - throw new Exception("Phone is in use by people " . $people->getId(), 1); |
|
85 | + if ($phone->getPeople()->getId() != $people->getId()) { |
|
86 | + throw new Exception("Phone is in use by people " . $people->getId(), 1); |
|
87 | + } |
|
82 | 88 | } else { |
83 | 89 | $phone = new Phone(); |
84 | 90 | $phone->setDdd($phone_number['ddd']); |
@@ -94,8 +100,9 @@ discard block |
||
94 | 100 | { |
95 | 101 | $document = $this->getDocument($document_number, $document_type); |
96 | 102 | if ($document) { |
97 | - if ($document->getPeople()->getId() != $people->getId()) |
|
98 | - throw new Exception("Document is in use by people " . $people->getId(), 1); |
|
103 | + if ($document->getPeople()->getId() != $people->getId()) { |
|
104 | + throw new Exception("Document is in use by people " . $people->getId(), 1); |
|
105 | + } |
|
99 | 106 | } else { |
100 | 107 | $document = new Document(); |
101 | 108 | $document->setDocument($document_number); |
@@ -112,8 +119,9 @@ discard block |
||
112 | 119 | { |
113 | 120 | $email = $this->getEmail($email_str); |
114 | 121 | if ($email && $email->getPeople()) { |
115 | - if ($email->getPeople()->getId() != $people->getId()) |
|
116 | - throw new Exception("Email is in use by people " . $people->getId(), 1); |
|
122 | + if ($email->getPeople()->getId() != $people->getId()) { |
|
123 | + throw new Exception("Email is in use by people " . $people->getId(), 1); |
|
124 | + } |
|
117 | 125 | } else { |
118 | 126 | $email = new Email(); |
119 | 127 | $email->setEmail($email_str); |
@@ -152,8 +160,9 @@ discard block |
||
152 | 160 | |
153 | 161 | public function getDocument(string $document_number, ?string $document_type = null): ?Document |
154 | 162 | { |
155 | - if (!$document_type) |
|
156 | - $document_type = $this->getDocumentTypeByDocumentLen($document_number); |
|
163 | + if (!$document_type) { |
|
164 | + $document_type = $this->getDocumentTypeByDocumentLen($document_number); |
|
165 | + } |
|
157 | 166 | return $this->manager->getRepository(Document::class)->findOneBy([ |
158 | 167 | 'document' => $document_number, |
159 | 168 | 'documentType' => |
@@ -172,14 +181,15 @@ discard block |
||
172 | 181 | $payload = json_decode($request->getContent()); |
173 | 182 | if (isset($payload->link_type)) { |
174 | 183 | $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company)); |
175 | - if ($company) |
|
176 | - $this->addLink($company, $people, $payload->link_type); |
|
177 | - else { |
|
184 | + if ($company) { |
|
185 | + $this->addLink($company, $people, $payload->link_type); |
|
186 | + } else { |
|
178 | 187 | $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link)); |
179 | 188 | if ($payload->link_type == 'employee' && $link) { |
180 | 189 | $this->addLink($people, $link, $payload->link_type); |
181 | - if ($payload->people_document) |
|
182 | - $this->addDocument($people, $payload->people_document); |
|
190 | + if ($payload->people_document) { |
|
191 | + $this->addDocument($people, $payload->people_document); |
|
192 | + } |
|
183 | 193 | } |
184 | 194 | } |
185 | 195 | } |
@@ -194,8 +204,9 @@ discard block |
||
194 | 204 | 'link_type' => $link_type |
195 | 205 | ]); |
196 | 206 | |
197 | - if (!$peopleLink) |
|
198 | - $peopleLink = new PeopleLink(); |
|
207 | + if (!$peopleLink) { |
|
208 | + $peopleLink = new PeopleLink(); |
|
209 | + } |
|
199 | 210 | |
200 | 211 | $peopleLink->setCompany($company); |
201 | 212 | $peopleLink->setPeople($people); |
@@ -247,10 +258,14 @@ discard block |
||
247 | 258 | * @var \ControleOnline\Entity\User $currentUser |
248 | 259 | */ |
249 | 260 | $token = $this->security->getToken(); |
250 | - if (!$token) return []; |
|
261 | + if (!$token) { |
|
262 | + return []; |
|
263 | + } |
|
251 | 264 | $currentUser = $token->getUser(); |
252 | 265 | $companies = []; |
253 | - if (!$currentUser) return []; |
|
266 | + if (!$currentUser) { |
|
267 | + return []; |
|
268 | + } |
|
254 | 269 | |
255 | 270 | if (!$currentUser->getPeople()->getLink()->isEmpty()) { |
256 | 271 | foreach ($currentUser->getPeople()->getLink() as $company) { |