@@ -269,7 +269,7 @@ |
||
269 | 269 | */ |
270 | 270 | public function getAmount(): float |
271 | 271 | { |
272 | - if ($this->part instanceof Part && ! $this->part->useFloatAmount()) { |
|
272 | + if ($this->part instanceof Part && !$this->part->useFloatAmount()) { |
|
273 | 273 | return round($this->amount); |
274 | 274 | } |
275 | 275 |
@@ -80,9 +80,9 @@ |
||
80 | 80 | public function onRegister(RegisterEvent $event): void |
81 | 81 | { |
82 | 82 | //Skip adding of U2F key on demo mode |
83 | - if (! $this->demo_mode) { |
|
83 | + if (!$this->demo_mode) { |
|
84 | 84 | $user = $event->getUser(); |
85 | - if (! $user instanceof User) { |
|
85 | + if (!$user instanceof User) { |
|
86 | 86 | throw new \InvalidArgumentException('Only User objects can be registered for U2F!'); |
87 | 87 | } |
88 | 88 |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | { |
270 | 270 | unset($fields['lastModified']); |
271 | 271 | |
272 | - if (! $this->hasFieldRestrictions($element)) { |
|
272 | + if (!$this->hasFieldRestrictions($element)) { |
|
273 | 273 | return $fields; |
274 | 274 | } |
275 | 275 | |
276 | - return array_filter($fields, function ($value, $key) use ($element) { |
|
276 | + return array_filter($fields, function($value, $key) use ($element) { |
|
277 | 277 | //Associative array (save changed data) case |
278 | 278 | if (is_string($key)) { |
279 | 279 | return $this->shouldFieldBeSaved($element, $key); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | { |
288 | 288 | $uow = $em->getUnitOfWork(); |
289 | 289 | |
290 | - if (! $logEntry instanceof ElementEditedLogEntry && ! $logEntry instanceof ElementDeletedLogEntry) { |
|
290 | + if (!$logEntry instanceof ElementEditedLogEntry && !$logEntry instanceof ElementDeletedLogEntry) { |
|
291 | 291 | throw new \InvalidArgumentException('$logEntry must be ElementEditedLogEntry or ElementDeletedLogEntry!'); |
292 | 292 | } |
293 | 293 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $old_data = $this->filterFieldRestrictions($entity, $old_data); |
301 | 301 | |
302 | 302 | //Restrict length of string fields, to save memory... |
303 | - $old_data = array_map(function ($value) { |
|
303 | + $old_data = array_map(function($value) { |
|
304 | 304 | if (is_string($value)) { |
305 | 305 | return mb_strimwidth($value, 0, self::MAX_STRING_LENGTH, '...'); |
306 | 306 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | protected function validEntity(object $entity): bool |
320 | 320 | { |
321 | 321 | //Dont log logentries itself! |
322 | - if ($entity instanceof AbstractDBElement && ! $entity instanceof AbstractLogEntry) { |
|
322 | + if ($entity instanceof AbstractDBElement && !$entity instanceof AbstractLogEntry) { |
|
323 | 323 | return true; |
324 | 324 | } |
325 | 325 |
@@ -85,7 +85,7 @@ |
||
85 | 85 | */ |
86 | 86 | protected function instanceToPermissionName($subject): ?string |
87 | 87 | { |
88 | - if (! is_string($subject)) { |
|
88 | + if (!is_string($subject)) { |
|
89 | 89 | $class_name = get_class($subject); |
90 | 90 | } else { |
91 | 91 | $class_name = $subject; |
@@ -27,11 +27,11 @@ |
||
27 | 27 | $this->addSql('ALTER TABLE `users` ADD perms_parts_parameters SMALLINT NOT NULL'); |
28 | 28 | $this->addSql('ALTER TABLE log CHANGE level level TINYINT'); |
29 | 29 | |
30 | - $sql = 'UPDATE `groups`' . |
|
30 | + $sql = 'UPDATE `groups`'. |
|
31 | 31 | 'SET perms_parts_parameters = 341 WHERE (id = 1 AND name = "admins") OR (id = 3 AND name = "users");'; |
32 | 32 | $this->addSql($sql); |
33 | 33 | |
34 | - $sql = 'UPDATE `groups`' . |
|
34 | + $sql = 'UPDATE `groups`'. |
|
35 | 35 | 'SET perms_parts_parameters = 681 WHERE (id = 2 AND name = "readonly");'; |
36 | 36 | $this->addSql($sql); |
37 | 37 |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | $dataTable->add('symbol', TextColumn::class, [ |
111 | 111 | 'label' => '', |
112 | - 'render' => function ($value, AbstractLogEntry $context) { |
|
112 | + 'render' => function($value, AbstractLogEntry $context) { |
|
113 | 113 | switch ($context->getLevelString()) { |
114 | 114 | case LogLevel::DEBUG: |
115 | 115 | $symbol = 'fa-bug'; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $dataTable->add('type', TextColumn::class, [ |
171 | 171 | 'label' => $this->translator->trans('log.type'), |
172 | 172 | 'propertyPath' => 'type', |
173 | - 'render' => function (string $value, AbstractLogEntry $context) { |
|
173 | + 'render' => function(string $value, AbstractLogEntry $context) { |
|
174 | 174 | return $this->translator->trans('log.type.'.$value); |
175 | 175 | }, |
176 | 176 | ]); |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | 'label' => $this->translator->trans('log.level'), |
180 | 180 | 'visible' => 'system_log' === $options['mode'], |
181 | 181 | 'propertyPath' => 'levelString', |
182 | - 'render' => function (string $value, AbstractLogEntry $context) { |
|
182 | + 'render' => function(string $value, AbstractLogEntry $context) { |
|
183 | 183 | return $value; |
184 | 184 | }, |
185 | 185 | ]); |
186 | 186 | |
187 | 187 | $dataTable->add('user', TextColumn::class, [ |
188 | 188 | 'label' => $this->translator->trans('log.user'), |
189 | - 'render' => function ($value, AbstractLogEntry $context) { |
|
189 | + 'render' => function($value, AbstractLogEntry $context) { |
|
190 | 190 | $user = $context->getUser(); |
191 | 191 | |
192 | 192 | return sprintf( |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $dataTable->add('target_type', TextColumn::class, [ |
201 | 201 | 'label' => $this->translator->trans('log.target_type'), |
202 | 202 | 'visible' => false, |
203 | - 'render' => function ($value, AbstractLogEntry $context) { |
|
203 | + 'render' => function($value, AbstractLogEntry $context) { |
|
204 | 204 | $class = $context->getTargetClass(); |
205 | 205 | if (null !== $class) { |
206 | 206 | return $this->elementTypeNameGenerator->getLocalizedTypeLabel($class); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $dataTable->add('timeTravel', IconLinkColumn::class, [ |
222 | 222 | 'label' => '', |
223 | 223 | 'icon' => 'fas fa-fw fa-eye', |
224 | - 'href' => function ($value, AbstractLogEntry $context) { |
|
224 | + 'href' => function($value, AbstractLogEntry $context) { |
|
225 | 225 | if ( |
226 | 226 | ($context instanceof TimeTravelInterface |
227 | 227 | && $context->hasOldDataInformations()) |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | |
240 | 240 | return null; |
241 | 241 | }, |
242 | - 'disabled' => function ($value, AbstractLogEntry $context) { |
|
242 | + 'disabled' => function($value, AbstractLogEntry $context) { |
|
243 | 243 | return |
244 | - ! $this->security->isGranted('@tools.timetravel') |
|
245 | - || ! $this->security->isGranted('show_history', $context->getTargetClass()); |
|
244 | + !$this->security->isGranted('@tools.timetravel') |
|
245 | + || !$this->security->isGranted('show_history', $context->getTargetClass()); |
|
246 | 246 | }, |
247 | 247 | ]); |
248 | 248 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | $dataTable->createAdapter(ORMAdapter::class, [ |
256 | 256 | 'entity' => AbstractLogEntry::class, |
257 | - 'query' => function (QueryBuilder $builder) use ($options): void { |
|
257 | + 'query' => function(QueryBuilder $builder) use ($options): void { |
|
258 | 258 | $this->getQuery($builder, $options); |
259 | 259 | }, |
260 | 260 | ]); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | ]); |
281 | 281 | } |
282 | 282 | |
283 | - if (! empty($options['filter_elements'])) { |
|
283 | + if (!empty($options['filter_elements'])) { |
|
284 | 284 | foreach ($options['filter_elements'] as $element) { |
285 | 285 | /** @var AbstractDBElement $element */ |
286 | 286 |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $optionsResolver->setAllowedTypes('search', ['null', 'string']); |
114 | 114 | |
115 | 115 | //Configure search options |
116 | - $optionsResolver->setDefault('search_options', function (OptionsResolver $resolver): void { |
|
116 | + $optionsResolver->setDefault('search_options', function(OptionsResolver $resolver): void { |
|
117 | 117 | $resolver->setDefaults([ |
118 | 118 | 'name' => true, |
119 | 119 | 'category' => true, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $dataTable |
150 | 150 | ->add('picture', TextColumn::class, [ |
151 | 151 | 'label' => '', |
152 | - 'render' => function ($value, Part $context) { |
|
152 | + 'render' => function($value, Part $context) { |
|
153 | 153 | $preview_attachment = $this->previewGenerator->getTablePreviewAttachment($context); |
154 | 154 | if (null === $preview_attachment) { |
155 | 155 | return ''; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | ]) |
167 | 167 | ->add('name', TextColumn::class, [ |
168 | 168 | 'label' => $this->translator->trans('part.table.name'), |
169 | - 'render' => function ($value, Part $context) { |
|
169 | + 'render' => function($value, Part $context) { |
|
170 | 170 | return sprintf( |
171 | 171 | '<a href="%s">%s</a>', |
172 | 172 | $this->urlGenerator->infoURL($context), |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | ]) |
196 | 196 | ->add('storelocation', TextColumn::class, [ |
197 | 197 | 'label' => $this->translator->trans('part.table.storeLocations'), |
198 | - 'render' => function ($value, Part $context) { |
|
198 | + 'render' => function($value, Part $context) { |
|
199 | 199 | $tmp = []; |
200 | 200 | foreach ($context->getPartLots() as $lot) { |
201 | 201 | //Ignore lots without storelocation |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | ]) |
215 | 215 | ->add('amount', TextColumn::class, [ |
216 | 216 | 'label' => $this->translator->trans('part.table.amount'), |
217 | - 'render' => function ($value, Part $context) { |
|
217 | + 'render' => function($value, Part $context) { |
|
218 | 218 | $amount = $context->getAmountSum(); |
219 | 219 | |
220 | 220 | return $this->amountFormatter->format($amount, $context->getPartUnit()); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | ->add('minamount', TextColumn::class, [ |
224 | 224 | 'label' => $this->translator->trans('part.table.minamount'), |
225 | 225 | 'visible' => false, |
226 | - 'render' => function ($value, Part $context) { |
|
226 | + 'render' => function($value, Part $context) { |
|
227 | 227 | return $this->amountFormatter->format($value, $context->getPartUnit()); |
228 | 228 | }, |
229 | 229 | ]) |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | ->addOrderBy('name') |
288 | 288 | ->createAdapter(FetchJoinORMAdapter::class, [ |
289 | 289 | 'simple_total_query' => true, |
290 | - 'query' => function (QueryBuilder $builder): void { |
|
290 | + 'query' => function(QueryBuilder $builder): void { |
|
291 | 291 | $this->getQuery($builder); |
292 | 292 | }, |
293 | 293 | 'entity' => Part::class, |
294 | 294 | 'criteria' => [ |
295 | - function (QueryBuilder $builder) use ($options): void { |
|
295 | + function(QueryBuilder $builder) use ($options): void { |
|
296 | 296 | $this->buildCriteria($builder, $options); |
297 | 297 | }, |
298 | 298 | new SearchCriteriaProvider(), |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | $builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%'); |
376 | 376 | } |
377 | 377 | |
378 | - if (! empty($options['search'])) { |
|
379 | - if (! $options['search_options']['regex']) { |
|
378 | + if (!empty($options['search'])) { |
|
379 | + if (!$options['search_options']['regex']) { |
|
380 | 380 | //Dont show results, if no things are selected |
381 | 381 | $builder->andWhere('0=1'); |
382 | 382 | $defined = false; |
@@ -66,7 +66,7 @@ |
||
66 | 66 | return ''; |
67 | 67 | } |
68 | 68 | |
69 | - $disabled = ! $this->security->isGranted('revert_element', $context->getTargetClass()); |
|
69 | + $disabled = !$this->security->isGranted('revert_element', $context->getTargetClass()); |
|
70 | 70 | |
71 | 71 | $tmp = '<div class="btn-group btn-group-sm">'; |
72 | 72 | $tmp .= sprintf( |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | //When user change its settings, he should be logged in fully. |
85 | 85 | $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); |
86 | 86 | |
87 | - if (! $user instanceof User) { |
|
87 | + if (!$user instanceof User) { |
|
88 | 88 | return new RuntimeException('This controller only works only for Part-DB User objects!'); |
89 | 89 | } |
90 | 90 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | //When user change its settings, he should be logged in fully. |
116 | 116 | $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); |
117 | 117 | |
118 | - if (! $user instanceof User) { |
|
118 | + if (!$user instanceof User) { |
|
119 | 119 | throw new RuntimeException('This controller only works only for Part-DB User objects!'); |
120 | 120 | } |
121 | 121 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | //When user change its settings, he should be logged in fully. |
167 | 167 | $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); |
168 | 168 | |
169 | - if (! $user instanceof User) { |
|
169 | + if (!$user instanceof User) { |
|
170 | 170 | return new RuntimeException('This controller only works only for Part-DB User objects!'); |
171 | 171 | } |
172 | 172 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | //When user change its settings, he should be logged in fully. |
197 | 197 | $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); |
198 | 198 | |
199 | - if (! $user instanceof User) { |
|
199 | + if (!$user instanceof User) { |
|
200 | 200 | throw new RuntimeException('This controller only works only for Part-DB User objects!'); |
201 | 201 | } |
202 | 202 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | $form->handleRequest($request); |
210 | 210 | |
211 | - if (! $this->demo_mode && $form->isSubmitted() && $form->isValid()) { |
|
211 | + if (!$this->demo_mode && $form->isSubmitted() && $form->isValid()) { |
|
212 | 212 | //Check if user theme setting has changed |
213 | 213 | if ($user->getTheme() !== $em->getUnitOfWork()->getOriginalEntityData($user)['theme']) { |
214 | 214 | $page_need_reload = true; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $pw_form->handleRequest($request); |
269 | 269 | |
270 | 270 | //Check if password if everything was correct, then save it to User and DB |
271 | - if (! $this->demo_mode && $pw_form->isSubmitted() && $pw_form->isValid()) { |
|
271 | + if (!$this->demo_mode && $pw_form->isSubmitted() && $pw_form->isValid()) { |
|
272 | 272 | $password = $passwordEncoder->encodePassword($user, $pw_form['new_password']->getData()); |
273 | 273 | $user->setPassword($password); |
274 | 274 | |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | //Handle 2FA things |
284 | 284 | $google_form = $this->createForm(TFAGoogleSettingsType::class, $user); |
285 | 285 | $google_enabled = $user->isGoogleAuthenticatorEnabled(); |
286 | - if (! $google_enabled && ! $form->isSubmitted()) { |
|
286 | + if (!$google_enabled && !$form->isSubmitted()) { |
|
287 | 287 | $user->setGoogleAuthenticatorSecret($googleAuthenticator->generateSecret()); |
288 | 288 | $google_form->get('googleAuthenticatorSecret')->setData($user->getGoogleAuthenticatorSecret()); |
289 | 289 | } |
290 | 290 | $google_form->handleRequest($request); |
291 | 291 | |
292 | - if (! $this->demo_mode && $google_form->isSubmitted() && $google_form->isValid()) { |
|
293 | - if (! $google_enabled) { |
|
292 | + if (!$this->demo_mode && $google_form->isSubmitted() && $google_form->isValid()) { |
|
293 | + if (!$google_enabled) { |
|
294 | 294 | //Save 2FA settings (save secrets) |
295 | 295 | $user->setGoogleAuthenticatorSecret($google_form->get('googleAuthenticatorSecret')->getData()); |
296 | 296 | $backupCodeManager->enableBackupCodes($user); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | ])->getForm(); |
319 | 319 | |
320 | 320 | $backup_form->handleRequest($request); |
321 | - if (! $this->demo_mode && $backup_form->isSubmitted() && $backup_form->isValid()) { |
|
321 | + if (!$this->demo_mode && $backup_form->isSubmitted() && $backup_form->isValid()) { |
|
322 | 322 | $backupCodeManager->regenerateBackupCodes($user); |
323 | 323 | $em->flush(); |
324 | 324 | $this->addFlash('success', 'user.settings.2fa.backup_codes.regenerated'); |