@@ -113,8 +113,9 @@ |
||
113 | 113 | |
114 | 114 | return true; |
115 | 115 | } catch (\Exception $e) { |
116 | - if ($this->manager->getConnection()->isTransactionActive()) |
|
117 | - $this->manager->getConnection()->rollBack(); |
|
116 | + if ($this->manager->getConnection()->isTransactionActive()) { |
|
117 | + $this->manager->getConnection()->rollBack(); |
|
118 | + } |
|
118 | 119 | |
119 | 120 | throw new \InvalidArgumentException($e->getMessage()); |
120 | 121 | } |
@@ -51,8 +51,9 @@ |
||
51 | 51 | ->setParameter('company', $company->getId()) |
52 | 52 | ->setParameter('people', $people->getId()); |
53 | 53 | |
54 | - if ($linkType) |
|
55 | - $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType'); |
|
54 | + if ($linkType) { |
|
55 | + $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType'); |
|
56 | + } |
|
56 | 57 | |
57 | 58 | if ($maxResults) { |
58 | 59 | $queryBuilder->setMaxResults($maxResults); |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | $isSalesman = false; |
35 | 35 | |
36 | 36 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'salesman', 1); |
37 | - if ($isSalesman) return true; |
|
37 | + if ($isSalesman) { |
|
38 | + return true; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | $getPeopleCompanies = $this->manager->getRepository(PeopleLink::class)->findBy([ |
40 | 42 | 'people' => $people, |
@@ -45,7 +47,9 @@ discard block |
||
45 | 47 | */ |
46 | 48 | foreach ($getPeopleCompanies as $peopleCompany) { |
47 | 49 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'salesman', 1); |
48 | - if ($isSalesman) return true; |
|
50 | + if ($isSalesman) { |
|
51 | + return true; |
|
52 | + } |
|
49 | 53 | } |
50 | 54 | return $isSalesman; |
51 | 55 | } |
@@ -57,8 +61,9 @@ discard block |
||
57 | 61 | $mainCompany = $this->getMainCompany(); |
58 | 62 | |
59 | 63 | $isSuper = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'employee', 1); |
60 | - if ($isSuper) |
|
61 | - $peopleRole[] = 'super'; |
|
64 | + if ($isSuper) { |
|
65 | + $peopleRole[] = 'super'; |
|
66 | + } |
|
62 | 67 | |
63 | 68 | |
64 | 69 | |
@@ -69,13 +74,15 @@ discard block |
||
69 | 74 | } |
70 | 75 | |
71 | 76 | $isClient = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'client', 1); |
72 | - if ($isClient) |
|
73 | - $peopleRole[] = 'client'; |
|
77 | + if ($isClient) { |
|
78 | + $peopleRole[] = 'client'; |
|
79 | + } |
|
74 | 80 | |
75 | 81 | |
76 | 82 | $isSalesman = $this->isSalesman($people); |
77 | - if ($isSalesman) |
|
78 | - $peopleRole[] = 'salesman'; |
|
83 | + if ($isSalesman) { |
|
84 | + $peopleRole[] = 'salesman'; |
|
85 | + } |
|
79 | 86 | |
80 | 87 | |
81 | 88 | return array_values(array_unique(empty($peopleRole) ? ['guest'] : $peopleRole)); |
@@ -89,7 +96,9 @@ discard block |
||
89 | 96 | public function getMainCompany(): People |
90 | 97 | { |
91 | 98 | |
92 | - if (self::$mainCompany) return self::$mainCompany; |
|
99 | + if (self::$mainCompany) { |
|
100 | + return self::$mainCompany; |
|
101 | + } |
|
93 | 102 | |
94 | 103 | $peopleDomain = $this->domainService->getPeopleDomain(); |
95 | 104 | self::$mainCompany = $peopleDomain->getPeople(); |
@@ -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) { |