@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | private Security $security, |
23 | 23 | private RequestStack $requestStack |
24 | 24 | ) { |
25 | - $this->request = $requestStack->getCurrentRequest(); |
|
25 | + $this->request = $requestStack->getCurrentRequest(); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function prePersist(People $people) |
@@ -122,29 +122,29 @@ discard block |
||
122 | 122 | public function checkLink(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
123 | 123 | { |
124 | 124 | |
125 | - $link = $this->request->query->get('link', null); |
|
125 | + $link = $this->request->query->get('link', null); |
|
126 | 126 | $company = $this->request->query->get('company', null); |
127 | 127 | $link_type = $this->request->query->get('link_type', null); |
128 | 128 | |
129 | 129 | if ($link_type) { |
130 | - $queryBuilder->join(sprintf('%s.' . ($link ? 'company' : 'link'), $rootAlias), 'PeopleLink'); |
|
130 | + $queryBuilder->join(sprintf('%s.'.($link ? 'company' : 'link'), $rootAlias), 'PeopleLink'); |
|
131 | 131 | $queryBuilder->andWhere('PeopleLink.link_type IN(:link_type)'); |
132 | 132 | $queryBuilder->setParameter('link_type', $link_type); |
133 | 133 | } |
134 | 134 | |
135 | 135 | if ($company || $link) { |
136 | - $queryBuilder->andWhere('PeopleLink.' . ($link ? 'people' : 'company') . ' IN(:people)'); |
|
136 | + $queryBuilder->andWhere('PeopleLink.'.($link ? 'people' : 'company').' IN(:people)'); |
|
137 | 137 | $queryBuilder->setParameter('people', preg_replace("/[^0-9]/", "", ($link ?: $company))); |
138 | 138 | } |
139 | 139 | } |
140 | 140 | public function checkCompany($type, QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
141 | 141 | { |
142 | - $companies = $this->getMyCompanies(); |
|
143 | - $queryBuilder->andWhere(sprintf('%s.' . $type . ' IN(:companies)', $rootAlias, $rootAlias)); |
|
142 | + $companies = $this->getMyCompanies(); |
|
143 | + $queryBuilder->andWhere(sprintf('%s.'.$type.' IN(:companies)', $rootAlias, $rootAlias)); |
|
144 | 144 | $queryBuilder->setParameter('companies', $companies); |
145 | 145 | |
146 | 146 | if ($payer = $this->request->query->get('company', null)) { |
147 | - $queryBuilder->andWhere(sprintf('%s.' . $type . ' IN(:people)', $rootAlias)); |
|
147 | + $queryBuilder->andWhere(sprintf('%s.'.$type.' IN(:people)', $rootAlias)); |
|
148 | 148 | $queryBuilder->setParameter('people', preg_replace("/[^0-9]/", "", $payer)); |
149 | 149 | } |
150 | 150 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | $token = $this->security->getToken(); |
160 | 160 | if (!$token) return []; |
161 | - $currentUser = $token->getUser(); |
|
161 | + $currentUser = $token->getUser(); |
|
162 | 162 | $companies = []; |
163 | 163 | if (!$currentUser) return []; |
164 | 164 |
@@ -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) { |