@@ -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,9 +181,9 @@ 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); |
@@ -202,8 +211,9 @@ discard block |
||
202 | 211 | 'link_type' => $link_type |
203 | 212 | ]); |
204 | 213 | |
205 | - if (!$peopleLink) |
|
206 | - $peopleLink = new PeopleLink(); |
|
214 | + if (!$peopleLink) { |
|
215 | + $peopleLink = new PeopleLink(); |
|
216 | + } |
|
207 | 217 | |
208 | 218 | $peopleLink->setCompany($company); |
209 | 219 | $peopleLink->setPeople($people); |
@@ -255,10 +265,14 @@ discard block |
||
255 | 265 | * @var \ControleOnline\Entity\User $currentUser |
256 | 266 | */ |
257 | 267 | $token = $this->security->getToken(); |
258 | - if (!$token) return []; |
|
268 | + if (!$token) { |
|
269 | + return []; |
|
270 | + } |
|
259 | 271 | $currentUser = $token->getUser(); |
260 | 272 | $companies = []; |
261 | - if (!$currentUser) return []; |
|
273 | + if (!$currentUser) { |
|
274 | + return []; |
|
275 | + } |
|
262 | 276 | |
263 | 277 | if (!$currentUser->getPeople()->getLink()->isEmpty()) { |
264 | 278 | foreach ($currentUser->getPeople()->getLink() as $company) { |