@@ -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['ddd'], $phone['phone'])?->getPeople(); |
|
74 | + if (!$people && !empty($phone)) { |
|
75 | + $people = $this->getPhone($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['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->setDdd((int) $phone_number['ddd']); |
@@ -112,8 +120,9 @@ discard block |
||
112 | 120 | { |
113 | 121 | $document = $this->getDocument($document_number, $document_type); |
114 | 122 | if ($document) { |
115 | - if ($document->getPeople()->getId() != $people->getId()) |
|
116 | - throw new Exception("Document is in use by people " . $people->getId(), 1); |
|
123 | + if ($document->getPeople()->getId() != $people->getId()) { |
|
124 | + throw new Exception("Document is in use by people " . $people->getId(), 1); |
|
125 | + } |
|
117 | 126 | } else { |
118 | 127 | $document_type = $document_type ? $this->discoveryDocumentType($document_type) : $this->discoveryDocumentType($this->getDocumentTypeByDocumentLen($document_number)); |
119 | 128 | $document = new Document(); |
@@ -131,8 +140,9 @@ discard block |
||
131 | 140 | { |
132 | 141 | $email = $this->getEmail($email_str); |
133 | 142 | if ($email && $email->getPeople()) { |
134 | - if ($email->getPeople()->getId() != $people->getId()) |
|
135 | - throw new Exception("Email is in use by people " . $people->getId(), 1); |
|
143 | + if ($email->getPeople()->getId() != $people->getId()) { |
|
144 | + throw new Exception("Email is in use by people " . $people->getId(), 1); |
|
145 | + } |
|
136 | 146 | } else { |
137 | 147 | $email = new Email(); |
138 | 148 | $email->setEmail($email_str); |
@@ -171,8 +181,9 @@ discard block |
||
171 | 181 | |
172 | 182 | public function getDocument(string $document_number, ?string $document_type = null): ?Document |
173 | 183 | { |
174 | - if (!$document_type) |
|
175 | - $document_type = $this->getDocumentTypeByDocumentLen($document_number); |
|
184 | + if (!$document_type) { |
|
185 | + $document_type = $this->getDocumentTypeByDocumentLen($document_number); |
|
186 | + } |
|
176 | 187 | return $this->manager->getRepository(Document::class)->findOneBy([ |
177 | 188 | 'document' => $document_number, |
178 | 189 | 'documentType' => |
@@ -193,18 +204,21 @@ discard block |
||
193 | 204 | public function postPersist(People $people) |
194 | 205 | { |
195 | 206 | $request = $this->requestStack->getCurrentRequest(); |
196 | - if (!$request) return; |
|
207 | + if (!$request) { |
|
208 | + return; |
|
209 | + } |
|
197 | 210 | $payload = json_decode($request->getContent()); |
198 | 211 | if (isset($payload->link_type)) { |
199 | 212 | $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company)); |
200 | - if ($company) |
|
201 | - $this->discoveryLink($company, $people, $payload->link_type); |
|
202 | - else { |
|
213 | + if ($company) { |
|
214 | + $this->discoveryLink($company, $people, $payload->link_type); |
|
215 | + } else { |
|
203 | 216 | $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link)); |
204 | 217 | if ($payload->link_type == 'employee' && $link) { |
205 | 218 | $this->discoveryLink($people, $link, $payload->link_type); |
206 | - if ($payload->people_document) |
|
207 | - $this->addDocument($people, $payload->people_document); |
|
219 | + if ($payload->people_document) { |
|
220 | + $this->addDocument($people, $payload->people_document); |
|
221 | + } |
|
208 | 222 | } |
209 | 223 | } |
210 | 224 | } |
@@ -219,8 +233,9 @@ discard block |
||
219 | 233 | 'link_type' => $link_type |
220 | 234 | ]); |
221 | 235 | |
222 | - if (!$peopleLink) |
|
223 | - $peopleLink = new PeopleLink(); |
|
236 | + if (!$peopleLink) { |
|
237 | + $peopleLink = new PeopleLink(); |
|
238 | + } |
|
224 | 239 | |
225 | 240 | $peopleLink->setCompany($company); |
226 | 241 | $peopleLink->setPeople($people); |
@@ -272,10 +287,14 @@ discard block |
||
272 | 287 | * @var \ControleOnline\Entity\User $currentUser |
273 | 288 | */ |
274 | 289 | $token = $this->security->getToken(); |
275 | - if (!$token) return []; |
|
290 | + if (!$token) { |
|
291 | + return []; |
|
292 | + } |
|
276 | 293 | $currentUser = $token->getUser(); |
277 | 294 | $companies = []; |
278 | - if (!$currentUser) return []; |
|
295 | + if (!$currentUser) { |
|
296 | + return []; |
|
297 | + } |
|
279 | 298 | |
280 | 299 | if (!$currentUser->getPeople()->getLink()->isEmpty()) { |
281 | 300 | foreach ($currentUser->getPeople()->getLink() as $company) { |