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