@@ -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; |
@@ -47,129 +47,129 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $app->post( |
| 49 | 49 | 'validate-email', |
| 50 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 51 | - $validationResult = $ffFactory->getEmailValidator()->validate( $request->request->get( 'email', '' ) ); |
|
| 52 | - return $app->json( [ 'status' => $validationResult->isSuccessful() ? 'OK' : 'ERR' ] ); |
|
| 50 | + function(Request $request) use ($app, $ffFactory) { |
|
| 51 | + $validationResult = $ffFactory->getEmailValidator()->validate($request->request->get('email', '')); |
|
| 52 | + return $app->json(['status' => $validationResult->isSuccessful() ? 'OK' : 'ERR']); |
|
| 53 | 53 | } |
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | $app->post( |
| 57 | 57 | 'validate-payment-data', |
| 58 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 58 | + function(Request $request) use ($app, $ffFactory) { |
|
| 59 | 59 | |
| 60 | - $amount = (float) $ffFactory->newDecimalNumberFormatter()->parse( $request->get( 'amount', '0' ) ); |
|
| 60 | + $amount = (float)$ffFactory->newDecimalNumberFormatter()->parse($request->get('amount', '0')); |
|
| 61 | 61 | $validator = $ffFactory->newPaymentDataValidator(); |
| 62 | - $validationResult = $validator->validate( $amount, (string) $request->get( 'paymentType', '' ) ); |
|
| 62 | + $validationResult = $validator->validate($amount, (string)$request->get('paymentType', '')); |
|
| 63 | 63 | |
| 64 | - if ( $validationResult->isSuccessful() ) { |
|
| 65 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 64 | + if ($validationResult->isSuccessful()) { |
|
| 65 | + return $app->json(['status' => 'OK']); |
|
| 66 | 66 | } else { |
| 67 | 67 | $errors = []; |
| 68 | - foreach( $validationResult->getViolations() as $violation ) { |
|
| 69 | - $errors[ $violation->getSource() ] = $ffFactory->getTranslator()->trans( $violation->getMessageIdentifier() ); |
|
| 68 | + foreach ($validationResult->getViolations() as $violation) { |
|
| 69 | + $errors[$violation->getSource()] = $ffFactory->getTranslator()->trans($violation->getMessageIdentifier()); |
|
| 70 | 70 | } |
| 71 | - return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] ); |
|
| 71 | + return $app->json(['status' => 'ERR', 'messages' => $errors]); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | $app->post( |
| 77 | 77 | 'validate-address', |
| 78 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 78 | + function(Request $request) use ($app, $ffFactory) { |
|
| 79 | 79 | $routeHandler = new class() { |
| 80 | 80 | |
| 81 | - public function handle( FunFunFactory $ffFactory, Application $app, Request $request ) { |
|
| 82 | - if ( $request->get( 'adressType', '' ) === 'anonym' ) { |
|
| 83 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 81 | + public function handle(FunFunFactory $ffFactory, Application $app, Request $request) { |
|
| 82 | + if ($request->get('adressType', '') === 'anonym') { |
|
| 83 | + return $app->json(['status' => 'OK']); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $personalInfo = $this->getPersonalInfoFromRequest( $request ); |
|
| 86 | + $personalInfo = $this->getPersonalInfoFromRequest($request); |
|
| 87 | 87 | $personalInfoValidator = $ffFactory->newPersonalInfoValidator(); |
| 88 | - $validationResult = $personalInfoValidator->validate( $personalInfo ); |
|
| 88 | + $validationResult = $personalInfoValidator->validate($personalInfo); |
|
| 89 | 89 | |
| 90 | - if ( $validationResult->isSuccessful() ) { |
|
| 91 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 90 | + if ($validationResult->isSuccessful()) { |
|
| 91 | + return $app->json(['status' => 'OK']); |
|
| 92 | 92 | } else { |
| 93 | 93 | $errors = []; |
| 94 | - foreach( $validationResult->getViolations() as $violation ) { |
|
| 95 | - $errors[$violation->getSource()] = $ffFactory->getTranslator()->trans( $violation->getMessageIdentifier() ); |
|
| 94 | + foreach ($validationResult->getViolations() as $violation) { |
|
| 95 | + $errors[$violation->getSource()] = $ffFactory->getTranslator()->trans($violation->getMessageIdentifier()); |
|
| 96 | 96 | } |
| 97 | - return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] ); |
|
| 97 | + return $app->json(['status' => 'ERR', 'messages' => $errors]); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - private function getPersonalInfoFromRequest( Request $request ): Donor { |
|
| 101 | + private function getPersonalInfoFromRequest(Request $request): Donor { |
|
| 102 | 102 | return new Donor( |
| 103 | - $this->getNameFromRequest( $request ), |
|
| 104 | - $this->getPhysicalAddressFromRequest( $request ), |
|
| 105 | - $request->get( 'email', '' ) |
|
| 103 | + $this->getNameFromRequest($request), |
|
| 104 | + $this->getPhysicalAddressFromRequest($request), |
|
| 105 | + $request->get('email', '') |
|
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - private function getPhysicalAddressFromRequest( Request $request ): DonorAddress { |
|
| 109 | + private function getPhysicalAddressFromRequest(Request $request): DonorAddress { |
|
| 110 | 110 | $address = new DonorAddress(); |
| 111 | 111 | |
| 112 | - $address->setStreetAddress( $request->get( 'street', '' ) ); |
|
| 113 | - $address->setPostalCode( $request->get( 'postcode', '' ) ); |
|
| 114 | - $address->setCity( $request->get( 'city', '' ) ); |
|
| 115 | - $address->setCountryCode( $request->get( 'country', '' ) ); |
|
| 112 | + $address->setStreetAddress($request->get('street', '')); |
|
| 113 | + $address->setPostalCode($request->get('postcode', '')); |
|
| 114 | + $address->setCity($request->get('city', '')); |
|
| 115 | + $address->setCountryCode($request->get('country', '')); |
|
| 116 | 116 | |
| 117 | 117 | return $address->freeze()->assertNoNullFields(); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - private function getNameFromRequest( Request $request ): DonorName { |
|
| 121 | - $name = $request->get( 'addressType', '' ) === 'firma' |
|
| 120 | + private function getNameFromRequest(Request $request): DonorName { |
|
| 121 | + $name = $request->get('addressType', '') === 'firma' |
|
| 122 | 122 | ? DonorName::newCompanyName() : DonorName::newPrivatePersonName(); |
| 123 | 123 | |
| 124 | - $name->setSalutation( $request->get( 'salutation', '' ) ); |
|
| 125 | - $name->setTitle( $request->get( 'title', '' ) ); |
|
| 126 | - $name->setCompanyName( $request->get( 'companyName', '' ) ); |
|
| 127 | - $name->setFirstName( $request->get( 'firstName', '' ) ); |
|
| 128 | - $name->setLastName( $request->get( 'lastName', '' ) ); |
|
| 124 | + $name->setSalutation($request->get('salutation', '')); |
|
| 125 | + $name->setTitle($request->get('title', '')); |
|
| 126 | + $name->setCompanyName($request->get('companyName', '')); |
|
| 127 | + $name->setFirstName($request->get('firstName', '')); |
|
| 128 | + $name->setLastName($request->get('lastName', '')); |
|
| 129 | 129 | |
| 130 | 130 | return $name->freeze()->assertNoNullFields(); |
| 131 | 131 | } |
| 132 | 132 | }; |
| 133 | 133 | |
| 134 | - return $routeHandler->handle( $ffFactory, $app, $request ); |
|
| 134 | + return $routeHandler->handle($ffFactory, $app, $request); |
|
| 135 | 135 | } |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | 138 | $app->post( |
| 139 | 139 | 'validate-fee', |
| 140 | - function( Request $httpRequest ) use ( $app, $ffFactory ) { |
|
| 140 | + function(Request $httpRequest) use ($app, $ffFactory) { |
|
| 141 | 141 | $validator = new MembershipFeeValidator(); |
| 142 | 142 | $result = $validator->validate( |
| 143 | - str_replace( ',', '.', $httpRequest->request->get( 'amount', '' ) ), |
|
| 144 | - (int) $httpRequest->request->get( 'paymentIntervalInMonths', '0' ), |
|
| 145 | - $httpRequest->request->get( 'addressType', '' ) |
|
| 143 | + str_replace(',', '.', $httpRequest->request->get('amount', '')), |
|
| 144 | + (int)$httpRequest->request->get('paymentIntervalInMonths', '0'), |
|
| 145 | + $httpRequest->request->get('addressType', '') |
|
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - if ( $result->isSuccessful() ) { |
|
| 149 | - return $app->json( [ 'status' => 'OK' ] ); |
|
| 148 | + if ($result->isSuccessful()) { |
|
| 149 | + return $app->json(['status' => 'OK']); |
|
| 150 | 150 | } else { |
| 151 | 151 | $errors = $result->getViolations(); |
| 152 | - return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] ); |
|
| 152 | + return $app->json(['status' => 'ERR', 'messages' => $errors]); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | 157 | $app->get( |
| 158 | 158 | 'list-comments.json', |
| 159 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 159 | + function(Request $request) use ($app, $ffFactory) { |
|
| 160 | 160 | $response = $app->json( |
| 161 | 161 | $ffFactory->newCommentListJsonPresenter()->present( |
| 162 | 162 | $ffFactory->newListCommentsUseCase()->listComments( |
| 163 | 163 | new CommentListingRequest( |
| 164 | - (int)$request->query->get( 'n', '10' ), |
|
| 165 | - (int)$request->query->get( 'page', '1' ) |
|
| 164 | + (int)$request->query->get('n', '10'), |
|
| 165 | + (int)$request->query->get('page', '1') |
|
| 166 | 166 | ) |
| 167 | 167 | ) |
| 168 | 168 | ) |
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | - if ( $request->query->get( 'f' ) ) { |
|
| 172 | - $response->setCallback( $request->query->get( 'f' ) ); |
|
| 171 | + if ($request->query->get('f')) { |
|
| 172 | + $response->setCallback($request->query->get('f')); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | return $response; |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $app->get( |
| 180 | 180 | 'list-comments.rss', |
| 181 | - function() use ( $app, $ffFactory ) { |
|
| 181 | + function() use ($app, $ffFactory) { |
|
| 182 | 182 | $rss = $ffFactory->newCommentListRssPresenter()->present( |
| 183 | 183 | $ffFactory->newListCommentsUseCase()->listComments( |
| 184 | - new CommentListingRequest( 100, CommentListingRequest::FIRST_PAGE ) |
|
| 184 | + new CommentListingRequest(100, CommentListingRequest::FIRST_PAGE) |
|
| 185 | 185 | ) |
| 186 | 186 | ); |
| 187 | 187 | |
@@ -194,167 +194,167 @@ discard block |
||
| 194 | 194 | ] |
| 195 | 195 | ); |
| 196 | 196 | } |
| 197 | -)->bind( 'list-comments.rss' ); |
|
| 197 | +)->bind('list-comments.rss'); |
|
| 198 | 198 | |
| 199 | 199 | $app->get( |
| 200 | 200 | 'list-comments.html', |
| 201 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 201 | + function(Request $request) use ($app, $ffFactory) { |
|
| 202 | 202 | return new Response( |
| 203 | 203 | $ffFactory->newCommentListHtmlPresenter()->present( |
| 204 | 204 | $ffFactory->newListCommentsUseCase()->listComments( |
| 205 | 205 | new CommentListingRequest( |
| 206 | 206 | 10, |
| 207 | - (int)$request->query->get( 'page', '1' ) |
|
| 207 | + (int)$request->query->get('page', '1') |
|
| 208 | 208 | ) |
| 209 | 209 | ), |
| 210 | - (int)$request->query->get( 'page', '1' ) |
|
| 210 | + (int)$request->query->get('page', '1') |
|
| 211 | 211 | ) |
| 212 | 212 | ); |
| 213 | 213 | } |
| 214 | -)->bind( 'list-comments.html' ); |
|
| 214 | +)->bind('list-comments.html'); |
|
| 215 | 215 | |
| 216 | 216 | $app->get( |
| 217 | 217 | 'page/{pageName}', |
| 218 | - function( $pageName ) use ( $ffFactory ) { |
|
| 218 | + function($pageName) use ($ffFactory) { |
|
| 219 | 219 | $pageSelector = $ffFactory->getContentPagePageSelector(); |
| 220 | 220 | |
| 221 | 221 | try { |
| 222 | - $pageId = $pageSelector->getPageId( $pageName ); |
|
| 223 | - } catch ( PageNotFoundException $exception ) { |
|
| 224 | - throw new NotFoundHttpException( "Page page name '$pageName' not found." ); |
|
| 222 | + $pageId = $pageSelector->getPageId($pageName); |
|
| 223 | + } catch (PageNotFoundException $exception) { |
|
| 224 | + throw new NotFoundHttpException("Page page name '$pageName' not found."); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | try { |
| 228 | - return $ffFactory->getLayoutTemplate( 'Display_Page_Layout.twig' )->render( [ |
|
| 228 | + return $ffFactory->getLayoutTemplate('Display_Page_Layout.twig')->render([ |
|
| 229 | 229 | 'page_id' => $pageId |
| 230 | - ] ); |
|
| 231 | - } catch ( Twig_Error_Runtime $exception ) { |
|
| 230 | + ]); |
|
| 231 | + } catch (Twig_Error_Runtime $exception) { |
|
| 232 | 232 | if ($exception->getPrevious() instanceof ContentNotFoundException) { |
| 233 | - throw new NotFoundHttpException( "Content for page id '$pageId' not found." ); |
|
| 233 | + throw new NotFoundHttpException("Content for page id '$pageId' not found."); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | throw $exception; |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | ) |
| 240 | -->bind( 'page' ); |
|
| 240 | +->bind('page'); |
|
| 241 | 241 | |
| 242 | 242 | // Form for this is provided by route page/Subscription_Form |
| 243 | 243 | $app->match( |
| 244 | 244 | 'contact/subscribe', |
| 245 | - function( Application $app, Request $request ) use ( $ffFactory ) { |
|
| 246 | - return ( new AddSubscriptionHandler( $ffFactory, $app ) ) |
|
| 247 | - ->handle( $request ); |
|
| 245 | + function(Application $app, Request $request) use ($ffFactory) { |
|
| 246 | + return (new AddSubscriptionHandler($ffFactory, $app)) |
|
| 247 | + ->handle($request); |
|
| 248 | 248 | } |
| 249 | 249 | ) |
| 250 | -->method( 'GET|POST' ) |
|
| 251 | -->bind( 'subscribe' ); |
|
| 250 | +->method('GET|POST') |
|
| 251 | +->bind('subscribe'); |
|
| 252 | 252 | |
| 253 | -$app->get( 'contact/confirm-subscription/{confirmationCode}', function ( $confirmationCode ) use ( $ffFactory ) { |
|
| 253 | +$app->get('contact/confirm-subscription/{confirmationCode}', function($confirmationCode) use ($ffFactory) { |
|
| 254 | 254 | $useCase = $ffFactory->newConfirmSubscriptionUseCase(); |
| 255 | - $response = $useCase->confirmSubscription( $confirmationCode ); |
|
| 256 | - return $ffFactory->newConfirmSubscriptionHtmlPresenter()->present( $response ); |
|
| 255 | + $response = $useCase->confirmSubscription($confirmationCode); |
|
| 256 | + return $ffFactory->newConfirmSubscriptionHtmlPresenter()->present($response); |
|
| 257 | 257 | } ) |
| 258 | -->assert( 'confirmationCode', '^[0-9a-f]+$' ) |
|
| 259 | -->bind( 'confirm-subscription' ); |
|
| 258 | +->assert('confirmationCode', '^[0-9a-f]+$') |
|
| 259 | +->bind('confirm-subscription'); |
|
| 260 | 260 | |
| 261 | 261 | $app->get( |
| 262 | 262 | 'check-iban', |
| 263 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 263 | + function(Request $request) use ($app, $ffFactory) { |
|
| 264 | 264 | $useCase = $ffFactory->newCheckIbanUseCase(); |
| 265 | - $checkIbanResponse = $useCase->checkIban( new Iban( $request->query->get( 'iban', '' ) ) ); |
|
| 266 | - return $app->json( $ffFactory->newIbanPresenter()->present( $checkIbanResponse ) ); |
|
| 265 | + $checkIbanResponse = $useCase->checkIban(new Iban($request->query->get('iban', ''))); |
|
| 266 | + return $app->json($ffFactory->newIbanPresenter()->present($checkIbanResponse)); |
|
| 267 | 267 | } |
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | 270 | $app->get( |
| 271 | 271 | 'generate-iban', |
| 272 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 272 | + function(Request $request) use ($app, $ffFactory) { |
|
| 273 | 273 | $generateIbanRequest = new GenerateIbanRequest( |
| 274 | - $request->query->get( 'accountNumber', '' ), |
|
| 275 | - $request->query->get( 'bankCode', '' ) |
|
| 274 | + $request->query->get('accountNumber', ''), |
|
| 275 | + $request->query->get('bankCode', '') |
|
| 276 | 276 | ); |
| 277 | 277 | |
| 278 | - $generateIbanResponse = $ffFactory->newGenerateIbanUseCase()->generateIban( $generateIbanRequest ); |
|
| 279 | - return $app->json( $ffFactory->newIbanPresenter()->present( $generateIbanResponse ) ); |
|
| 278 | + $generateIbanResponse = $ffFactory->newGenerateIbanUseCase()->generateIban($generateIbanRequest); |
|
| 279 | + return $app->json($ffFactory->newIbanPresenter()->present($generateIbanResponse)); |
|
| 280 | 280 | } |
| 281 | 281 | ); |
| 282 | 282 | |
| 283 | 283 | $app->post( |
| 284 | 284 | 'add-comment', |
| 285 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 285 | + function(Request $request) use ($app, $ffFactory) { |
|
| 286 | 286 | $addCommentRequest = new AddCommentRequest(); |
| 287 | - $addCommentRequest->setCommentText( trim( $request->request->get( 'kommentar', '' ) ) ); |
|
| 288 | - $addCommentRequest->setIsPublic( $request->request->get( 'public', '0' ) === '1' ); |
|
| 289 | - $addCommentRequest->setAuthorDisplayName( trim( $request->request->get( 'eintrag', '' ) ) ); |
|
| 290 | - $addCommentRequest->setDonationId( (int)$request->request->get( 'sid', '' ) ); |
|
| 287 | + $addCommentRequest->setCommentText(trim($request->request->get('kommentar', ''))); |
|
| 288 | + $addCommentRequest->setIsPublic($request->request->get('public', '0') === '1'); |
|
| 289 | + $addCommentRequest->setAuthorDisplayName(trim($request->request->get('eintrag', ''))); |
|
| 290 | + $addCommentRequest->setDonationId((int)$request->request->get('sid', '')); |
|
| 291 | 291 | $addCommentRequest->freeze()->assertNoNullFields(); |
| 292 | 292 | |
| 293 | - $updateToken = $request->request->get( 'utoken', '' ); |
|
| 293 | + $updateToken = $request->request->get('utoken', ''); |
|
| 294 | 294 | |
| 295 | - if ( $updateToken === '' ) { |
|
| 296 | - return $app->json( [ |
|
| 295 | + if ($updateToken === '') { |
|
| 296 | + return $app->json([ |
|
| 297 | 297 | 'status' => 'ERR', |
| 298 | - 'message' => $ffFactory->getTranslator()->trans( 'comment_failure_access_denied' ), |
|
| 299 | - ] ); |
|
| 298 | + 'message' => $ffFactory->getTranslator()->trans('comment_failure_access_denied'), |
|
| 299 | + ]); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $response = $ffFactory->newAddCommentUseCase( $updateToken )->addComment( $addCommentRequest ); |
|
| 302 | + $response = $ffFactory->newAddCommentUseCase($updateToken)->addComment($addCommentRequest); |
|
| 303 | 303 | |
| 304 | - if ( $response->isSuccessful() ) { |
|
| 305 | - return $app->json( [ |
|
| 304 | + if ($response->isSuccessful()) { |
|
| 305 | + return $app->json([ |
|
| 306 | 306 | 'status' => 'OK', |
| 307 | - 'message' => $ffFactory->getTranslator()->trans( $response->getSuccessMessage() ), |
|
| 308 | - ] ); |
|
| 307 | + 'message' => $ffFactory->getTranslator()->trans($response->getSuccessMessage()), |
|
| 308 | + ]); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - return $app->json( [ |
|
| 311 | + return $app->json([ |
|
| 312 | 312 | 'status' => 'ERR', |
| 313 | - 'message' => $ffFactory->getTranslator()->trans( $response->getErrorMessage() ), |
|
| 314 | - ] ); |
|
| 313 | + 'message' => $ffFactory->getTranslator()->trans($response->getErrorMessage()), |
|
| 314 | + ]); |
|
| 315 | 315 | } |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | 318 | $app->post( |
| 319 | 319 | 'contact/get-in-touch', |
| 320 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 320 | + function(Request $request) use ($app, $ffFactory) { |
|
| 321 | 321 | $contactFormRequest = new GetInTouchRequest( |
| 322 | - $request->get( 'firstname', '' ), |
|
| 323 | - $request->get( 'lastname', '' ), |
|
| 324 | - $request->get( 'email', '' ), |
|
| 325 | - $request->get( 'subject', '' ), |
|
| 326 | - $request->get( 'messageBody', '' ) |
|
| 322 | + $request->get('firstname', ''), |
|
| 323 | + $request->get('lastname', ''), |
|
| 324 | + $request->get('email', ''), |
|
| 325 | + $request->get('subject', ''), |
|
| 326 | + $request->get('messageBody', '') |
|
| 327 | 327 | ); |
| 328 | 328 | |
| 329 | - $contactFormResponse = $ffFactory->newGetInTouchUseCase()->processContactRequest( $contactFormRequest ); |
|
| 330 | - if ( $contactFormResponse->isSuccessful() ) { |
|
| 331 | - return $app->redirect( $app['url_generator']->generate( 'page', [ 'pageName' => 'Kontakt_Bestaetigung' ] ) ); |
|
| 329 | + $contactFormResponse = $ffFactory->newGetInTouchUseCase()->processContactRequest($contactFormRequest); |
|
| 330 | + if ($contactFormResponse->isSuccessful()) { |
|
| 331 | + return $app->redirect($app['url_generator']->generate('page', ['pageName' => 'Kontakt_Bestaetigung'])); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - return $ffFactory->newGetInTouchHtmlPresenter()->present( $contactFormResponse, $request->request->all() ); |
|
| 334 | + return $ffFactory->newGetInTouchHtmlPresenter()->present($contactFormResponse, $request->request->all()); |
|
| 335 | 335 | } |
| 336 | 336 | ); |
| 337 | 337 | |
| 338 | 338 | $app->get( |
| 339 | 339 | 'contact/get-in-touch', |
| 340 | - function() use ( $app, $ffFactory ) { |
|
| 341 | - return $ffFactory->getLayoutTemplate( 'contact_form.html.twig' )->render( [ ] ); |
|
| 340 | + function() use ($app, $ffFactory) { |
|
| 341 | + return $ffFactory->getLayoutTemplate('contact_form.html.twig')->render([]); |
|
| 342 | 342 | } |
| 343 | 343 | )->bind('contact'); |
| 344 | 344 | |
| 345 | 345 | $app->post( |
| 346 | 346 | 'donation/cancel', |
| 347 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 347 | + function(Request $request) use ($app, $ffFactory) { |
|
| 348 | 348 | $cancellationRequest = new CancelDonationRequest( |
| 349 | - (int)$request->request->get( 'sid', '' ) |
|
| 349 | + (int)$request->request->get('sid', '') |
|
| 350 | 350 | ); |
| 351 | 351 | |
| 352 | - $responseModel = $ffFactory->newCancelDonationUseCase( $request->request->get( 'utoken', '' ) ) |
|
| 353 | - ->cancelDonation( $cancellationRequest ); |
|
| 352 | + $responseModel = $ffFactory->newCancelDonationUseCase($request->request->get('utoken', '')) |
|
| 353 | + ->cancelDonation($cancellationRequest); |
|
| 354 | 354 | |
| 355 | - $httpResponse = new Response( $ffFactory->newCancelDonationHtmlPresenter()->present( $responseModel ) ); |
|
| 356 | - if ( $responseModel->cancellationSucceeded() ) { |
|
| 357 | - $httpResponse->headers->clearCookie( 'donation_timestamp' ); |
|
| 355 | + $httpResponse = new Response($ffFactory->newCancelDonationHtmlPresenter()->present($responseModel)); |
|
| 356 | + if ($responseModel->cancellationSucceeded()) { |
|
| 357 | + $httpResponse->headers->clearCookie('donation_timestamp'); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | return $httpResponse; |
@@ -363,171 +363,171 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | $app->post( |
| 365 | 365 | 'donation/add', |
| 366 | - function( Application $app, Request $request ) use ( $ffFactory ) { |
|
| 367 | - return ( new AddDonationHandler( $ffFactory, $app ) ) |
|
| 368 | - ->handle( $request ); |
|
| 366 | + function(Application $app, Request $request) use ($ffFactory) { |
|
| 367 | + return (new AddDonationHandler($ffFactory, $app)) |
|
| 368 | + ->handle($request); |
|
| 369 | 369 | } |
| 370 | 370 | ); |
| 371 | 371 | |
| 372 | 372 | // Show a donation form with pre-filled payment values, e.g. when coming from a banner |
| 373 | -$app->get( 'donation/new', function ( Request $request ) use ( $ffFactory ) { |
|
| 373 | +$app->get('donation/new', function(Request $request) use ($ffFactory) { |
|
| 374 | 374 | try { |
| 375 | - $amount = Euro::newFromFloat( ( new AmountParser( 'en_EN' ) )->parseAsFloat( |
|
| 376 | - $request->get( 'betrag_auswahl', $request->get( 'amountGiven', '' ) ) ) |
|
| 375 | + $amount = Euro::newFromFloat((new AmountParser('en_EN'))->parseAsFloat( |
|
| 376 | + $request->get('betrag_auswahl', $request->get('amountGiven', '')) ) |
|
| 377 | 377 | ); |
| 378 | - } catch ( \InvalidArgumentException $ex ) { |
|
| 379 | - $amount = Euro::newFromCents( 0 ); |
|
| 378 | + } catch (\InvalidArgumentException $ex) { |
|
| 379 | + $amount = Euro::newFromCents(0); |
|
| 380 | 380 | } |
| 381 | - $validationResult = $ffFactory->newPaymentDataValidator()->validate( $amount, (string) $request->get( 'zahlweise', '' ) ); |
|
| 381 | + $validationResult = $ffFactory->newPaymentDataValidator()->validate($amount, (string)$request->get('zahlweise', '')); |
|
| 382 | 382 | |
| 383 | 383 | $trackingInfo = new DonationTrackingInfo(); |
| 384 | - $trackingInfo->setTotalImpressionCount( intval( $request->get( 'impCount' ) ) ); |
|
| 385 | - $trackingInfo->setSingleBannerImpressionCount( intval( $request->get( 'bImpCount' ) ) ); |
|
| 384 | + $trackingInfo->setTotalImpressionCount(intval($request->get('impCount'))); |
|
| 385 | + $trackingInfo->setSingleBannerImpressionCount(intval($request->get('bImpCount'))); |
|
| 386 | 386 | |
| 387 | 387 | // TODO: don't we want to use newDonationFormViolationPresenter when !$validationResult->isSuccessful()? |
| 388 | 388 | |
| 389 | 389 | return new Response( |
| 390 | 390 | $ffFactory->newDonationFormPresenter()->present( |
| 391 | 391 | $amount, |
| 392 | - $request->get( 'zahlweise', '' ), |
|
| 393 | - intval( $request->get( 'periode', 0 ) ), |
|
| 392 | + $request->get('zahlweise', ''), |
|
| 393 | + intval($request->get('periode', 0)), |
|
| 394 | 394 | $validationResult->isSuccessful(), |
| 395 | 395 | $trackingInfo, |
| 396 | - $request->get( 'addressType', 'person' ) |
|
| 396 | + $request->get('addressType', 'person') |
|
| 397 | 397 | ) |
| 398 | 398 | ); |
| 399 | -} )->method( 'POST|GET' ); |
|
| 399 | +} )->method('POST|GET'); |
|
| 400 | 400 | |
| 401 | 401 | $app->post( |
| 402 | 402 | 'apply-for-membership', |
| 403 | - function( Application $app, Request $httpRequest ) use ( $ffFactory ) { |
|
| 404 | - return ( new ApplyForMembershipHandler( $ffFactory, $app ) )->handle( $httpRequest ); |
|
| 403 | + function(Application $app, Request $httpRequest) use ($ffFactory) { |
|
| 404 | + return (new ApplyForMembershipHandler($ffFactory, $app))->handle($httpRequest); |
|
| 405 | 405 | } |
| 406 | 406 | ); |
| 407 | 407 | |
| 408 | 408 | $app->get( |
| 409 | 409 | 'apply-for-membership', |
| 410 | - function( Request $request ) use ( $ffFactory ) { |
|
| 410 | + function(Request $request) use ($ffFactory) { |
|
| 411 | 411 | |
| 412 | 412 | $params = []; |
| 413 | - if ( $request->query->get('type' ) === 'sustaining' ) { |
|
| 414 | - $params['showMembershipTypeOption'] = false ; |
|
| 413 | + if ($request->query->get('type') === 'sustaining') { |
|
| 414 | + $params['showMembershipTypeOption'] = false; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - return $ffFactory->getLayoutTemplate( 'Membership_Application.html.twig' )->render( $params ); |
|
| 417 | + return $ffFactory->getLayoutTemplate('Membership_Application.html.twig')->render($params); |
|
| 418 | 418 | } |
| 419 | 419 | ); |
| 420 | 420 | |
| 421 | 421 | $app->get( |
| 422 | 422 | 'show-membership-confirmation', |
| 423 | - function( Request $request ) use ( $ffFactory ) { |
|
| 424 | - $confirmationRequest = new ShowMembershipAppConfirmationRequest( (int)$request->query->get( 'id', 0 ) ); |
|
| 423 | + function(Request $request) use ($ffFactory) { |
|
| 424 | + $confirmationRequest = new ShowMembershipAppConfirmationRequest((int)$request->query->get('id', 0)); |
|
| 425 | 425 | |
| 426 | 426 | return $ffFactory->newMembershipApplicationConfirmationHtmlPresenter()->present( |
| 427 | - $ffFactory->newMembershipApplicationConfirmationUseCase( $request->query->get( 'accessToken', '' ) ) |
|
| 428 | - ->showConfirmation( $confirmationRequest ) |
|
| 427 | + $ffFactory->newMembershipApplicationConfirmationUseCase($request->query->get('accessToken', '')) |
|
| 428 | + ->showConfirmation($confirmationRequest) |
|
| 429 | 429 | ); |
| 430 | 430 | } |
| 431 | -)->bind( 'show-membership-confirmation' ); |
|
| 431 | +)->bind('show-membership-confirmation'); |
|
| 432 | 432 | |
| 433 | 433 | $app->get( |
| 434 | 434 | 'cancel-membership-application', |
| 435 | - function( Request $request ) use ( $ffFactory ) { |
|
| 435 | + function(Request $request) use ($ffFactory) { |
|
| 436 | 436 | $cancellationRequest = new CancellationRequest( |
| 437 | - (int)$request->query->get( 'id', '' ) |
|
| 437 | + (int)$request->query->get('id', '') |
|
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | 440 | return $ffFactory->newCancelMembershipApplicationHtmlPresenter()->present( |
| 441 | - $ffFactory->newCancelMembershipApplicationUseCase( $request->query->get( 'updateToken', '' ) ) |
|
| 442 | - ->cancelApplication( $cancellationRequest ) |
|
| 441 | + $ffFactory->newCancelMembershipApplicationUseCase($request->query->get('updateToken', '')) |
|
| 442 | + ->cancelApplication($cancellationRequest) |
|
| 443 | 443 | ); |
| 444 | 444 | } |
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | 447 | $app->match( |
| 448 | 448 | 'show-donation-confirmation', |
| 449 | - function( Application $app, Request $request ) use ( $ffFactory ) { |
|
| 450 | - return ( new ShowDonationConfirmationHandler( $ffFactory ) )->handle( |
|
| 449 | + function(Application $app, Request $request) use ($ffFactory) { |
|
| 450 | + return (new ShowDonationConfirmationHandler($ffFactory))->handle( |
|
| 451 | 451 | $request, |
| 452 | - $app['session']->get( 'piwikTracking', [] ) |
|
| 452 | + $app['session']->get('piwikTracking', []) |
|
| 453 | 453 | ); |
| 454 | 454 | } |
| 455 | -)->bind( 'show-donation-confirmation' ) |
|
| 456 | -->method( 'GET|POST' ); |
|
| 455 | +)->bind('show-donation-confirmation') |
|
| 456 | +->method('GET|POST'); |
|
| 457 | 457 | |
| 458 | 458 | $app->post( |
| 459 | 459 | 'handle-paypal-payment-notification', |
| 460 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 461 | - return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request ); |
|
| 460 | + function(Request $request) use ($ffFactory) { |
|
| 461 | + return (new PayPalNotificationHandler($ffFactory))->handle($request); |
|
| 462 | 462 | } |
| 463 | 463 | ); |
| 464 | 464 | |
| 465 | 465 | $app->post( |
| 466 | 466 | 'sofort-payment-notification', |
| 467 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 468 | - return ( new SofortNotificationHandler( $ffFactory ) )->handle( $request ); |
|
| 467 | + function(Request $request) use ($ffFactory) { |
|
| 468 | + return (new SofortNotificationHandler($ffFactory))->handle($request); |
|
| 469 | 469 | } |
| 470 | 470 | ); |
| 471 | 471 | |
| 472 | 472 | $app->get( |
| 473 | 473 | 'handle-creditcard-payment-notification', |
| 474 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 474 | + function(Request $request) use ($ffFactory) { |
|
| 475 | 475 | try { |
| 476 | - $ffFactory->newCreditCardNotificationUseCase( $request->query->get( 'utoken', '' ) ) |
|
| 476 | + $ffFactory->newCreditCardNotificationUseCase($request->query->get('utoken', '')) |
|
| 477 | 477 | ->handleNotification( |
| 478 | - ( new CreditCardPaymentNotificationRequest() ) |
|
| 479 | - ->setTransactionId( $request->query->get( 'transactionId', '' ) ) |
|
| 480 | - ->setDonationId( (int)$request->query->get( 'donation_id', '' ) ) |
|
| 481 | - ->setAmount( Euro::newFromCents( (int)$request->query->get( 'amount' ) ) ) |
|
| 482 | - ->setCustomerId( $request->query->get( 'customerId', '' ) ) |
|
| 483 | - ->setSessionId( $request->query->get( 'sessionId', '' ) ) |
|
| 484 | - ->setAuthId( $request->query->get( 'auth', '' ) ) |
|
| 485 | - ->setTitle( $request->query->get( 'title', '' ) ) |
|
| 486 | - ->setCountry( $request->query->get( 'country', '' ) ) |
|
| 487 | - ->setCurrency( $request->query->get( 'currency', '' ) ) |
|
| 478 | + (new CreditCardPaymentNotificationRequest()) |
|
| 479 | + ->setTransactionId($request->query->get('transactionId', '')) |
|
| 480 | + ->setDonationId((int)$request->query->get('donation_id', '')) |
|
| 481 | + ->setAmount(Euro::newFromCents((int)$request->query->get('amount'))) |
|
| 482 | + ->setCustomerId($request->query->get('customerId', '')) |
|
| 483 | + ->setSessionId($request->query->get('sessionId', '')) |
|
| 484 | + ->setAuthId($request->query->get('auth', '')) |
|
| 485 | + ->setTitle($request->query->get('title', '')) |
|
| 486 | + ->setCountry($request->query->get('country', '')) |
|
| 487 | + ->setCurrency($request->query->get('currency', '')) |
|
| 488 | 488 | ); |
| 489 | 489 | |
| 490 | 490 | $response = CreditCardNotificationResponse::newSuccessResponse( |
| 491 | - (int)$request->query->get( 'donation_id', '' ), |
|
| 492 | - $request->query->get( 'token', '' ) |
|
| 491 | + (int)$request->query->get('donation_id', ''), |
|
| 492 | + $request->query->get('token', '') |
|
| 493 | 493 | ); |
| 494 | - } catch ( CreditCardPaymentHandlerException $e ) { |
|
| 495 | - $response = CreditCardNotificationResponse::newFailureResponse( $e->getMessage() ); |
|
| 494 | + } catch (CreditCardPaymentHandlerException $e) { |
|
| 495 | + $response = CreditCardNotificationResponse::newFailureResponse($e->getMessage()); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - return new Response( $ffFactory->newCreditCardNotificationPresenter()->present( $response ) ); |
|
| 498 | + return new Response($ffFactory->newCreditCardNotificationPresenter()->present($response)); |
|
| 499 | 499 | } |
| 500 | 500 | ); |
| 501 | 501 | |
| 502 | 502 | $app->get( |
| 503 | 503 | 'donation-accepted', |
| 504 | - function( Request $request ) use ( $app, $ffFactory ) { |
|
| 504 | + function(Request $request) use ($app, $ffFactory) { |
|
| 505 | 505 | |
| 506 | - $eventHandler = $ffFactory->newDonationAcceptedEventHandler( $request->query->get( 'update_token', '' ) ); |
|
| 507 | - $result = $eventHandler->onDonationAccepted( (int)$request->query->get( 'donation_id', '' ) ); |
|
| 506 | + $eventHandler = $ffFactory->newDonationAcceptedEventHandler($request->query->get('update_token', '')); |
|
| 507 | + $result = $eventHandler->onDonationAccepted((int)$request->query->get('donation_id', '')); |
|
| 508 | 508 | |
| 509 | 509 | return $app->json( |
| 510 | - $result === null ? [ 'status' => 'OK' ] : [ 'status' => 'ERR', 'message' => $result ] |
|
| 510 | + $result === null ? ['status' => 'OK'] : ['status' => 'ERR', 'message' => $result] |
|
| 511 | 511 | ); |
| 512 | 512 | } |
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | 515 | $app->post( |
| 516 | 516 | 'handle-paypal-membership-fee-payments', |
| 517 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 518 | - return ( new PayPalNotificationHandlerForMembershipFee( $ffFactory ) )->handle( $request->request ); |
|
| 517 | + function(Request $request) use ($ffFactory) { |
|
| 518 | + return (new PayPalNotificationHandlerForMembershipFee($ffFactory))->handle($request->request); |
|
| 519 | 519 | } |
| 520 | 520 | ); |
| 521 | 521 | |
| 522 | -$app->get( '/', function ( Application $app, Request $request ) { |
|
| 523 | - $app['session']->set( 'piwikTracking', array_filter( |
|
| 522 | +$app->get('/', function(Application $app, Request $request) { |
|
| 523 | + $app['session']->set('piwikTracking', array_filter( |
|
| 524 | 524 | [ |
| 525 | - 'paymentType' => $request->get( 'zahlweise', '' ), |
|
| 526 | - 'paymentAmount' => $request->get( 'betrag', '' ), |
|
| 527 | - 'paymentInterval' => $request->get( 'periode', '' ) |
|
| 525 | + 'paymentType' => $request->get('zahlweise', ''), |
|
| 526 | + 'paymentAmount' => $request->get('betrag', ''), |
|
| 527 | + 'paymentInterval' => $request->get('periode', '') |
|
| 528 | 528 | ], |
| 529 | - function ( string $value ) { |
|
| 530 | - return $value !== '' && strlen( $value ) < 20; |
|
| 529 | + function(string $value) { |
|
| 530 | + return $value !== '' && strlen($value) < 20; |
|
| 531 | 531 | } ) |
| 532 | 532 | ); |
| 533 | 533 | |
@@ -542,43 +542,43 @@ discard block |
||
| 542 | 542 | ), |
| 543 | 543 | HttpKernelInterface::SUB_REQUEST |
| 544 | 544 | ); |
| 545 | -} )->bind( '/' ); |
|
| 545 | +} )->bind('/'); |
|
| 546 | 546 | |
| 547 | 547 | // TODO Figure out how to rewrite with Nginx |
| 548 | 548 | // See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url |
| 549 | 549 | $app->post( |
| 550 | 550 | '/spenden/paypal_handler.php', |
| 551 | - function ( Request $request ) use ( $ffFactory ) { |
|
| 552 | - return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request ); |
|
| 551 | + function(Request $request) use ($ffFactory) { |
|
| 552 | + return (new PayPalNotificationHandler($ffFactory))->handle($request); |
|
| 553 | 553 | } |
| 554 | 554 | ); |
| 555 | 555 | |
| 556 | 556 | // redirect display page requests from old URLs |
| 557 | -$app->get( '/spenden/{page}', function( Application $app, Request $request, string $page ) { |
|
| 557 | +$app->get('/spenden/{page}', function(Application $app, Request $request, string $page) { |
|
| 558 | 558 | // Poor man's rewrite until someone has figured out how to do this with Nginx without breaking REQUEST_URI |
| 559 | 559 | // See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url |
| 560 | - switch ( $page ) { |
|
| 560 | + switch ($page) { |
|
| 561 | 561 | case 'Mitgliedschaft': |
| 562 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/page/Membership_Application' ); |
|
| 562 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/page/Membership_Application'); |
|
| 563 | 563 | default: |
| 564 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/page/' . $page ); |
|
| 564 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/page/' . $page); |
|
| 565 | 565 | } |
| 566 | -} )->assert( 'page', '[a-zA-Z_\-\s\x7f-\xff]+' ); |
|
| 566 | +} )->assert('page', '[a-zA-Z_\-\s\x7f-\xff]+'); |
|
| 567 | 567 | |
| 568 | 568 | // redirect different formats of comment lists |
| 569 | -$app->get( '/spenden/{outputFormat}.php', function( Application $app, Request $request, string $outputFormat ) { |
|
| 570 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( |
|
| 571 | - '/list-comments.' . ( $outputFormat === 'list' ? 'html' : $outputFormat ) |
|
| 569 | +$app->get('/spenden/{outputFormat}.php', function(Application $app, Request $request, string $outputFormat) { |
|
| 570 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle( |
|
| 571 | + '/list-comments.' . ($outputFormat === 'list' ? 'html' : $outputFormat) |
|
| 572 | 572 | ); |
| 573 | -} )->assert( 'outputFormat', 'list|rss|json' ); |
|
| 573 | +} )->assert('outputFormat', 'list|rss|json'); |
|
| 574 | 574 | |
| 575 | 575 | // redirect all other calls to default route |
| 576 | -$app->get( '/spenden{page}', function( Application $app, Request $request ) { |
|
| 577 | - return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/' ); |
|
| 578 | -} )->assert( 'page', '/?([a-z]+\.php)?' ); |
|
| 576 | +$app->get('/spenden{page}', function(Application $app, Request $request) { |
|
| 577 | + return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/'); |
|
| 578 | +} )->assert('page', '/?([a-z]+\.php)?'); |
|
| 579 | 579 | |
| 580 | -$app->get( '/purge-cache', function( Request $request ) use ( $ffFactory ) { |
|
| 581 | - $response = $ffFactory->newAuthorizedCachePurger()->purgeCache( $request->query->get( 'secret', '' ) ); |
|
| 580 | +$app->get('/purge-cache', function(Request $request) use ($ffFactory) { |
|
| 581 | + $response = $ffFactory->newAuthorizedCachePurger()->purgeCache($request->query->get('secret', '')); |
|
| 582 | 582 | |
| 583 | 583 | return new Response( |
| 584 | 584 | [ |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | ); |
| 590 | 590 | } ); |
| 591 | 591 | |
| 592 | -$app->get( 'status', function() { |
|
| 592 | +$app->get('status', function() { |
|
| 593 | 593 | return 'Status: OK (Online)'; |
| 594 | 594 | } ); |
| 595 | 595 | |