@@ -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); |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | foreach ($getPeopleCompanies as $peopleCompany) { |
39 | 39 | $isFranchisee = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'franchisee', 1); |
40 | - if ($isFranchisee) return true; |
|
40 | + if ($isFranchisee) { |
|
41 | + return true; |
|
42 | + } |
|
41 | 43 | } |
42 | 44 | return $isFranchisee; |
43 | 45 | } |
@@ -54,7 +56,9 @@ discard block |
||
54 | 56 | $isSalesman = false; |
55 | 57 | |
56 | 58 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'salesman', 1); |
57 | - if ($isSalesman) return true; |
|
59 | + if ($isSalesman) { |
|
60 | + return true; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | $getPeopleCompanies = $this->manager->getRepository(PeopleLink::class)->findBy([ |
60 | 64 | 'people' => $people, |
@@ -65,7 +69,9 @@ discard block |
||
65 | 69 | */ |
66 | 70 | foreach ($getPeopleCompanies as $peopleCompany) { |
67 | 71 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'salesman', 1); |
68 | - if ($isSalesman) return true; |
|
72 | + if ($isSalesman) { |
|
73 | + return true; |
|
74 | + } |
|
69 | 75 | } |
70 | 76 | return $isSalesman; |
71 | 77 | } |
@@ -78,8 +84,9 @@ discard block |
||
78 | 84 | $mainCompany = $this->getMainCompany(); |
79 | 85 | |
80 | 86 | $isSuper = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'employee', 1); |
81 | - if ($isSuper) |
|
82 | - $peopleRole[] = 'super'; |
|
87 | + if ($isSuper) { |
|
88 | + $peopleRole[] = 'super'; |
|
89 | + } |
|
83 | 90 | |
84 | 91 | |
85 | 92 | |
@@ -90,13 +97,15 @@ discard block |
||
90 | 97 | } |
91 | 98 | |
92 | 99 | $isClient = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'client', 1); |
93 | - if ($isClient) |
|
94 | - $peopleRole[] = 'client'; |
|
100 | + if ($isClient) { |
|
101 | + $peopleRole[] = 'client'; |
|
102 | + } |
|
95 | 103 | |
96 | 104 | |
97 | 105 | $isSalesman = $this->isSalesman($user); |
98 | - if ($isSalesman) |
|
99 | - $peopleRole[] = 'salesman'; |
|
106 | + if ($isSalesman) { |
|
107 | + $peopleRole[] = 'salesman'; |
|
108 | + } |
|
100 | 109 | |
101 | 110 | |
102 | 111 | return array_values(array_unique(empty($peopleRole) ? ['guest'] : $peopleRole)); |
@@ -110,15 +119,18 @@ discard block |
||
110 | 119 | public function getMainCompany(): People |
111 | 120 | { |
112 | 121 | |
113 | - if (self::$mainCompany) return self::$mainCompany; |
|
122 | + if (self::$mainCompany) { |
|
123 | + return self::$mainCompany; |
|
124 | + } |
|
114 | 125 | |
115 | 126 | $domain = $this->domainService->getMainDomain(); |
116 | 127 | $company = $this->manager->getRepository(PeopleDomain::class)->findOneBy(['domain' => $domain]); |
117 | 128 | |
118 | - if ($company === null) |
|
119 | - throw new \Exception( |
|
129 | + if ($company === null) { |
|
130 | + throw new \Exception( |
|
120 | 131 | sprintf('Main company "%s" not found', $domain) |
121 | 132 | ); |
133 | + } |
|
122 | 134 | |
123 | 135 | self::$mainCompany = $company->getPeople(); |
124 | 136 | return self::$mainCompany; |
@@ -261,12 +261,13 @@ |
||
261 | 261 | |
262 | 262 | private function getLogo(People $company): ?array |
263 | 263 | { |
264 | - if ($company->getImage() instanceof File) |
|
265 | - return [ |
|
264 | + if ($company->getImage() instanceof File) { |
|
265 | + return [ |
|
266 | 266 | 'id' => $company->getImage()->getId(), |
267 | 267 | 'domain' => $this->domainService->getMainDomain(), |
268 | 268 | 'url' => '/files/' . $company->getImage()->getId() . '/download' |
269 | 269 | ]; |
270 | + } |
|
270 | 271 | |
271 | 272 | return null; |
272 | 273 | } |
@@ -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); |