@@ -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(); |
@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | |
| 41 | 41 | $document = $this->manager->getRepository(Document::class)->findOneBy(['document' => $document_number]); |
| 42 | - if ($document) |
|
| 43 | - return $document->getPeople(); |
|
| 42 | + if ($document) { |
|
| 43 | + return $document->getPeople(); |
|
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | |
| 46 | 47 | if ($name) { |
@@ -72,9 +73,9 @@ discard block |
||
| 72 | 73 | $payload = json_decode($request->getContent()); |
| 73 | 74 | if (isset($payload->link_type)) { |
| 74 | 75 | $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company)); |
| 75 | - if ($company) |
|
| 76 | - $this->addLink($company, $people, $payload->link_type); |
|
| 77 | - else { |
|
| 76 | + if ($company) { |
|
| 77 | + $this->addLink($company, $people, $payload->link_type); |
|
| 78 | + } else { |
|
| 78 | 79 | $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link)); |
| 79 | 80 | if ($payload->link_type == 'employee' && $link) { |
| 80 | 81 | $this->addLink($people, $link, $payload->link_type); |
@@ -102,8 +103,9 @@ discard block |
||
| 102 | 103 | 'link_type' => $link_type |
| 103 | 104 | ]); |
| 104 | 105 | |
| 105 | - if (!$peopleLink) |
|
| 106 | - $peopleLink = new PeopleLink(); |
|
| 106 | + if (!$peopleLink) { |
|
| 107 | + $peopleLink = new PeopleLink(); |
|
| 108 | + } |
|
| 107 | 109 | |
| 108 | 110 | $peopleLink->setCompany($company); |
| 109 | 111 | $peopleLink->setPeople($people); |
@@ -157,10 +159,14 @@ discard block |
||
| 157 | 159 | * @var \ControleOnline\Entity\User $currentUser |
| 158 | 160 | */ |
| 159 | 161 | $token = $this->security->getToken(); |
| 160 | - if (!$token) return []; |
|
| 162 | + if (!$token) { |
|
| 163 | + return []; |
|
| 164 | + } |
|
| 161 | 165 | $currentUser = $token->getUser(); |
| 162 | 166 | $companies = []; |
| 163 | - if (!$currentUser) return []; |
|
| 167 | + if (!$currentUser) { |
|
| 168 | + return []; |
|
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | if (!$currentUser->getPeople()->getLink()->isEmpty()) { |
| 166 | 172 | foreach ($currentUser->getPeople()->getLink() as $company) { |