@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @var \WMDE\Fundraising\Frontend\Factories\FunFunFactory $ffFactory |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -declare( strict_types = 1 ); |
|
| 9 | +declare(strict_types = 1); |
|
| 10 | 10 | |
| 11 | 11 | use Silex\Application; |
| 12 | 12 | use Silex\Provider\RoutingServiceProvider; |
@@ -21,101 +21,101 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $app = new Application(); |
| 23 | 23 | |
| 24 | -$app->register( new SessionServiceProvider() ); |
|
| 25 | -$app->register( new RoutingServiceProvider() ); |
|
| 26 | -$app->register( new TwigServiceProvider() ); |
|
| 24 | +$app->register(new SessionServiceProvider()); |
|
| 25 | +$app->register(new RoutingServiceProvider()); |
|
| 26 | +$app->register(new TwigServiceProvider()); |
|
| 27 | 27 | |
| 28 | 28 | $app->before( |
| 29 | - function ( Request $request, Application $app ) { |
|
| 30 | - $app['request_stack.is_json'] = in_array( 'application/json', $request->getAcceptableContentTypes() ); |
|
| 29 | + function(Request $request, Application $app) { |
|
| 30 | + $app['request_stack.is_json'] = in_array('application/json', $request->getAcceptableContentTypes()); |
|
| 31 | 31 | |
| 32 | - $request->attributes->set( 'trackingCode', TrackingDataSelector::getFirstNonEmptyValue( [ |
|
| 33 | - $request->cookies->get( 'spenden_tracking' ), |
|
| 34 | - $request->request->get( 'tracking' ), |
|
| 32 | + $request->attributes->set('trackingCode', TrackingDataSelector::getFirstNonEmptyValue([ |
|
| 33 | + $request->cookies->get('spenden_tracking'), |
|
| 34 | + $request->request->get('tracking'), |
|
| 35 | 35 | TrackingDataSelector::concatTrackingFromVarTuple( |
| 36 | - $request->get( 'piwik_campaign', '' ), |
|
| 37 | - $request->get( 'piwik_kwd', '' ) |
|
| 36 | + $request->get('piwik_campaign', ''), |
|
| 37 | + $request->get('piwik_kwd', '') |
|
| 38 | 38 | ) |
| 39 | - ] ) ); |
|
| 39 | + ])); |
|
| 40 | 40 | |
| 41 | - $request->attributes->set( 'trackingSource', TrackingDataSelector::getFirstNonEmptyValue( [ |
|
| 42 | - $request->cookies->get( 'spenden_source' ), |
|
| 43 | - $request->request->get( 'source' ), |
|
| 44 | - $request->server->get( 'HTTP_REFERER' ) |
|
| 45 | - ] ) ); |
|
| 41 | + $request->attributes->set('trackingSource', TrackingDataSelector::getFirstNonEmptyValue([ |
|
| 42 | + $request->cookies->get('spenden_source'), |
|
| 43 | + $request->request->get('source'), |
|
| 44 | + $request->server->get('HTTP_REFERER') |
|
| 45 | + ])); |
|
| 46 | 46 | }, |
| 47 | 47 | Application::EARLY_EVENT |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | -$app->before( function( Request $request ) { |
|
| 51 | - foreach ( [ $request->request, $request->query ] as $parameterBag ) { |
|
| 52 | - foreach ( $parameterBag->keys() as $key ) { |
|
| 53 | - if ( is_string( $parameterBag->get( $key ) ) ) { |
|
| 54 | - $parameterBag->set( $key, trim( $parameterBag->get( $key ) ) ); |
|
| 50 | +$app->before(function(Request $request) { |
|
| 51 | + foreach ([$request->request, $request->query] as $parameterBag) { |
|
| 52 | + foreach ($parameterBag->keys() as $key) { |
|
| 53 | + if (is_string($parameterBag->get($key))) { |
|
| 54 | + $parameterBag->set($key, trim($parameterBag->get($key))); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | -}, Application::EARLY_EVENT ); |
|
| 58 | +}, Application::EARLY_EVENT); |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | -$app->after( function( Request $request, Response $response, Application $app ) { |
|
| 62 | - if( $response instanceof JsonResponse ) { |
|
| 63 | - $response->setEncodingOptions( JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); |
|
| 61 | +$app->after(function(Request $request, Response $response, Application $app) { |
|
| 62 | + if ($response instanceof JsonResponse) { |
|
| 63 | + $response->setEncodingOptions(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Set cookie with original tracking data |
| 67 | - if ( (string)$request->cookies->get( 'spenden_tracking' ) === '' && |
|
| 68 | - (string)$request->get( 'piwik_campaign' ) !== '' && (string)$request->get( 'piwik_kwd' ) !== '' ) { |
|
| 69 | - $response->headers->setCookie( new \Symfony\Component\HttpFoundation\Cookie( |
|
| 67 | + if ((string)$request->cookies->get('spenden_tracking') === '' && |
|
| 68 | + (string)$request->get('piwik_campaign') !== '' && (string)$request->get('piwik_kwd') !== '') { |
|
| 69 | + $response->headers->setCookie(new \Symfony\Component\HttpFoundation\Cookie( |
|
| 70 | 70 | 'spenden_tracking', |
| 71 | - $request->get( 'piwik_campaign' ) . '/' . $request->get( 'piwik_kwd' ) |
|
| 72 | - ) ); |
|
| 71 | + $request->get('piwik_campaign') . '/' . $request->get('piwik_kwd') |
|
| 72 | + )); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $response; |
| 76 | 76 | } ); |
| 77 | 77 | |
| 78 | -$app->error( function ( AccessDeniedException $e ) use ( $ffFactory ) { |
|
| 78 | +$app->error(function(AccessDeniedException $e) use ($ffFactory) { |
|
| 79 | 79 | return new Response( |
| 80 | - $ffFactory->newAccessDeniedHTMLPresenter()->present( $e ), |
|
| 80 | + $ffFactory->newAccessDeniedHTMLPresenter()->present($e), |
|
| 81 | 81 | 403, |
| 82 | - [ 'X-Status-Code' => 403 ] |
|
| 82 | + ['X-Status-Code' => 403] |
|
| 83 | 83 | ); |
| 84 | 84 | } ); |
| 85 | 85 | |
| 86 | -$app->error( function ( NotFoundHttpException $e ) use ( $ffFactory, $app ) { |
|
| 87 | - if ( $app['request_stack.is_json'] ) { |
|
| 88 | - return $app->json( [ 'ERR' => $e->getMessage() ], 404, [ 'X-Status-Code' => 404 ] ); |
|
| 86 | +$app->error(function(NotFoundHttpException $e) use ($ffFactory, $app) { |
|
| 87 | + if ($app['request_stack.is_json']) { |
|
| 88 | + return $app->json(['ERR' => $e->getMessage()], 404, ['X-Status-Code' => 404]); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return new Response( |
| 92 | 92 | $ffFactory->newPageNotFoundHTMLPresenter()->present(), |
| 93 | 93 | 404, |
| 94 | - [ 'X-Status-Code' => 404 ] |
|
| 94 | + ['X-Status-Code' => 404] |
|
| 95 | 95 | ); |
| 96 | 96 | } ); |
| 97 | 97 | |
| 98 | 98 | |
| 99 | -$app->error( function ( \Exception $e, Request $request, $code ) use ( $ffFactory, $app ) { |
|
| 100 | - if ( $app['debug'] ) { |
|
| 99 | +$app->error(function(\Exception $e, Request $request, $code) use ($ffFactory, $app) { |
|
| 100 | + if ($app['debug']) { |
|
| 101 | 101 | throw $e; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $ffFactory->getLogger()->error( $e->getMessage(), [ |
|
| 104 | + $ffFactory->getLogger()->error($e->getMessage(), [ |
|
| 105 | 105 | 'code' => $e->getCode(), |
| 106 | 106 | 'file' => $e->getFile(), |
| 107 | 107 | 'line' => $e->getLine(), |
| 108 | 108 | 'stack_trace' => $e->getTraceAsString() |
| 109 | - ] ); |
|
| 109 | + ]); |
|
| 110 | 110 | |
| 111 | - if ( $app['request_stack.is_json'] ) { |
|
| 112 | - return $app->json( [ |
|
| 111 | + if ($app['request_stack.is_json']) { |
|
| 112 | + return $app->json([ |
|
| 113 | 113 | 'ERR' => $e->getMessage() |
| 114 | - ] ); |
|
| 114 | + ]); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | return new Response( |
| 118 | - $ffFactory->newInternalErrorHTMLPresenter()->present( $e ), |
|
| 118 | + $ffFactory->newInternalErrorHTMLPresenter()->present($e), |
|
| 119 | 119 | $code |
| 120 | 120 | ); |
| 121 | 121 | } ); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @var \WMDE\Fundraising\Frontend\Factories\FunFunFactory $ffFactory |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -declare( strict_types = 1 ); |
|
| 10 | +declare(strict_types = 1); |
|
| 11 | 11 | |
| 12 | 12 | use Silex\Application; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Request; |
@@ -43,129 +43,129 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $app->post( |
| 45 | 45 | 'validate-email', |
| 46 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 47 | - $validationResult = $ffFactory->getEmailValidator()->validate( $request->request->get( 'email', '' ) ); |
|
| 48 | - return $app->json( [ 'status' => $validationResult->isSuccessful() ? 'OK' : 'ERR' ] ); |
|
| 46 | + function(Request $request) use ($app, $ffFactory) { |
|
| 47 | + $validationResult = $ffFactory->getEmailValidator()->validate($request->request->get('email', '')); |
|
| 48 | + return $app->json(['status' => $validationResult->isSuccessful() ? 'OK' : 'ERR']); |
|
| 49 | 49 | } |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | $app->post( |
| 53 | 53 | 'validate-payment-data', |
| 54 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 54 | + function(Request $request) use ($app, $ffFactory) { |
|
| 55 | 55 | |
| 56 | - $amount = (float) $ffFactory->newDecimalNumberFormatter()->parse( $request->get( 'amount', '0' ) ); |
|
| 56 | + $amount = (float)$ffFactory->newDecimalNumberFormatter()->parse($request->get('amount', '0')); |
|
| 57 | 57 | $validator = $ffFactory->newPaymentDataValidator(); |
| 58 | - $validationResult = $validator->validate( $amount, (string) $request->get( 'paymentType', '' ) ); |
|
| 58 | + $validationResult = $validator->validate($amount, (string)$request->get('paymentType', '')); |
|
| 59 | 59 | |
| 60 | - if ( $validationResult->isSuccessful() ) { |
|
| 61 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 60 | + if ($validationResult->isSuccessful()) { |
|
| 61 | + return $app->json(['status' => 'OK']); |
|
| 62 | 62 | } else { |
| 63 | 63 | $errors = []; |
| 64 | - foreach( $validationResult->getViolations() as $violation ) { |
|
| 65 | - $errors[ $violation->getSource() ] = $ffFactory->getTranslator()->trans( $violation->getMessageIdentifier() ); |
|
| 64 | + foreach ($validationResult->getViolations() as $violation) { |
|
| 65 | + $errors[$violation->getSource()] = $ffFactory->getTranslator()->trans($violation->getMessageIdentifier()); |
|
| 66 | 66 | } |
| 67 | - return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] ); |
|
| 67 | + return $app->json(['status' => 'ERR', 'messages' => $errors]); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | $app->post( |
| 73 | 73 | 'validate-address', |
| 74 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 74 | + function(Request $request) use ($app, $ffFactory) { |
|
| 75 | 75 | $routeHandler = new class() { |
| 76 | 76 | |
| 77 | - public function handle( FunFunFactory $ffFactory, Application $app, Request $request ) { |
|
| 78 | - if ( $request->get( 'adressType', '' ) === 'anonym' ) { |
|
| 79 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 77 | + public function handle(FunFunFactory $ffFactory, Application $app, Request $request) { |
|
| 78 | + if ($request->get('adressType', '') === 'anonym') { |
|
| 79 | + return $app->json(['status' => 'OK']); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $personalInfo = $this->getPersonalInfoFromRequest( $request ); |
|
| 82 | + $personalInfo = $this->getPersonalInfoFromRequest($request); |
|
| 83 | 83 | $personalInfoValidator = $ffFactory->newPersonalInfoValidator(); |
| 84 | - $validationResult = $personalInfoValidator->validate( $personalInfo ); |
|
| 84 | + $validationResult = $personalInfoValidator->validate($personalInfo); |
|
| 85 | 85 | |
| 86 | - if ( $validationResult->isSuccessful() ) { |
|
| 87 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 86 | + if ($validationResult->isSuccessful()) { |
|
| 87 | + return $app->json(['status' => 'OK']); |
|
| 88 | 88 | } else { |
| 89 | 89 | $errors = []; |
| 90 | - foreach( $validationResult->getViolations() as $violation ) { |
|
| 91 | - $errors[$violation->getSource()] = $ffFactory->getTranslator()->trans( $violation->getMessageIdentifier() ); |
|
| 90 | + foreach ($validationResult->getViolations() as $violation) { |
|
| 91 | + $errors[$violation->getSource()] = $ffFactory->getTranslator()->trans($violation->getMessageIdentifier()); |
|
| 92 | 92 | } |
| 93 | - return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] ); |
|
| 93 | + return $app->json(['status' => 'ERR', 'messages' => $errors]); |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - private function getPersonalInfoFromRequest( Request $request ): Donor { |
|
| 97 | + private function getPersonalInfoFromRequest(Request $request): Donor { |
|
| 98 | 98 | return new Donor( |
| 99 | - $this->getNameFromRequest( $request ), |
|
| 100 | - $this->getPhysicalAddressFromRequest( $request ), |
|
| 101 | - $request->get( 'email', '' ) |
|
| 99 | + $this->getNameFromRequest($request), |
|
| 100 | + $this->getPhysicalAddressFromRequest($request), |
|
| 101 | + $request->get('email', '') |
|
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - private function getPhysicalAddressFromRequest( Request $request ): DonorAddress { |
|
| 105 | + private function getPhysicalAddressFromRequest(Request $request): DonorAddress { |
|
| 106 | 106 | $address = new DonorAddress(); |
| 107 | 107 | |
| 108 | - $address->setStreetAddress( $request->get( 'street', '' ) ); |
|
| 109 | - $address->setPostalCode( $request->get( 'postcode', '' ) ); |
|
| 110 | - $address->setCity( $request->get( 'city', '' ) ); |
|
| 111 | - $address->setCountryCode( $request->get( 'country', '' ) ); |
|
| 108 | + $address->setStreetAddress($request->get('street', '')); |
|
| 109 | + $address->setPostalCode($request->get('postcode', '')); |
|
| 110 | + $address->setCity($request->get('city', '')); |
|
| 111 | + $address->setCountryCode($request->get('country', '')); |
|
| 112 | 112 | |
| 113 | 113 | return $address->freeze()->assertNoNullFields(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - private function getNameFromRequest( Request $request ): DonorName { |
|
| 117 | - $name = $request->get( 'addressType', '' ) === 'firma' |
|
| 116 | + private function getNameFromRequest(Request $request): DonorName { |
|
| 117 | + $name = $request->get('addressType', '') === 'firma' |
|
| 118 | 118 | ? DonorName::newCompanyName() : DonorName::newPrivatePersonName(); |
| 119 | 119 | |
| 120 | - $name->setSalutation( $request->get( 'salutation', '' ) ); |
|
| 121 | - $name->setTitle( $request->get( 'title', '' ) ); |
|
| 122 | - $name->setCompanyName( $request->get( 'companyName', '' ) ); |
|
| 123 | - $name->setFirstName( $request->get( 'firstName', '' ) ); |
|
| 124 | - $name->setLastName( $request->get( 'lastName', '' ) ); |
|
| 120 | + $name->setSalutation($request->get('salutation', '')); |
|
| 121 | + $name->setTitle($request->get('title', '')); |
|
| 122 | + $name->setCompanyName($request->get('companyName', '')); |
|
| 123 | + $name->setFirstName($request->get('firstName', '')); |
|
| 124 | + $name->setLastName($request->get('lastName', '')); |
|
| 125 | 125 | |
| 126 | 126 | return $name->freeze()->assertNoNullFields(); |
| 127 | 127 | } |
| 128 | 128 | }; |
| 129 | 129 | |
| 130 | - return $routeHandler->handle( $ffFactory, $app, $request ); |
|
| 130 | + return $routeHandler->handle($ffFactory, $app, $request); |
|
| 131 | 131 | } |
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | 134 | $app->post( |
| 135 | 135 | 'validate-fee', |
| 136 | - function( Request $httpRequest ) use ( $app, $ffFactory ) { |
|
| 136 | + function(Request $httpRequest) use ($app, $ffFactory) { |
|
| 137 | 137 | $validator = new MembershipFeeValidator(); |
| 138 | 138 | $result = $validator->validate( |
| 139 | - str_replace( ',', '.', $httpRequest->request->get( 'amount', '' ) ), |
|
| 140 | - (int) $httpRequest->request->get( 'paymentIntervalInMonths', '0' ), |
|
| 141 | - $httpRequest->request->get( 'addressType', '' ) |
|
| 139 | + str_replace(',', '.', $httpRequest->request->get('amount', '')), |
|
| 140 | + (int)$httpRequest->request->get('paymentIntervalInMonths', '0'), |
|
| 141 | + $httpRequest->request->get('addressType', '') |
|
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | - if ( $result->isSuccessful() ) { |
|
| 145 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 144 | + if ($result->isSuccessful()) { |
|
| 145 | + return $app->json(['status' => 'OK']); |
|
| 146 | 146 | } else { |
| 147 | 147 | $errors = $result->getViolations(); |
| 148 | - return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] ); |
|
| 148 | + return $app->json(['status' => 'ERR', 'messages' => $errors]); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | ); |
| 152 | 152 | |
| 153 | 153 | $app->get( |
| 154 | 154 | 'list-comments.json', |
| 155 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 155 | + function(Request $request) use ($app, $ffFactory) { |
|
| 156 | 156 | $response = $app->json( |
| 157 | 157 | $ffFactory->newCommentListJsonPresenter()->present( |
| 158 | 158 | $ffFactory->newListCommentsUseCase()->listComments( |
| 159 | 159 | new CommentListingRequest( |
| 160 | - (int)$request->query->get( 'n', '10' ), |
|
| 161 | - (int)$request->query->get( 'page', '1' ) |
|
| 160 | + (int)$request->query->get('n', '10'), |
|
| 161 | + (int)$request->query->get('page', '1') |
|
| 162 | 162 | ) |
| 163 | 163 | ) |
| 164 | 164 | ) |
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | - if ( $request->query->get( 'f' ) ) { |
|
| 168 | - $response->setCallback( $request->query->get( 'f' ) ); |
|
| 167 | + if ($request->query->get('f')) { |
|
| 168 | + $response->setCallback($request->query->get('f')); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $response; |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $app->get( |
| 176 | 176 | 'list-comments.rss', |
| 177 | - function() use ( $app, $ffFactory ) { |
|
| 177 | + function() use ($app, $ffFactory) { |
|
| 178 | 178 | $rss = $ffFactory->newCommentListRssPresenter()->present( |
| 179 | 179 | $ffFactory->newListCommentsUseCase()->listComments( |
| 180 | - new CommentListingRequest( 100, CommentListingRequest::FIRST_PAGE ) |
|
| 180 | + new CommentListingRequest(100, CommentListingRequest::FIRST_PAGE) |
|
| 181 | 181 | ) |
| 182 | 182 | ); |
| 183 | 183 | |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $app->get( |
| 196 | 196 | 'list-comments.html', |
| 197 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 197 | + function(Request $request) use ($app, $ffFactory) { |
|
| 198 | 198 | return new Response( |
| 199 | 199 | $ffFactory->newCommentListHtmlPresenter()->present( |
| 200 | 200 | $ffFactory->newListCommentsUseCase()->listComments( |
| 201 | 201 | new CommentListingRequest( |
| 202 | 202 | 10, |
| 203 | - (int)$request->query->get( 'page', '1' ) |
|
| 203 | + (int)$request->query->get('page', '1') |
|
| 204 | 204 | ) |
| 205 | 205 | ), |
| 206 | - (int)$request->query->get( 'page', '1' ) |
|
| 206 | + (int)$request->query->get('page', '1') |
|
| 207 | 207 | ) |
| 208 | 208 | ); |
| 209 | 209 | } |
@@ -211,126 +211,126 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $app->get( |
| 213 | 213 | 'page/{pageName}', |
| 214 | - function( $pageName ) use ( $ffFactory ) { |
|
| 215 | - if ( !$ffFactory->getTemplateNameValidator()->validate( $pageName )->isSuccessful() ) { |
|
| 216 | - throw new NotFoundHttpException( "Page '$pageName' not found." ); |
|
| 214 | + function($pageName) use ($ffFactory) { |
|
| 215 | + if (!$ffFactory->getTemplateNameValidator()->validate($pageName)->isSuccessful()) { |
|
| 216 | + throw new NotFoundHttpException("Page '$pageName' not found."); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - return $ffFactory->getLayoutTemplate( 'DisplayPageLayout.twig' )->render( [ |
|
| 219 | + return $ffFactory->getLayoutTemplate('DisplayPageLayout.twig')->render([ |
|
| 220 | 220 | 'main_template' => $pageName |
| 221 | - ] ); |
|
| 221 | + ]); |
|
| 222 | 222 | } |
| 223 | 223 | ) |
| 224 | -->bind( 'page' ); |
|
| 224 | +->bind('page'); |
|
| 225 | 225 | |
| 226 | 226 | // Form for this is provided by route page/Subscription_Form |
| 227 | 227 | $app->match( |
| 228 | 228 | 'contact/subscribe', |
| 229 | - function( Application $app, Request $request ) use ( $ffFactory ) { |
|
| 230 | - return ( new AddSubscriptionHandler( $ffFactory, $app ) ) |
|
| 231 | - ->handle( $request ); |
|
| 229 | + function(Application $app, Request $request) use ($ffFactory) { |
|
| 230 | + return (new AddSubscriptionHandler($ffFactory, $app)) |
|
| 231 | + ->handle($request); |
|
| 232 | 232 | } |
| 233 | 233 | ) |
| 234 | -->method( 'GET|POST' ) |
|
| 235 | -->bind( 'subscribe' ); |
|
| 234 | +->method('GET|POST') |
|
| 235 | +->bind('subscribe'); |
|
| 236 | 236 | |
| 237 | -$app->get( 'contact/confirm-subscription/{confirmationCode}', function ( $confirmationCode ) use ( $ffFactory ) { |
|
| 237 | +$app->get('contact/confirm-subscription/{confirmationCode}', function($confirmationCode) use ($ffFactory) { |
|
| 238 | 238 | $useCase = $ffFactory->newConfirmSubscriptionUseCase(); |
| 239 | - $response = $useCase->confirmSubscription( $confirmationCode ); |
|
| 240 | - return $ffFactory->newConfirmSubscriptionHtmlPresenter()->present( $response ); |
|
| 239 | + $response = $useCase->confirmSubscription($confirmationCode); |
|
| 240 | + return $ffFactory->newConfirmSubscriptionHtmlPresenter()->present($response); |
|
| 241 | 241 | } ) |
| 242 | -->assert( 'confirmationCode', '^[0-9a-f]+$' ) |
|
| 243 | -->bind( 'confirm-subscription' ); |
|
| 242 | +->assert('confirmationCode', '^[0-9a-f]+$') |
|
| 243 | +->bind('confirm-subscription'); |
|
| 244 | 244 | |
| 245 | 245 | $app->get( |
| 246 | 246 | 'check-iban', |
| 247 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 247 | + function(Request $request) use ($app, $ffFactory) { |
|
| 248 | 248 | $useCase = $ffFactory->newCheckIbanUseCase(); |
| 249 | - $checkIbanResponse = $useCase->checkIban( new Iban( $request->query->get( 'iban', '' ) ) ); |
|
| 250 | - return $app->json( $ffFactory->newIbanPresenter()->present( $checkIbanResponse ) ); |
|
| 249 | + $checkIbanResponse = $useCase->checkIban(new Iban($request->query->get('iban', ''))); |
|
| 250 | + return $app->json($ffFactory->newIbanPresenter()->present($checkIbanResponse)); |
|
| 251 | 251 | } |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | 254 | $app->get( |
| 255 | 255 | 'generate-iban', |
| 256 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 256 | + function(Request $request) use ($app, $ffFactory) { |
|
| 257 | 257 | $generateIbanRequest = new GenerateIbanRequest( |
| 258 | - $request->query->get( 'accountNumber', '' ), |
|
| 259 | - $request->query->get( 'bankCode', '' ) |
|
| 258 | + $request->query->get('accountNumber', ''), |
|
| 259 | + $request->query->get('bankCode', '') |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $generateIbanResponse = $ffFactory->newGenerateIbanUseCase()->generateIban( $generateIbanRequest ); |
|
| 263 | - return $app->json( $ffFactory->newIbanPresenter()->present( $generateIbanResponse ) ); |
|
| 262 | + $generateIbanResponse = $ffFactory->newGenerateIbanUseCase()->generateIban($generateIbanRequest); |
|
| 263 | + return $app->json($ffFactory->newIbanPresenter()->present($generateIbanResponse)); |
|
| 264 | 264 | } |
| 265 | 265 | ); |
| 266 | 266 | |
| 267 | 267 | $app->post( |
| 268 | 268 | 'add-comment', |
| 269 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 269 | + function(Request $request) use ($app, $ffFactory) { |
|
| 270 | 270 | $addCommentRequest = new AddCommentRequest(); |
| 271 | - $addCommentRequest->setCommentText( trim( $request->request->get( 'kommentar', '' ) ) ); |
|
| 272 | - $addCommentRequest->setIsPublic( $request->request->get( 'public', '0' ) === '1' ); |
|
| 273 | - $addCommentRequest->setAuthorDisplayName( trim( $request->request->get( 'eintrag', '' ) ) ); |
|
| 274 | - $addCommentRequest->setDonationId( (int)$request->request->get( 'sid', '' ) ); |
|
| 271 | + $addCommentRequest->setCommentText(trim($request->request->get('kommentar', ''))); |
|
| 272 | + $addCommentRequest->setIsPublic($request->request->get('public', '0') === '1'); |
|
| 273 | + $addCommentRequest->setAuthorDisplayName(trim($request->request->get('eintrag', ''))); |
|
| 274 | + $addCommentRequest->setDonationId((int)$request->request->get('sid', '')); |
|
| 275 | 275 | $addCommentRequest->freeze()->assertNoNullFields(); |
| 276 | 276 | |
| 277 | - $updateToken = $request->request->get( 'utoken', '' ); |
|
| 277 | + $updateToken = $request->request->get('utoken', ''); |
|
| 278 | 278 | |
| 279 | - if ( $updateToken === '' ) { |
|
| 280 | - return $app->json( [ |
|
| 279 | + if ($updateToken === '') { |
|
| 280 | + return $app->json([ |
|
| 281 | 281 | 'status' => 'ERR', |
| 282 | - 'message' => $ffFactory->getTranslator()->trans( 'comment_failure_access_denied' ), |
|
| 283 | - ] ); |
|
| 282 | + 'message' => $ffFactory->getTranslator()->trans('comment_failure_access_denied'), |
|
| 283 | + ]); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $response = $ffFactory->newAddCommentUseCase( $updateToken )->addComment( $addCommentRequest ); |
|
| 286 | + $response = $ffFactory->newAddCommentUseCase($updateToken)->addComment($addCommentRequest); |
|
| 287 | 287 | |
| 288 | - if ( $response->isSuccessful() ) { |
|
| 289 | - return $app->json( [ |
|
| 288 | + if ($response->isSuccessful()) { |
|
| 289 | + return $app->json([ |
|
| 290 | 290 | 'status' => 'OK', |
| 291 | - 'message' => $ffFactory->getTranslator()->trans( $response->getSuccessMessage() ), |
|
| 292 | - ] ); |
|
| 291 | + 'message' => $ffFactory->getTranslator()->trans($response->getSuccessMessage()), |
|
| 292 | + ]); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - return $app->json( [ |
|
| 295 | + return $app->json([ |
|
| 296 | 296 | 'status' => 'ERR', |
| 297 | - 'message' => $ffFactory->getTranslator()->trans( $response->getErrorMessage() ), |
|
| 298 | - ] ); |
|
| 297 | + 'message' => $ffFactory->getTranslator()->trans($response->getErrorMessage()), |
|
| 298 | + ]); |
|
| 299 | 299 | } |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | 302 | $app->post( |
| 303 | 303 | 'contact/get-in-touch', |
| 304 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 304 | + function(Request $request) use ($app, $ffFactory) { |
|
| 305 | 305 | $contactFormRequest = new GetInTouchRequest( |
| 306 | - $request->get( 'firstname', '' ), |
|
| 307 | - $request->get( 'lastname', '' ), |
|
| 308 | - $request->get( 'email', '' ), |
|
| 309 | - $request->get( 'subject', '' ), |
|
| 310 | - $request->get( 'messageBody', '' ) |
|
| 306 | + $request->get('firstname', ''), |
|
| 307 | + $request->get('lastname', ''), |
|
| 308 | + $request->get('email', ''), |
|
| 309 | + $request->get('subject', ''), |
|
| 310 | + $request->get('messageBody', '') |
|
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | - $contactFormResponse = $ffFactory->newGetInTouchUseCase()->processContactRequest( $contactFormRequest ); |
|
| 314 | - if ( $contactFormResponse->isSuccessful() ) { |
|
| 315 | - return $app->redirect( $app['url_generator']->generate( 'page', [ 'pageName' => 'KontaktBestaetigung' ] ) ); |
|
| 313 | + $contactFormResponse = $ffFactory->newGetInTouchUseCase()->processContactRequest($contactFormRequest); |
|
| 314 | + if ($contactFormResponse->isSuccessful()) { |
|
| 315 | + return $app->redirect($app['url_generator']->generate('page', ['pageName' => 'KontaktBestaetigung'])); |
|
| 316 | 316 | } |
| 317 | - return $ffFactory->newGetInTouchHTMLPresenter()->present( $contactFormResponse, $request->request->all() ); |
|
| 317 | + return $ffFactory->newGetInTouchHTMLPresenter()->present($contactFormResponse, $request->request->all()); |
|
| 318 | 318 | } |
| 319 | 319 | ); |
| 320 | 320 | |
| 321 | 321 | $app->post( |
| 322 | 322 | 'donation/cancel', |
| 323 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 323 | + function(Request $request) use ($app, $ffFactory) { |
|
| 324 | 324 | $cancellationRequest = new CancelDonationRequest( |
| 325 | - (int)$request->request->get( 'sid', '' ) |
|
| 325 | + (int)$request->request->get('sid', '') |
|
| 326 | 326 | ); |
| 327 | 327 | |
| 328 | - $responseModel = $ffFactory->newCancelDonationUseCase( $request->request->get( 'utoken', '' ) ) |
|
| 329 | - ->cancelDonation( $cancellationRequest ); |
|
| 328 | + $responseModel = $ffFactory->newCancelDonationUseCase($request->request->get('utoken', '')) |
|
| 329 | + ->cancelDonation($cancellationRequest); |
|
| 330 | 330 | |
| 331 | - $httpResponse = new Response( $ffFactory->newCancelDonationHtmlPresenter()->present( $responseModel ) ); |
|
| 332 | - if ( $responseModel->cancellationSucceeded() ) { |
|
| 333 | - $httpResponse->headers->clearCookie( 'donation_timestamp' ); |
|
| 331 | + $httpResponse = new Response($ffFactory->newCancelDonationHtmlPresenter()->present($responseModel)); |
|
| 332 | + if ($responseModel->cancellationSucceeded()) { |
|
| 333 | + $httpResponse->headers->clearCookie('donation_timestamp'); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | return $httpResponse; |
@@ -340,144 +340,144 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | $app->post( |
| 342 | 342 | 'donation/add', |
| 343 | - function( Application $app, Request $request ) use ( $ffFactory ) { |
|
| 344 | - return ( new AddDonationHandler( $ffFactory, $app ) ) |
|
| 345 | - ->handle( $request ); |
|
| 343 | + function(Application $app, Request $request) use ($ffFactory) { |
|
| 344 | + return (new AddDonationHandler($ffFactory, $app)) |
|
| 345 | + ->handle($request); |
|
| 346 | 346 | } |
| 347 | 347 | ); |
| 348 | 348 | |
| 349 | 349 | // Show a donation form with pre-filled payment values, e.g. when coming from a banner |
| 350 | -$app->get( 'donation/new', function ( Request $request ) use ( $ffFactory ) { |
|
| 350 | +$app->get('donation/new', function(Request $request) use ($ffFactory) { |
|
| 351 | 351 | try { |
| 352 | - $amount = Euro::newFromFloat( ( new AmountParser( 'en_EN' ) )->parseAsFloat( |
|
| 353 | - $request->get( 'betrag_auswahl', $request->get( 'amountGiven', '' ) ) ) |
|
| 352 | + $amount = Euro::newFromFloat((new AmountParser('en_EN'))->parseAsFloat( |
|
| 353 | + $request->get('betrag_auswahl', $request->get('amountGiven', '')) ) |
|
| 354 | 354 | ); |
| 355 | - } catch ( \InvalidArgumentException $ex ) { |
|
| 356 | - $amount = Euro::newFromCents( 0 ); |
|
| 355 | + } catch (\InvalidArgumentException $ex) { |
|
| 356 | + $amount = Euro::newFromCents(0); |
|
| 357 | 357 | } |
| 358 | - $validationResult = $ffFactory->newPaymentDataValidator()->validate( $amount, (string) $request->get( 'zahlweise', '' ) ); |
|
| 358 | + $validationResult = $ffFactory->newPaymentDataValidator()->validate($amount, (string)$request->get('zahlweise', '')); |
|
| 359 | 359 | |
| 360 | 360 | $trackingInfo = new DonationTrackingInfo(); |
| 361 | - $trackingInfo->setTotalImpressionCount( intval( $request->get( 'impCount' ) ) ); |
|
| 362 | - $trackingInfo->setSingleBannerImpressionCount( intval( $request->get( 'bImpCount' ) ) ); |
|
| 361 | + $trackingInfo->setTotalImpressionCount(intval($request->get('impCount'))); |
|
| 362 | + $trackingInfo->setSingleBannerImpressionCount(intval($request->get('bImpCount'))); |
|
| 363 | 363 | |
| 364 | 364 | // TODO: don't we want to use newDonationFormViolationPresenter when !$validationResult->isSuccessful()? |
| 365 | 365 | |
| 366 | 366 | return new Response( |
| 367 | 367 | $ffFactory->newDonationFormPresenter()->present( |
| 368 | 368 | $amount, |
| 369 | - $request->get( 'zahlweise', '' ), |
|
| 370 | - intval( $request->get( 'periode', 0 ) ), |
|
| 369 | + $request->get('zahlweise', ''), |
|
| 370 | + intval($request->get('periode', 0)), |
|
| 371 | 371 | $validationResult->isSuccessful(), |
| 372 | 372 | $trackingInfo, |
| 373 | - $request->get( 'addressType', 'person' ) |
|
| 373 | + $request->get('addressType', 'person') |
|
| 374 | 374 | ) |
| 375 | 375 | ); |
| 376 | -} )->method( 'POST|GET' ); |
|
| 376 | +} )->method('POST|GET'); |
|
| 377 | 377 | |
| 378 | 378 | $app->post( |
| 379 | 379 | 'apply-for-membership', |
| 380 | - function( Application $app, Request $httpRequest ) use ( $ffFactory ) { |
|
| 381 | - return ( new ApplyForMembershipHandler( $ffFactory, $app ) )->handle( $httpRequest ); |
|
| 380 | + function(Application $app, Request $httpRequest) use ($ffFactory) { |
|
| 381 | + return (new ApplyForMembershipHandler($ffFactory, $app))->handle($httpRequest); |
|
| 382 | 382 | } |
| 383 | 383 | ); |
| 384 | 384 | |
| 385 | 385 | $app->get( |
| 386 | 386 | 'show-membership-confirmation', |
| 387 | - function( Request $request ) use ( $ffFactory ) { |
|
| 388 | - $confirmationRequest = new ShowMembershipAppConfirmationRequest( (int)$request->query->get( 'id', 0 ) ); |
|
| 387 | + function(Request $request) use ($ffFactory) { |
|
| 388 | + $confirmationRequest = new ShowMembershipAppConfirmationRequest((int)$request->query->get('id', 0)); |
|
| 389 | 389 | |
| 390 | 390 | return $ffFactory->newMembershipApplicationConfirmationHtmlPresenter()->present( |
| 391 | - $ffFactory->newMembershipApplicationConfirmationUseCase( $request->query->get( 'accessToken', '' ) ) |
|
| 392 | - ->showConfirmation( $confirmationRequest ) |
|
| 391 | + $ffFactory->newMembershipApplicationConfirmationUseCase($request->query->get('accessToken', '')) |
|
| 392 | + ->showConfirmation($confirmationRequest) |
|
| 393 | 393 | ); |
| 394 | 394 | } |
| 395 | -)->bind( 'show-membership-confirmation' ); |
|
| 395 | +)->bind('show-membership-confirmation'); |
|
| 396 | 396 | |
| 397 | 397 | $app->get( |
| 398 | 398 | 'cancel-membership-application', |
| 399 | - function( Request $request ) use ( $ffFactory ) { |
|
| 399 | + function(Request $request) use ($ffFactory) { |
|
| 400 | 400 | $cancellationRequest = new CancellationRequest( |
| 401 | - (int)$request->query->get( 'id', '' ) |
|
| 401 | + (int)$request->query->get('id', '') |
|
| 402 | 402 | ); |
| 403 | 403 | |
| 404 | 404 | return $ffFactory->newCancelMembershipApplicationHtmlPresenter()->present( |
| 405 | - $ffFactory->newCancelMembershipApplicationUseCase( $request->query->get( 'updateToken', '' ) ) |
|
| 406 | - ->cancelApplication( $cancellationRequest ) |
|
| 405 | + $ffFactory->newCancelMembershipApplicationUseCase($request->query->get('updateToken', '')) |
|
| 406 | + ->cancelApplication($cancellationRequest) |
|
| 407 | 407 | ); |
| 408 | 408 | } |
| 409 | 409 | ); |
| 410 | 410 | |
| 411 | 411 | $app->match( |
| 412 | 412 | 'show-donation-confirmation', |
| 413 | - function( Application $app, Request $request ) use ( $ffFactory ) { |
|
| 414 | - return ( new ShowDonationConfirmationHandler( $ffFactory ) )->handle( |
|
| 413 | + function(Application $app, Request $request) use ($ffFactory) { |
|
| 414 | + return (new ShowDonationConfirmationHandler($ffFactory))->handle( |
|
| 415 | 415 | $request, |
| 416 | - $app['session']->get( 'piwikTracking', [] ) |
|
| 416 | + $app['session']->get('piwikTracking', []) |
|
| 417 | 417 | ); |
| 418 | 418 | } |
| 419 | -)->bind( 'show-donation-confirmation' ) |
|
| 420 | -->method( 'GET|POST' ); |
|
| 419 | +)->bind('show-donation-confirmation') |
|
| 420 | +->method('GET|POST'); |
|
| 421 | 421 | |
| 422 | 422 | $app->post( |
| 423 | 423 | 'handle-paypal-payment-notification', |
| 424 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 425 | - return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request ); |
|
| 424 | + function(Request $request) use ($ffFactory) { |
|
| 425 | + return (new PayPalNotificationHandler($ffFactory))->handle($request); |
|
| 426 | 426 | } |
| 427 | 427 | ); |
| 428 | 428 | |
| 429 | 429 | $app->get( |
| 430 | 430 | 'handle-creditcard-payment-notification', |
| 431 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 431 | + function(Request $request) use ($ffFactory) { |
|
| 432 | 432 | try { |
| 433 | - $ffFactory->newCreditCardNotificationUseCase( $request->query->get( 'utoken', '' ) ) |
|
| 433 | + $ffFactory->newCreditCardNotificationUseCase($request->query->get('utoken', '')) |
|
| 434 | 434 | ->handleNotification( |
| 435 | - ( new CreditCardPaymentNotificationRequest() ) |
|
| 436 | - ->setTransactionId( $request->query->get( 'transactionId', '' ) ) |
|
| 437 | - ->setDonationId( (int)$request->query->get( 'donation_id', '' ) ) |
|
| 438 | - ->setAmount( Euro::newFromCents( (int)$request->query->get( 'amount' ) ) ) |
|
| 439 | - ->setCustomerId( $request->query->get( 'customerId', '' ) ) |
|
| 440 | - ->setSessionId( $request->query->get( 'sessionId', '' ) ) |
|
| 441 | - ->setAuthId( $request->query->get( 'auth', '' ) ) |
|
| 442 | - ->setTitle( $request->query->get( 'title', '' ) ) |
|
| 443 | - ->setCountry( $request->query->get( 'country', '' ) ) |
|
| 444 | - ->setCurrency( $request->query->get( 'currency', '' ) ) |
|
| 435 | + (new CreditCardPaymentNotificationRequest()) |
|
| 436 | + ->setTransactionId($request->query->get('transactionId', '')) |
|
| 437 | + ->setDonationId((int)$request->query->get('donation_id', '')) |
|
| 438 | + ->setAmount(Euro::newFromCents((int)$request->query->get('amount'))) |
|
| 439 | + ->setCustomerId($request->query->get('customerId', '')) |
|
| 440 | + ->setSessionId($request->query->get('sessionId', '')) |
|
| 441 | + ->setAuthId($request->query->get('auth', '')) |
|
| 442 | + ->setTitle($request->query->get('title', '')) |
|
| 443 | + ->setCountry($request->query->get('country', '')) |
|
| 444 | + ->setCurrency($request->query->get('currency', '')) |
|
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | 447 | $response = CreditCardNotificationResponse::newSuccessResponse( |
| 448 | - (int)$request->query->get( 'donation_id', '' ), |
|
| 449 | - $request->query->get( 'token', '' ) |
|
| 448 | + (int)$request->query->get('donation_id', ''), |
|
| 449 | + $request->query->get('token', '') |
|
| 450 | 450 | ); |
| 451 | - } catch ( CreditCardPaymentHandlerException $e ) { |
|
| 452 | - $response = CreditCardNotificationResponse::newFailureResponse( $e->getMessage() ); |
|
| 451 | + } catch (CreditCardPaymentHandlerException $e) { |
|
| 452 | + $response = CreditCardNotificationResponse::newFailureResponse($e->getMessage()); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - return new Response( $ffFactory->newCreditCardNotificationPresenter()->present( $response ) ); |
|
| 455 | + return new Response($ffFactory->newCreditCardNotificationPresenter()->present($response)); |
|
| 456 | 456 | } |
| 457 | 457 | ); |
| 458 | 458 | |
| 459 | 459 | $app->get( |
| 460 | 460 | 'donation-accepted', |
| 461 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 461 | + function(Request $request) use ($app, $ffFactory) { |
|
| 462 | 462 | |
| 463 | - $eventHandler = $ffFactory->newDonationAcceptedEventHandler( $request->query->get( 'update_token', '' ) ); |
|
| 464 | - $result = $eventHandler->onDonationAccepted( (int)$request->query->get( 'donation_id', '' ) ); |
|
| 463 | + $eventHandler = $ffFactory->newDonationAcceptedEventHandler($request->query->get('update_token', '')); |
|
| 464 | + $result = $eventHandler->onDonationAccepted((int)$request->query->get('donation_id', '')); |
|
| 465 | 465 | |
| 466 | 466 | return $app->json( |
| 467 | - $result === null ? [ 'status' => 'OK' ] : [ 'status' => 'ERR', 'message' => $result ] |
|
| 467 | + $result === null ? ['status' => 'OK'] : ['status' => 'ERR', 'message' => $result] |
|
| 468 | 468 | ); |
| 469 | 469 | } |
| 470 | 470 | ); |
| 471 | 471 | |
| 472 | -$app->get( '/', function ( Application $app, Request $request ) { |
|
| 473 | - $app['session']->set( 'piwikTracking', array_filter( |
|
| 472 | +$app->get('/', function(Application $app, Request $request) { |
|
| 473 | + $app['session']->set('piwikTracking', array_filter( |
|
| 474 | 474 | [ |
| 475 | - 'paymentType' => $request->get( 'zahlweise', '' ), |
|
| 476 | - 'paymentAmount' => $request->get( 'betrag', '' ), |
|
| 477 | - 'paymentInterval' => $request->get( 'periode', '' ) |
|
| 475 | + 'paymentType' => $request->get('zahlweise', ''), |
|
| 476 | + 'paymentAmount' => $request->get('betrag', ''), |
|
| 477 | + 'paymentInterval' => $request->get('periode', '') |
|
| 478 | 478 | ], |
| 479 | - function ( string $value ) { |
|
| 480 | - return $value !== '' && strlen( $value ) < 20; |
|
| 479 | + function(string $value) { |
|
| 480 | + return $value !== '' && strlen($value) < 20; |
|
| 481 | 481 | } ) |
| 482 | 482 | ); |
| 483 | 483 | |
@@ -498,37 +498,37 @@ discard block |
||
| 498 | 498 | // See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url |
| 499 | 499 | $app->post( |
| 500 | 500 | '/spenden/paypal_handler.php', |
| 501 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 502 | - return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request ); |
|
| 501 | + function(Request $request) use ($ffFactory) { |
|
| 502 | + return (new PayPalNotificationHandler($ffFactory))->handle($request); |
|
| 503 | 503 | } |
| 504 | 504 | ); |
| 505 | 505 | |
| 506 | 506 | // redirect display page requests from old URLs |
| 507 | -$app->get( '/spenden/{page}', function( Application $app, Request $request, string $page ) { |
|
| 507 | +$app->get('/spenden/{page}', function(Application $app, Request $request, string $page) { |
|
| 508 | 508 | // Poor man's rewrite until someone has figured out how to do this with Nginx without breaking REQUEST_URI |
| 509 | 509 | // See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url |
| 510 | - switch ( $page ) { |
|
| 510 | + switch ($page) { |
|
| 511 | 511 | case 'Mitgliedschaft': |
| 512 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/page/MembershipApplication' ); |
|
| 512 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/page/MembershipApplication'); |
|
| 513 | 513 | default: |
| 514 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/page/' . $page ); |
|
| 514 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/page/' . $page); |
|
| 515 | 515 | } |
| 516 | -} )->assert( 'page', '[a-zA-Z_\-\s\x7f-\xff]+' ); |
|
| 516 | +} )->assert('page', '[a-zA-Z_\-\s\x7f-\xff]+'); |
|
| 517 | 517 | |
| 518 | 518 | // redirect different formats of comment lists |
| 519 | -$app->get( '/spenden/{outputFormat}.php', function( Application $app, Request $request, string $outputFormat ) { |
|
| 520 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( |
|
| 521 | - '/list-comments.' . ( $outputFormat === 'list' ? 'html' : $outputFormat ) |
|
| 519 | +$app->get('/spenden/{outputFormat}.php', function(Application $app, Request $request, string $outputFormat) { |
|
| 520 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle( |
|
| 521 | + '/list-comments.' . ($outputFormat === 'list' ? 'html' : $outputFormat) |
|
| 522 | 522 | ); |
| 523 | -} )->assert( 'outputFormat', 'list|rss|json' ); |
|
| 523 | +} )->assert('outputFormat', 'list|rss|json'); |
|
| 524 | 524 | |
| 525 | 525 | // redirect all other calls to default route |
| 526 | -$app->get( '/spenden{page}', function( Application $app, Request $request ) { |
|
| 527 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/' ); |
|
| 528 | -} )->assert( 'page', '/?([a-z]+\.php)?' ); |
|
| 526 | +$app->get('/spenden{page}', function(Application $app, Request $request) { |
|
| 527 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/'); |
|
| 528 | +} )->assert('page', '/?([a-z]+\.php)?'); |
|
| 529 | 529 | |
| 530 | -$app->get( '/purge-cache', function( Request $request ) use ( $ffFactory ) { |
|
| 531 | - $response = $ffFactory->newAuthorizedCachePurger()->purgeCache( $request->query->get( 'secret', '' ) ); |
|
| 530 | +$app->get('/purge-cache', function(Request $request) use ($ffFactory) { |
|
| 531 | + $response = $ffFactory->newAuthorizedCachePurger()->purgeCache($request->query->get('secret', '')); |
|
| 532 | 532 | |
| 533 | 533 | return new Response( |
| 534 | 534 | [ |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | ); |
| 540 | 540 | } ); |
| 541 | 541 | |
| 542 | -$app->get( 'status', function() { |
|
| 542 | +$app->get('status', function() { |
|
| 543 | 543 | return 'Status: OK (Online)'; |
| 544 | 544 | } ); |
| 545 | 545 | |