Completed
Pull Request — master (#1332)
by Tonina
33:24 queued 25:44
created
app/Routes.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\App;
6 6
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 		$app->post(
63 63
 			'validate-donation-amount',
64
-			function ( Request $httpRequest ) use ( $app, $ffFactory ) {
64
+			function( Request $httpRequest ) use ( $app, $ffFactory ) {
65 65
 
66 66
 				$constraint = new Collection(
67 67
 					[
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 
77 77
 				if ( $violations->count() > 0 ) {
78 78
 					$mapper = new ConstraintViolationListMapper();
79
-					return $app->json( [ 'status' => 'ERR', 'messages' => $mapper->map( $violations ) ] );
79
+					return $app->json( ['status' => 'ERR', 'messages' => $mapper->map( $violations )] );
80 80
 				}
81 81
 
82
-				return $app->json( [ 'status' => 'OK' ] );
82
+				return $app->json( ['status' => 'OK'] );
83 83
 			}
84 84
 		);
85 85
 
86 86
 		$app->post(
87 87
 			'validate-fee',
88
-			function ( Request $httpRequest ) use ( $app ) {
88
+			function( Request $httpRequest ) use ( $app ) {
89 89
 				$validator = new MembershipFeeValidator();
90 90
 				$result = $validator->validate(
91 91
 					str_replace( ',', '.', $httpRequest->request->get( 'amount', '' ) ),
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 				);
95 95
 
96 96
 				if ( $result->isSuccessful() ) {
97
-					return $app->json( [ 'status' => 'OK' ] );
97
+					return $app->json( ['status' => 'OK'] );
98 98
 				} else {
99 99
 					$errors = $result->getViolations();
100
-					return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] );
100
+					return $app->json( ['status' => 'ERR', 'messages' => $errors] );
101 101
 				}
102 102
 			}
103 103
 		);
104 104
 
105 105
 		$app->get(
106 106
 			'list-comments.json',
107
-			function ( Request $request ) use ( $app, $ffFactory ) {
107
+			function( Request $request ) use ( $app, $ffFactory ) {
108 108
 				$response = $app->json(
109 109
 					$ffFactory->newCommentListJsonPresenter()->present(
110 110
 						$ffFactory->newListCommentsUseCase()->listComments(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 		$app->get(
128 128
 			'list-comments.rss',
129
-			function () use ( $ffFactory ) {
129
+			function() use ( $ffFactory ) {
130 130
 				$rss = $ffFactory->newCommentListRssPresenter()->present(
131 131
 					$ffFactory->newListCommentsUseCase()->listComments(
132 132
 						new CommentListingRequest( 100, CommentListingRequest::FIRST_PAGE )
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 		$app->get(
148 148
 			'list-comments.html',
149
-			function ( Request $request ) use ( $ffFactory ) {
149
+			function( Request $request ) use ( $ffFactory ) {
150 150
 				return new Response(
151 151
 					$ffFactory->newCommentListHtmlPresenter()->present(
152 152
 						$ffFactory->newListCommentsUseCase()->listComments(
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 		$app->get(
165 165
 			'page/{pageName}',
166
-			function ( Application $app, $pageName ) use ( $ffFactory ) {
166
+			function( Application $app, $pageName ) use ( $ffFactory ) {
167 167
 				return ( new \WMDE\Fundraising\Frontend\App\RouteHandlers\PageDisplayHandler( $ffFactory, $app ) )
168 168
 					->handle( $pageName );
169 169
 			}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		// Form for this is provided by route page/Subscription_Form
174 174
 		$app->match(
175 175
 			'contact/subscribe',
176
-			function ( Application $app, Request $request ) use ( $ffFactory ) {
176
+			function( Application $app, Request $request ) use ( $ffFactory ) {
177 177
 				return ( new AddSubscriptionHandler( $ffFactory, $app ) )
178 178
 					->handle( $request );
179 179
 			}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$app->get(
185 185
 			'contact/confirm-subscription/{confirmationCode}',
186
-			function ( $confirmationCode ) use ( $ffFactory ) {
186
+			function( $confirmationCode ) use ( $ffFactory ) {
187 187
 				$useCase = $ffFactory->newConfirmSubscriptionUseCase();
188 188
 				$response = $useCase->confirmSubscription( $confirmationCode );
189 189
 				return $ffFactory->newConfirmSubscriptionHtmlPresenter()->present( $response );
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 		$app->get(
196 196
 			'check-iban',
197
-			function ( Request $request ) use ( $app, $ffFactory ) {
197
+			function( Request $request ) use ( $app, $ffFactory ) {
198 198
 				$useCase = $ffFactory->newCheckIbanUseCase();
199 199
 				$checkIbanResponse = $useCase->checkIban( new Iban( $request->query->get( 'iban', '' ) ) );
200 200
 				return $app->json( $ffFactory->newIbanPresenter()->present( $checkIbanResponse ) );
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 		$app->get(
205 205
 			'generate-iban',
206
-			function ( Request $request ) use ( $app, $ffFactory ) {
206
+			function( Request $request ) use ( $app, $ffFactory ) {
207 207
 				$generateIbanRequest = new GenerateIbanRequest(
208 208
 					$request->query->get( 'accountNumber', '' ),
209 209
 					$request->query->get( 'bankCode', '' )
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
 		$app->post(
218 218
 			'add-comment',
219
-			function ( Request $request ) use ( $app, $ffFactory ) {
219
+			function( Request $request ) use ( $app, $ffFactory ) {
220 220
 				$addCommentRequest = new AddCommentRequest();
221 221
 				$addCommentRequest->setCommentText( trim( $request->request->get( 'comment', '' ) ) );
222 222
 				$addCommentRequest->setIsPublic( $request->request->get( 'public', '0' ) === '1' );
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
 		$app->get(
265 265
 			'add-comment',
266
-			function ( Request $request ) use ( $app, $ffFactory ) {
266
+			function( Request $request ) use ( $app, $ffFactory ) {
267 267
 				$template = $ffFactory->getLayoutTemplate(
268 268
 					'Donation_Comment.html.twig'
269 269
 				);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
 		$app->post(
290 290
 			'contact/get-in-touch',
291
-			function ( Request $request ) use ( $app, $ffFactory ) {
291
+			function( Request $request ) use ( $app, $ffFactory ) {
292 292
 				$contactFormRequest = new GetInTouchRequest(
293 293
 					$request->get( 'firstname', '' ),
294 294
 					$request->get( 'lastname', '' ),
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 				$contactFormResponse = $ffFactory->newGetInTouchUseCase()->processContactRequest( $contactFormRequest );
303 303
 				if ( $contactFormResponse->isSuccessful() ) {
304 304
 					return $app->redirect(
305
-						$app['url_generator']->generate( 'page', [ 'pageName' => 'Kontakt_Bestaetigung' ] )
305
+						$app['url_generator']->generate( 'page', ['pageName' => 'Kontakt_Bestaetigung'] )
306 306
 					);
307 307
 				}
308 308
 
@@ -315,23 +315,23 @@  discard block
 block discarded – undo
315 315
 
316 316
 		$app->get(
317 317
 			'contact/get-in-touch',
318
-			function () use ( $ffFactory ) {
318
+			function() use ( $ffFactory ) {
319 319
 				return $ffFactory->getLayoutTemplate( 'contact_form.html.twig' )->render(
320
-					[ 'contact_categories' => $ffFactory->getGetInTouchCategories() ]
320
+					['contact_categories' => $ffFactory->getGetInTouchCategories()]
321 321
 				);
322 322
 			}
323 323
 		)->bind( 'contact' );
324 324
 
325 325
 		$app->get(
326 326
 			'contact/faq',
327
-			function () use ( $ffFactory ) {
327
+			function() use ( $ffFactory ) {
328 328
 				return $ffFactory->getLayoutTemplate( 'page_layouts/faq.html.twig' )->render( [] );
329 329
 			}
330 330
 		);
331 331
 
332 332
 		$app->post(
333 333
 			'donation/cancel',
334
-			function ( Request $request ) use ( $ffFactory ) {
334
+			function( Request $request ) use ( $ffFactory ) {
335 335
 				$cancellationRequest = new CancelDonationRequest(
336 336
 					(int)$request->request->get( 'sid', '' )
337 337
 				);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 		$app->post(
352 352
 			'donation/add',
353
-			function ( Application $app, Request $request ) use ( $ffFactory ) {
353
+			function( Application $app, Request $request ) use ( $ffFactory ) {
354 354
 				return ( new AddDonationHandler( $ffFactory, $app ) )
355 355
 					->handle( $request );
356 356
 			}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		// Show a donation form with pre-filled payment values, e.g. when coming from a banner
365 365
 		$app->get(
366 366
 			'donation/new',
367
-			function ( Application $app, Request $request ) use ( $ffFactory ) {
367
+			function( Application $app, Request $request ) use ( $ffFactory ) {
368 368
 				$app['session']->set(
369 369
 					'piwikTracking',
370 370
 					array_filter(
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 							'paymentAmount' => $request->get( 'betrag', '' ),
374 374
 							'paymentInterval' => $request->get( 'periode', '' )
375 375
 						],
376
-						function ( string $value ) {
376
+						function( string $value ) {
377 377
 							return $value !== '' && strlen( $value ) < 20;
378 378
 						}
379 379
 					)
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 				try {
383 383
 					$amount = Euro::newFromFloat(
384 384
 						( new AmountParser( 'en_EN' ) )->parseAsFloat(
385
-							$request->get( 'betrag_auswahl', $request->get( 'betrag',  $request->get( 'amountGiven', '' ) ) )
385
+							$request->get( 'betrag_auswahl', $request->get( 'betrag', $request->get( 'amountGiven', '' ) ) )
386 386
 						)
387 387
 					);
388 388
 				}
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
 
416 416
 		$app->post(
417 417
 			'apply-for-membership',
418
-			function ( Application $app, Request $httpRequest ) use ( $ffFactory ) {
418
+			function( Application $app, Request $httpRequest ) use ( $ffFactory ) {
419 419
 				return ( new ApplyForMembershipHandler( $ffFactory, $app ) )->handle( $httpRequest );
420 420
 			}
421 421
 		);
422 422
 
423 423
 		$app->get(
424 424
 			'apply-for-membership',
425
-			function ( Request $request ) use ( $ffFactory ) {
425
+			function( Request $request ) use ( $ffFactory ) {
426 426
 				$params = [];
427 427
 
428 428
 				if ( $request->query->get( 'type' ) === 'sustaining' ) {
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 
453 453
 		$app->get(
454 454
 			'show-membership-confirmation',
455
-			function ( Request $request ) use ( $ffFactory ) {
455
+			function( Request $request ) use ( $ffFactory ) {
456 456
 				$presenter = $ffFactory->newMembershipApplicationConfirmationHtmlPresenter();
457 457
 
458 458
 				$useCase = $ffFactory->newMembershipApplicationConfirmationUseCase(
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 
469 469
 		$app->get(
470 470
 			'cancel-membership-application',
471
-			function ( Request $request ) use ( $ffFactory ) {
471
+			function( Request $request ) use ( $ffFactory ) {
472 472
 				$cancellationRequest = new CancellationRequest(
473 473
 					(int)$request->query->get( 'id', '' )
474 474
 				);
@@ -488,21 +488,21 @@  discard block
 block discarded – undo
488 488
 
489 489
 		$app->post(
490 490
 			'handle-paypal-payment-notification',
491
-			function ( Request $request ) use ( $ffFactory ) {
491
+			function( Request $request ) use ( $ffFactory ) {
492 492
 				return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request );
493 493
 			}
494 494
 		);
495 495
 
496 496
 		$app->post(
497 497
 			'sofort-payment-notification',
498
-			function ( Request $request ) use ( $ffFactory ) {
498
+			function( Request $request ) use ( $ffFactory ) {
499 499
 				return ( new SofortNotificationHandler( $ffFactory ) )->handle( $request );
500 500
 			}
501 501
 		);
502 502
 
503 503
 		$app->get(
504 504
 			'handle-creditcard-payment-notification',
505
-			function ( Request $request ) use ( $ffFactory ) {
505
+			function( Request $request ) use ( $ffFactory ) {
506 506
 				try {
507 507
 					$ffFactory->newCreditCardNotificationUseCase( $request->query->get( 'utoken', '' ) )
508 508
 						->handleNotification(
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
 		$app->get(
535 535
 			'donation-accepted',
536
-			function ( Request $request ) use ( $app, $ffFactory ) {
536
+			function( Request $request ) use ( $app, $ffFactory ) {
537 537
 
538 538
 				$eventHandler = $ffFactory->newDonationAcceptedEventHandler(
539 539
 					$request->query->get( 'update_token', '' )
@@ -541,21 +541,21 @@  discard block
 block discarded – undo
541 541
 				$result = $eventHandler->onDonationAccepted( (int)$request->query->get( 'donation_id', '' ) );
542 542
 
543 543
 				return $app->json(
544
-					$result === null ? [ 'status' => 'OK' ] : [ 'status' => 'ERR', 'message' => $result ]
544
+					$result === null ? ['status' => 'OK'] : ['status' => 'ERR', 'message' => $result]
545 545
 				);
546 546
 			}
547 547
 		);
548 548
 
549 549
 		$app->post(
550 550
 			'handle-paypal-membership-fee-payments',
551
-			function ( Request $request ) use ( $ffFactory ) {
551
+			function( Request $request ) use ( $ffFactory ) {
552 552
 				return ( new PayPalNotificationHandlerForMembershipFee( $ffFactory ) )->handle( $request->request );
553 553
 			}
554 554
 		);
555 555
 
556 556
 		$app->get(
557 557
 			'/',
558
-			function ( Application $app, Request $request ) {
558
+			function( Application $app, Request $request ) {
559 559
 				return $app->handle(
560 560
 					Request::create(
561 561
 						'/donation/new',
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 		// See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url
575 575
 		$app->post(
576 576
 			'/spenden/paypal_handler.php',
577
-			function ( Request $request ) use ( $ffFactory ) {
577
+			function( Request $request ) use ( $ffFactory ) {
578 578
 				return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request );
579 579
 			}
580 580
 		);
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		// redirect display page requests from old URLs
583 583
 		$app->get(
584 584
 			'/spenden/{page}',
585
-			function ( Application $app, Request $request, string $page ) {
585
+			function( Application $app, Request $request, string $page ) {
586 586
 				// Poor man's rewrite until someone has figured out how to do this with Nginx without breaking REQUEST_URI
587 587
 				// See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url
588 588
 				switch ( $page ) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		// redirect different formats of comment lists
602 602
 		$app->get(
603 603
 			'/spenden/{outputFormat}.php',
604
-			function ( Application $app, Request $request, string $outputFormat ) {
604
+			function( Application $app, Request $request, string $outputFormat ) {
605 605
 				return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle(
606 606
 					'/list-comments.' . ( $outputFormat === 'list' ? 'html' : $outputFormat )
607 607
 				);
@@ -611,14 +611,14 @@  discard block
 block discarded – undo
611 611
 		// redirect all other calls to default route
612 612
 		$app->get(
613 613
 			'/spenden{page}',
614
-			function ( Application $app, Request $request ) {
614
+			function( Application $app, Request $request ) {
615 615
 				return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/' );
616 616
 			}
617 617
 		)->assert( 'page', '/?([a-z]+\.php)?' );
618 618
 
619 619
 		$app->get(
620 620
 			'/purge-cache',
621
-			function ( Request $request ) use ( $ffFactory ) {
621
+			function( Request $request ) use ( $ffFactory ) {
622 622
 				$response = $ffFactory->newAuthorizedCachePurger()->purgeCache( $request->query->get( 'secret', '' ) );
623 623
 
624 624
 				return new Response(
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 
634 634
 		$app->get(
635 635
 			'status',
636
-			function () {
636
+			function() {
637 637
 				return 'Status: OK (Online)';
638 638
 			}
639 639
 		);
Please login to merge, or discard this patch.