@@ -53,8 +53,9 @@ discard block |
||
53 | 53 | 'link_type' => $linkType |
54 | 54 | ]); |
55 | 55 | |
56 | - if (!$peopleLink) |
|
57 | - $peopleLink = $this->addLink($company, $people, $linkType); |
|
56 | + if (!$peopleLink) { |
|
57 | + $peopleLink = $this->addLink($company, $people, $linkType); |
|
58 | + } |
|
58 | 59 | |
59 | 60 | return $peopleLink; |
60 | 61 | } |
@@ -62,14 +63,17 @@ discard block |
||
62 | 63 | public function discoveryPeople(?string $document = null, ?string $email = null, ?array $phone = [], ?string $name = null, ?string $peopleType = null): People |
63 | 64 | { |
64 | 65 | |
65 | - if (!empty($document)) |
|
66 | - $people = $this->getDocument($document)?->getPeople(); |
|
66 | + if (!empty($document)) { |
|
67 | + $people = $this->getDocument($document)?->getPeople(); |
|
68 | + } |
|
67 | 69 | |
68 | - if (!$people && !empty($email)) |
|
69 | - $people = $this->getEmail($email)?->getPeople(); |
|
70 | + if (!$people && !empty($email)) { |
|
71 | + $people = $this->getEmail($email)?->getPeople(); |
|
72 | + } |
|
70 | 73 | |
71 | - if (!$people && !empty($phone)) |
|
72 | - $people = $this->getPhone($phone['ddi'], $phone['ddd'], $phone['phone'])?->getPeople(); |
|
74 | + if (!$people && !empty($phone)) { |
|
75 | + $people = $this->getPhone($phone['ddi'], $phone['ddd'], $phone['phone'])?->getPeople(); |
|
76 | + } |
|
73 | 77 | |
74 | 78 | if (!$people) { |
75 | 79 | $people = new People(); |
@@ -80,12 +84,15 @@ discard block |
||
80 | 84 | $this->manager->flush(); |
81 | 85 | } |
82 | 86 | |
83 | - if ($document) |
|
84 | - $this->addDocument($people, $document); |
|
85 | - if ($email) |
|
86 | - $this->addEmail($people, $email); |
|
87 | - if ($phone) |
|
88 | - $this->addPhone($people, $phone); |
|
87 | + if ($document) { |
|
88 | + $this->addDocument($people, $document); |
|
89 | + } |
|
90 | + if ($email) { |
|
91 | + $this->addEmail($people, $email); |
|
92 | + } |
|
93 | + if ($phone) { |
|
94 | + $this->addPhone($people, $phone); |
|
95 | + } |
|
89 | 96 | |
90 | 97 | |
91 | 98 | return $people; |
@@ -95,8 +102,9 @@ discard block |
||
95 | 102 | { |
96 | 103 | $phone = $this->getPhone($phone_number['ddi'], $phone_number['ddd'], $phone_number['phone']); |
97 | 104 | if ($phone && $phone->getPeople()) { |
98 | - if ($phone->getPeople()->getId() != $people->getId()) |
|
99 | - throw new Exception("Phone is in use by people " . $people->getId(), 1); |
|
105 | + if ($phone->getPeople()->getId() != $people->getId()) { |
|
106 | + throw new Exception("Phone is in use by people " . $people->getId(), 1); |
|
107 | + } |
|
100 | 108 | } else { |
101 | 109 | $phone = new Phone(); |
102 | 110 | $phone->setDdi((int) $phone_number['ddi']); |
@@ -113,8 +121,9 @@ discard block |
||
113 | 121 | { |
114 | 122 | $document = $this->getDocument($document_number, $document_type); |
115 | 123 | if ($document) { |
116 | - if ($document->getPeople()->getId() != $people->getId()) |
|
117 | - throw new Exception("Document is in use by people " . $people->getId(), 1); |
|
124 | + if ($document->getPeople()->getId() != $people->getId()) { |
|
125 | + throw new Exception("Document is in use by people " . $people->getId(), 1); |
|
126 | + } |
|
118 | 127 | } else { |
119 | 128 | $document_type = $document_type ? $this->discoveryDocumentType($document_type) : $this->discoveryDocumentType($this->getDocumentTypeByDocumentLen($document_number)); |
120 | 129 | $document = new Document(); |
@@ -132,8 +141,9 @@ discard block |
||
132 | 141 | { |
133 | 142 | $email = $this->getEmail($email_str); |
134 | 143 | if ($email && $email->getPeople()) { |
135 | - if ($email->getPeople()->getId() != $people->getId()) |
|
136 | - throw new Exception("Email is in use by people " . $people->getId(), 1); |
|
144 | + if ($email->getPeople()->getId() != $people->getId()) { |
|
145 | + throw new Exception("Email is in use by people " . $people->getId(), 1); |
|
146 | + } |
|
137 | 147 | } else { |
138 | 148 | $email = new Email(); |
139 | 149 | $email->setEmail($email_str); |
@@ -176,8 +186,9 @@ discard block |
||
176 | 186 | |
177 | 187 | public function getDocument(string $document_number, ?string $document_type = null): ?Document |
178 | 188 | { |
179 | - if (!$document_type) |
|
180 | - $document_type = $this->getDocumentTypeByDocumentLen($document_number); |
|
189 | + if (!$document_type) { |
|
190 | + $document_type = $this->getDocumentTypeByDocumentLen($document_number); |
|
191 | + } |
|
181 | 192 | return $this->manager->getRepository(Document::class)->findOneBy([ |
182 | 193 | 'document' => $document_number, |
183 | 194 | 'documentType' => |
@@ -198,18 +209,21 @@ discard block |
||
198 | 209 | public function postPersist(People $people) |
199 | 210 | { |
200 | 211 | $request = $this->requestStack->getCurrentRequest(); |
201 | - if (!$request) return; |
|
212 | + if (!$request) { |
|
213 | + return; |
|
214 | + } |
|
202 | 215 | $payload = json_decode($request->getContent()); |
203 | 216 | if (isset($payload->link_type)) { |
204 | 217 | $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company)); |
205 | - if ($company) |
|
206 | - $this->discoveryLink($company, $people, $payload->link_type); |
|
207 | - else { |
|
218 | + if ($company) { |
|
219 | + $this->discoveryLink($company, $people, $payload->link_type); |
|
220 | + } else { |
|
208 | 221 | $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link)); |
209 | 222 | if ($payload->link_type == 'employee' && $link) { |
210 | 223 | $this->discoveryLink($people, $link, $payload->link_type); |
211 | - if ($payload->people_document) |
|
212 | - $this->addDocument($people, $payload->people_document); |
|
224 | + if ($payload->people_document) { |
|
225 | + $this->addDocument($people, $payload->people_document); |
|
226 | + } |
|
213 | 227 | } |
214 | 228 | } |
215 | 229 | } |
@@ -224,8 +238,9 @@ discard block |
||
224 | 238 | 'link_type' => $link_type |
225 | 239 | ]); |
226 | 240 | |
227 | - if (!$peopleLink) |
|
228 | - $peopleLink = new PeopleLink(); |
|
241 | + if (!$peopleLink) { |
|
242 | + $peopleLink = new PeopleLink(); |
|
243 | + } |
|
229 | 244 | |
230 | 245 | $peopleLink->setCompany($company); |
231 | 246 | $peopleLink->setPeople($people); |
@@ -277,10 +292,14 @@ discard block |
||
277 | 292 | * @var \ControleOnline\Entity\User $currentUser |
278 | 293 | */ |
279 | 294 | $token = $this->security->getToken(); |
280 | - if (!$token) return []; |
|
295 | + if (!$token) { |
|
296 | + return []; |
|
297 | + } |
|
281 | 298 | $currentUser = $token->getUser(); |
282 | 299 | $companies = []; |
283 | - if (!$currentUser) return []; |
|
300 | + if (!$currentUser) { |
|
301 | + return []; |
|
302 | + } |
|
284 | 303 | |
285 | 304 | if (!$currentUser->getPeople()->getLink()->isEmpty()) { |
286 | 305 | foreach ($currentUser->getPeople()->getLink() as $company) { |