@@ -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); |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | $payload = json_decode($request->getContent()); |
| 34 | 34 | if (isset($payload->link_type)) { |
| 35 | 35 | $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company)); |
| 36 | - if ($company) |
|
| 37 | - $this->addLink($company, $people, $payload->link_type); |
|
| 38 | - else { |
|
| 36 | + if ($company) { |
|
| 37 | + $this->addLink($company, $people, $payload->link_type); |
|
| 38 | + } else { |
|
| 39 | 39 | $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link)); |
| 40 | 40 | if ($payload->link_type == 'employee' && $link) { |
| 41 | 41 | $this->addLink($people, $link, $payload->link_type); |
@@ -63,8 +63,9 @@ discard block |
||
| 63 | 63 | 'link_type' => $link_type |
| 64 | 64 | ]); |
| 65 | 65 | |
| 66 | - if (!$peopleLink) |
|
| 67 | - $peopleLink = new PeopleLink(); |
|
| 66 | + if (!$peopleLink) { |
|
| 67 | + $peopleLink = new PeopleLink(); |
|
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | $peopleLink->setCompany($company); |
| 70 | 71 | $peopleLink->setPeople($people); |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | foreach ($getPeopleCompanies as $peopleCompany) { |
| 37 | 37 | $isFranchisee = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'franchisee', 1); |
| 38 | - if ($isFranchisee) return true; |
|
| 38 | + if ($isFranchisee) { |
|
| 39 | + return true; |
|
| 40 | + } |
|
| 39 | 41 | } |
| 40 | 42 | return $isFranchisee; |
| 41 | 43 | } |
@@ -52,7 +54,9 @@ discard block |
||
| 52 | 54 | $isSalesman = false; |
| 53 | 55 | |
| 54 | 56 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'salesman', 1); |
| 55 | - if ($isSalesman) return true; |
|
| 57 | + if ($isSalesman) { |
|
| 58 | + return true; |
|
| 59 | + } |
|
| 56 | 60 | |
| 57 | 61 | $getPeopleCompanies = $this->manager->getRepository(PeopleLink::class)->findBy([ |
| 58 | 62 | 'people' => $people, |
@@ -63,7 +67,9 @@ discard block |
||
| 63 | 67 | */ |
| 64 | 68 | foreach ($getPeopleCompanies as $peopleCompany) { |
| 65 | 69 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'salesman', 1); |
| 66 | - if ($isSalesman) return true; |
|
| 70 | + if ($isSalesman) { |
|
| 71 | + return true; |
|
| 72 | + } |
|
| 67 | 73 | } |
| 68 | 74 | return $isSalesman; |
| 69 | 75 | } |
@@ -76,8 +82,9 @@ discard block |
||
| 76 | 82 | $mainCompany = $this->getMainCompany(); |
| 77 | 83 | |
| 78 | 84 | $isSuper = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'employee', 1); |
| 79 | - if ($isSuper) |
|
| 80 | - $peopleRole[] = 'super'; |
|
| 85 | + if ($isSuper) { |
|
| 86 | + $peopleRole[] = 'super'; |
|
| 87 | + } |
|
| 81 | 88 | |
| 82 | 89 | |
| 83 | 90 | |
@@ -88,13 +95,15 @@ discard block |
||
| 88 | 95 | } |
| 89 | 96 | |
| 90 | 97 | $isClient = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'client', 1); |
| 91 | - if ($isClient) |
|
| 92 | - $peopleRole[] = 'client'; |
|
| 98 | + if ($isClient) { |
|
| 99 | + $peopleRole[] = 'client'; |
|
| 100 | + } |
|
| 93 | 101 | |
| 94 | 102 | |
| 95 | 103 | $isSalesman = $this->isSalesman($user); |
| 96 | - if ($isSalesman) |
|
| 97 | - $peopleRole[] = 'salesman'; |
|
| 104 | + if ($isSalesman) { |
|
| 105 | + $peopleRole[] = 'salesman'; |
|
| 106 | + } |
|
| 98 | 107 | |
| 99 | 108 | |
| 100 | 109 | return array_values(array_unique(empty($peopleRole) ? ['guest'] : $peopleRole)); |
@@ -108,7 +117,9 @@ discard block |
||
| 108 | 117 | public function getMainCompany(): People |
| 109 | 118 | { |
| 110 | 119 | |
| 111 | - if (self::$mainCompany) return self::$mainCompany; |
|
| 120 | + if (self::$mainCompany) { |
|
| 121 | + return self::$mainCompany; |
|
| 122 | + } |
|
| 112 | 123 | |
| 113 | 124 | $peopleDomain = $this->domainService->getPeopleDomain(); |
| 114 | 125 | self::$mainCompany = $peopleDomain->getPeople(); |