Complex classes like FunFunFactory often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FunFunFactory, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 167 | class FunFunFactory { |
||
| 168 | |||
| 169 | private $config; |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @var Container |
||
| 173 | */ |
||
| 174 | private $pimple; |
||
| 175 | |||
| 176 | private $addDoctrineSubscribers = true; |
||
| 177 | 160 | ||
| 178 | 160 | /** |
|
| 179 | 160 | * @var Stopwatch|null |
|
| 180 | 160 | */ |
|
| 181 | private $profiler = null; |
||
| 182 | 160 | ||
| 183 | 160 | public function __construct( array $config ) { |
|
| 184 | $this->config = $config; |
||
| 185 | $this->pimple = $this->newPimple(); |
||
| 186 | 119 | } |
|
| 187 | |||
| 188 | private function newPimple(): Container { |
||
| 189 | $pimple = new Container(); |
||
| 190 | 4 | ||
| 191 | $pimple['logger'] = function() { |
||
| 192 | return new NullLogger(); |
||
| 193 | }; |
||
| 194 | |||
| 195 | $pimple['paypal_logger'] = function() { |
||
| 196 | return new NullLogger(); |
||
| 197 | }; |
||
| 198 | 160 | ||
| 199 | $pimple['profiler_data_collector'] = function() { |
||
| 200 | return new ProfilerDataCollector(); |
||
| 201 | }; |
||
| 202 | 90 | ||
| 203 | 90 | $pimple['dbal_connection'] = function() { |
|
| 204 | 90 | return DriverManager::getConnection( $this->config['db'] ); |
|
| 205 | 90 | }; |
|
| 206 | 90 | ||
| 207 | $pimple['entity_manager'] = function() { |
||
| 208 | $entityManager = ( new StoreFactory( $this->getConnection(), $this->getVarPath() . '/doctrine_proxies' ) ) |
||
| 209 | 90 | ->getEntityManager(); |
|
| 210 | if ( $this->addDoctrineSubscribers ) { |
||
| 211 | $entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() ); |
||
| 212 | $entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() ); |
||
| 213 | 9 | } |
|
| 214 | 9 | ||
| 215 | 9 | return $entityManager; |
|
| 216 | }; |
||
| 217 | |||
| 218 | $pimple['subscription_repository'] = function() { |
||
| 219 | return new LoggingSubscriptionRepository( |
||
| 220 | 47 | new DoctrineSubscriptionRepository( $this->getEntityManager() ), |
|
| 221 | 47 | $this->getLogger() |
|
| 222 | 47 | ); |
|
| 223 | }; |
||
| 224 | |||
| 225 | $pimple['donation_repository'] = function() { |
||
| 226 | return new LoggingDonationRepository( |
||
| 227 | 14 | new DoctrineDonationRepository( $this->getEntityManager() ), |
|
| 228 | 14 | $this->getLogger() |
|
| 229 | 14 | ); |
|
| 230 | }; |
||
| 231 | |||
| 232 | $pimple['membership_application_repository'] = function() { |
||
| 233 | return new LoggingApplicationRepository( |
||
| 234 | 12 | new DoctrineApplicationRepository( $this->getEntityManager() ), |
|
| 235 | 12 | $this->getLogger() |
|
| 236 | 12 | ); |
|
| 237 | }; |
||
| 238 | |||
| 239 | 12 | $pimple['comment_repository'] = function() { |
|
| 240 | $finder = new LoggingCommentFinder( |
||
| 241 | new DoctrineCommentFinder( $this->getEntityManager() ), |
||
| 242 | $this->getLogger() |
||
| 243 | 44 | ); |
|
| 244 | |||
| 245 | return $this->addProfilingDecorator( $finder, 'CommentFinder' ); |
||
| 246 | }; |
||
| 247 | 7 | ||
| 248 | 7 | $pimple['mail_validator'] = function() { |
|
| 249 | 7 | return new EmailValidator( new InternetDomainNameValidator() ); |
|
| 250 | 7 | }; |
|
| 251 | 7 | ||
| 252 | $pimple['subscription_validator'] = function() { |
||
| 253 | return new SubscriptionValidator( |
||
| 254 | $this->getEmailValidator(), |
||
| 255 | $this->newTextPolicyValidator( 'fields' ), |
||
| 256 | 8 | $this->newSubscriptionDuplicateValidator(), |
|
| 257 | $this->newHonorificValidator() |
||
| 258 | ); |
||
| 259 | }; |
||
| 260 | 3 | ||
| 261 | $pimple['template_name_validator'] = function() { |
||
| 262 | return new TemplateNameValidator( $this->getTwig() ); |
||
| 263 | }; |
||
| 264 | 56 | ||
| 265 | $pimple['contact_validator'] = function() { |
||
| 266 | return new GetInTouchValidator( $this->getEmailValidator() ); |
||
| 267 | }; |
||
| 268 | 102 | ||
| 269 | 102 | $pimple['greeting_generator'] = function() { |
|
| 270 | 102 | return new GreetingGenerator(); |
|
| 271 | }; |
||
| 272 | |||
| 273 | $pimple['translator'] = function() { |
||
| 274 | $translationFactory = new TranslationFactory(); |
||
| 275 | 102 | $loaders = [ |
|
| 276 | 102 | 'json' => $translationFactory->newJsonLoader() |
|
| 277 | ]; |
||
| 278 | 102 | $locale = $this->config['locale']; |
|
| 279 | 102 | $messagesPath = $this->getI18nDirectory() . $this->config['translation']['message-dir']; |
|
| 280 | $translator = $translationFactory->create( $loaders, $locale ); |
||
| 281 | 102 | foreach ($this->config['translation']['files'] as $domain => $file) { |
|
| 282 | 102 | $translator->addResource( 'json', $messagesPath . '/' . $file, $locale, $domain ); |
|
| 283 | 102 | } |
|
| 284 | |||
| 285 | return $translator; |
||
| 286 | }; |
||
| 287 | 102 | ||
| 288 | // In the future, this could be locale-specific or filled from a DB table |
||
| 289 | $pimple['honorifics'] = function() { |
||
| 290 | return new Honorifics( [ |
||
| 291 | 114 | '' => 'Kein Titel', |
|
| 292 | 'Dr.' => 'Dr.', |
||
| 293 | 114 | 'Prof.' => 'Prof.', |
|
| 294 | 'Prof. Dr.' => 'Prof. Dr.' |
||
| 295 | 114 | ] ); |
|
| 296 | 114 | }; |
|
| 297 | 114 | ||
| 298 | 114 | $pimple['twig_factory'] = function () { |
|
| 299 | 114 | return new TwigFactory( |
|
| 300 | array_merge_recursive( |
||
| 301 | $this->config['twig'], |
||
| 302 | ['web-basepath' => $this->config['web-basepath']] |
||
| 303 | 114 | ), |
|
| 304 | 114 | $this->getCachePath() . '/twig', |
|
| 305 | 114 | $this->config['locale'] |
|
| 306 | ); |
||
| 307 | 114 | }; |
|
| 308 | |||
| 309 | $pimple['twig'] = function() { |
||
| 310 | 114 | $twigFactory = $this->getTwigFactory(); |
|
| 311 | 114 | $configurator = $twigFactory->newTwigEnvironmentConfigurator(); |
|
| 312 | 114 | ||
| 313 | $loaders = array_filter( [ |
||
| 314 | 114 | $twigFactory->newFileSystemLoader(), |
|
| 315 | $twigFactory->newArrayLoader(), // This is just a fallback for testing |
||
| 316 | ] ); |
||
| 317 | 114 | $extensions = [ |
|
| 318 | 114 | $twigFactory->newTranslationExtension( $this->getTranslator() ), |
|
| 319 | 114 | new Twig_Extensions_Extension_Intl() |
|
| 320 | ]; |
||
| 321 | 114 | $filters = [ |
|
| 322 | $twigFactory->newFilePrefixFilter( |
||
| 323 | $this->getFilePrefixer() |
||
| 324 | 114 | ) |
|
| 325 | 114 | ]; |
|
| 326 | 114 | $functions = [ |
|
| 327 | new Twig_SimpleFunction( |
||
| 328 | 114 | 'web_content', |
|
| 329 | function( string $name, array $context = [] ) { |
||
| 330 | return $this->getContentProvider()->getWeb( $name, $context ); |
||
| 331 | 114 | }, |
|
| 332 | [ 'is_safe' => [ 'html' ] ] |
||
| 333 | ), |
||
| 334 | new Twig_SimpleFunction( |
||
| 335 | 'mail_content', |
||
| 336 | 78 | function( string $name, array $context = [] ) { |
|
| 337 | 78 | return $this->getContentProvider()->getMail( $name, $context ); |
|
| 338 | }, |
||
| 339 | [ 'is_safe' => [ 'all' ] ] |
||
| 340 | ) |
||
| 341 | ]; |
||
| 342 | |||
| 343 | return $configurator->getEnvironment( $this->pimple['twig_environment'], $loaders, $extensions, $filters, $functions ); |
||
| 344 | }; |
||
| 345 | 109 | ||
| 346 | $pimple['messenger_suborganization'] = function() { |
||
| 347 | return new Messenger( |
||
| 348 | new Swift_MailTransport(), |
||
|
|
|||
| 349 | 109 | $this->getSubOrganizationEmailAddress(), |
|
| 350 | 109 | $this->config['contact-info']['suborganization']['name'] |
|
| 351 | 109 | ); |
|
| 352 | 109 | }; |
|
| 353 | 109 | ||
| 354 | 109 | $pimple['messenger_organization'] = function() { |
|
| 355 | 109 | return new Messenger( |
|
| 356 | new Swift_MailTransport(), |
||
| 357 | $this->getOrganizationEmailAddress(), |
||
| 358 | $this->config['contact-info']['organization']['name'] |
||
| 359 | 109 | ); |
|
| 360 | 109 | }; |
|
| 361 | |||
| 362 | $pimple['confirmation-page-selector'] = function() { |
||
| 363 | 109 | return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] ); |
|
| 364 | 109 | }; |
|
| 365 | |||
| 366 | $pimple['paypal-payment-notification-verifier'] = function() { |
||
| 367 | return new LoggingPaymentNotificationVerifier( |
||
| 368 | 109 | new PayPalPaymentNotificationVerifier( |
|
| 369 | new Client(), |
||
| 370 | $this->config['paypal-donation']['base-url'], |
||
| 371 | $this->config['paypal-donation']['account-address'] |
||
| 372 | ), |
||
| 373 | $this->getLogger() |
||
| 374 | ); |
||
| 375 | }; |
||
| 376 | |||
| 377 | $pimple['paypal-membership-fee-notification-verifier'] = function() { |
||
| 378 | return new LoggingPaymentNotificationVerifier( |
||
| 379 | new PayPalPaymentNotificationVerifier( |
||
| 380 | new Client(), |
||
| 381 | $this->config['paypal-membership']['base-url'], |
||
| 382 | $this->config['paypal-membership']['account-address'] |
||
| 383 | ), |
||
| 384 | $this->getLogger() |
||
| 385 | ); |
||
| 386 | }; |
||
| 387 | |||
| 388 | 6 | $pimple['credit-card-api-service'] = function() { |
|
| 389 | return new McpCreditCardService( |
||
| 390 | new TNvpServiceDispatcher( |
||
| 391 | 'IMcpCreditcardService_v1_5', |
||
| 392 | 'https://sipg.micropayment.de/public/creditcard/v1.5/nvp/' |
||
| 393 | ), |
||
| 394 | $this->config['creditcard']['access-key'], |
||
| 395 | $this->config['creditcard']['testmode'] |
||
| 396 | ); |
||
| 397 | }; |
||
| 398 | |||
| 399 | $pimple['token_generator'] = function() { |
||
| 400 | return new RandomTokenGenerator( |
||
| 401 | $this->config['token-length'], |
||
| 402 | new \DateInterval( $this->config['token-validity-timestamp'] ) |
||
| 403 | ); |
||
| 404 | }; |
||
| 405 | |||
| 406 | $pimple['page_cache'] = function() { |
||
| 407 | return new VoidCache(); |
||
| 408 | }; |
||
| 409 | |||
| 410 | $pimple['rendered_page_cache'] = function() { |
||
| 411 | return new VoidCache(); |
||
| 412 | }; |
||
| 413 | |||
| 414 | 69 | $pimple['page_view_tracker'] = function () { |
|
| 415 | 69 | return new PageViewTracker( $this->newServerSideTracker(), $this->config['piwik']['siteUrlBase'] ); |
|
| 416 | 69 | }; |
|
| 417 | |||
| 418 | $pimple['cachebusting_fileprefixer'] = function () { |
||
| 419 | return new FilePrefixer( $this->getFilePrefix() ); |
||
| 420 | }; |
||
| 421 | 112 | ||
| 422 | $pimple['content_page_selector'] = function () { |
||
| 423 | $json = (new SimpleFileFetcher())->fetchFile( $this->getI18nDirectory() . '/data/pages.json' ); |
||
| 424 | $config = json_decode( $json, true ) ?? []; |
||
| 425 | 109 | ||
| 426 | return new PageSelector( $config ); |
||
| 427 | }; |
||
| 428 | |||
| 429 | $pimple['content_provider'] = function () { |
||
| 430 | return new ContentProvider( [ |
||
| 431 | 'content_path' => $this->getI18nDirectory(), |
||
| 432 | 160 | 'cache' => $this->config['twig']['enable-cache'] ? $this->getCachePath() . '/content' : false, |
|
| 433 | 'globals' => [ |
||
| 434 | 'basepath' => $this->config['web-basepath'] |
||
| 435 | 160 | ] |
|
| 436 | 160 | ] ); |
|
| 437 | }; |
||
| 438 | |||
| 439 | 90 | $pimple['payment-delay-calculator'] = function() { |
|
| 440 | 90 | return new DefaultPaymentDelayCalculator( $this->getPayPalUrlConfigForMembershipApplications()->getDelayInDays() ); |
|
| 441 | }; |
||
| 442 | |||
| 443 | 11 | $pimple['sofort-client'] = function () { |
|
| 444 | 11 | $config = $this->config['sofort']; |
|
| 445 | 11 | return new SofortClient( $config['config-key'] ); |
|
| 446 | 11 | }; |
|
| 447 | |||
| 448 | return $pimple; |
||
| 449 | } |
||
| 450 | 160 | ||
| 451 | 160 | public function getConnection(): Connection { |
|
| 452 | return $this->pimple['dbal_connection']; |
||
| 453 | } |
||
| 454 | 12 | ||
| 455 | 12 | public function getEntityManager(): EntityManager { |
|
| 456 | return $this->pimple['entity_manager']; |
||
| 457 | } |
||
| 458 | 6 | ||
| 459 | 6 | private function newDonationEventLogger(): DonationEventLogger { |
|
| 460 | return new BestEffortDonationEventLogger( |
||
| 461 | new DoctrineDonationEventLogger( $this->getEntityManager() ), |
||
| 462 | 2 | $this->getLogger() |
|
| 463 | 2 | ); |
|
| 464 | 2 | } |
|
| 465 | 2 | ||
| 466 | public function newInstaller(): Installer { |
||
| 467 | return ( new StoreFactory( $this->getConnection() ) )->newInstaller(); |
||
| 468 | } |
||
| 469 | 4 | ||
| 470 | 4 | public function newListCommentsUseCase(): ListCommentsUseCase { |
|
| 471 | return new ListCommentsUseCase( $this->getCommentFinder() ); |
||
| 472 | } |
||
| 473 | 12 | ||
| 474 | 12 | public function newCommentListJsonPresenter(): CommentListJsonPresenter { |
|
| 475 | return new CommentListJsonPresenter(); |
||
| 476 | } |
||
| 477 | 10 | ||
| 478 | 10 | public function newCommentListRssPresenter(): CommentListRssPresenter { |
|
| 479 | return new CommentListRssPresenter( new TwigTemplate( |
||
| 480 | $this->getTwig(), |
||
| 481 | 1 | 'Comment_List.rss.twig' |
|
| 482 | 1 | ) ); |
|
| 483 | 1 | } |
|
| 484 | |||
| 485 | 7 | public function newCommentListHtmlPresenter(): CommentListHtmlPresenter { |
|
| 486 | 7 | return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'Comment_List.html.twig', [ 'piwikGoals' => [ 1 ] ] ) ); |
|
| 487 | } |
||
| 488 | |||
| 489 | 46 | private function getCommentFinder(): CommentFinder { |
|
| 490 | 46 | return $this->pimple['comment_repository']; |
|
| 491 | } |
||
| 492 | |||
| 493 | 8 | public function getSubscriptionRepository(): SubscriptionRepository { |
|
| 494 | 8 | return $this->pimple['subscription_repository']; |
|
| 495 | } |
||
| 496 | |||
| 497 | 1 | public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ) { |
|
| 498 | 1 | $this->pimple['subscription_repository'] = $subscriptionRepository; |
|
| 499 | } |
||
| 500 | |||
| 501 | 3 | private function getSubscriptionValidator(): SubscriptionValidator { |
|
| 502 | 3 | return $this->pimple['subscription_validator']; |
|
| 503 | 3 | } |
|
| 504 | 3 | ||
| 505 | public function getEmailValidator(): EmailValidator { |
||
| 506 | return $this->pimple['mail_validator']; |
||
| 507 | } |
||
| 508 | 3 | ||
| 509 | 3 | public function getTemplateNameValidator(): TemplateNameValidator { |
|
| 510 | return $this->pimple['template_name_validator']; |
||
| 511 | } |
||
| 512 | 1 | ||
| 513 | 1 | public function newAddSubscriptionHtmlPresenter(): AddSubscriptionHtmlPresenter { |
|
| 514 | return new AddSubscriptionHtmlPresenter( $this->getLayoutTemplate( 'Subscription_Form.html.twig' ), $this->getTranslator() ); |
||
| 515 | } |
||
| 516 | 160 | ||
| 517 | 160 | public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter { |
|
| 518 | 160 | return new ConfirmSubscriptionHtmlPresenter( |
|
| 519 | $this->getLayoutTemplate( 'Confirm_Subscription.twig' ), |
||
| 520 | 109 | $this->getTranslator() |
|
| 521 | 109 | ); |
|
| 522 | } |
||
| 523 | |||
| 524 | public function newAddSubscriptionJsonPresenter(): AddSubscriptionJsonPresenter { |
||
| 525 | return new AddSubscriptionJsonPresenter( $this->getTranslator() ); |
||
| 526 | } |
||
| 527 | |||
| 528 | public function newGetInTouchHtmlPresenter(): GetInTouchHtmlPresenter { |
||
| 529 | return new GetInTouchHtmlPresenter( $this->getLayoutTemplate( 'contact_form.html.twig' ), $this->getTranslator() ); |
||
| 530 | } |
||
| 531 | 43 | ||
| 532 | 43 | public function setTwigEnvironment( Twig_Environment $twig ) { |
|
| 533 | 43 | $this->pimple['twig_environment'] = $twig; |
|
| 534 | } |
||
| 535 | 43 | ||
| 536 | public function getTwig(): Twig_Environment { |
||
| 537 | return $this->pimple['twig']; |
||
| 538 | } |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Get a template, with the content for the layout areas filled in. |
||
| 542 | * |
||
| 543 | * @param string $templateName |
||
| 544 | * @param array $context Additional variables for the template |
||
| 545 | 30 | * @return TwigTemplate |
|
| 546 | 30 | */ |
|
| 547 | 30 | public function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
| 548 | 30 | return new TwigTemplate( |
|
| 549 | $this->getTwig(), |
||
| 550 | 30 | $templateName, |
|
| 551 | 30 | array_merge( $this->getDefaultTwigVariables(), $context ) |
|
| 552 | ); |
||
| 553 | } |
||
| 554 | |||
| 555 | /** |
||
| 556 | * Get a layouted template that includes another template |
||
| 557 | 72 | * |
|
| 558 | * @deprecated Change the template to use extend and block and call getLayoutTemplate instead. |
||
| 559 | 72 | * |
|
| 560 | 72 | * @param string $templateName Template to include |
|
| 561 | 72 | * @return TwigTemplate |
|
| 562 | 72 | */ |
|
| 563 | 72 | private function getIncludeTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
| 564 | 72 | return new TwigTemplate( |
|
| 565 | $this->getTwig(), |
||
| 566 | 'Include_in_Layout.twig', |
||
| 567 | array_merge( |
||
| 568 | 20 | $this->getDefaultTwigVariables(), |
|
| 569 | 20 | [ 'main_template' => $templateName ], |
|
| 570 | 20 | $context |
|
| 571 | 20 | ) |
|
| 572 | ); |
||
| 573 | } |
||
| 574 | |||
| 575 | 112 | private function getDefaultTwigVariables() { |
|
| 576 | 112 | return [ |
|
| 577 | 'honorifics' => $this->getHonorifics()->getList(), |
||
| 578 | 'header_template' => $this->config['default-layout-templates']['header'], |
||
| 579 | 10 | 'footer_template' => $this->config['default-layout-templates']['footer'], |
|
| 580 | 10 | 'no_js_notice_template' => $this->config['default-layout-templates']['no-js-notice'], |
|
| 581 | 10 | 'piwik' => $this->config['piwik'], |
|
| 582 | 'locale' => $this->config['locale'], |
||
| 583 | 102 | ]; |
|
| 584 | 102 | } |
|
| 585 | |||
| 586 | private function newReferrerGeneralizer() { |
||
| 587 | 112 | return new ReferrerGeneralizer( |
|
| 588 | 112 | $this->config['referrer-generalization']['default'], |
|
| 589 | 112 | $this->config['referrer-generalization']['domain-map'] |
|
| 590 | 112 | ); |
|
| 591 | } |
||
| 592 | |||
| 593 | 112 | public function getLogger(): LoggerInterface { |
|
| 594 | return $this->pimple['logger']; |
||
| 595 | } |
||
| 596 | 109 | ||
| 597 | 109 | public function getPaypalLogger(): LoggerInterface { |
|
| 598 | 109 | return $this->pimple['paypal_logger']; |
|
| 599 | 109 | } |
|
| 600 | |||
| 601 | private function getVarPath(): string { |
||
| 602 | 109 | return __DIR__ . '/../../var'; |
|
| 603 | } |
||
| 604 | |||
| 605 | 112 | public function getCachePath(): string { |
|
| 606 | 112 | return $this->getVarPath() . '/cache'; |
|
| 607 | 112 | } |
|
| 608 | 112 | ||
| 609 | 112 | public function getLoggingPath(): string { |
|
| 610 | 112 | return $this->getVarPath() . '/log'; |
|
| 611 | 112 | } |
|
| 612 | |||
| 613 | public function getTemplatePath(): string { |
||
| 614 | return __DIR__ . '/../../app/fundraising-frontend-content/templates'; |
||
| 615 | 109 | } |
|
| 616 | 109 | ||
| 617 | 109 | public function newAddSubscriptionUseCase(): AddSubscriptionUseCase { |
|
| 618 | 109 | return new AddSubscriptionUseCase( |
|
| 619 | 109 | $this->getSubscriptionRepository(), |
|
| 620 | 109 | $this->getSubscriptionValidator(), |
|
| 621 | 109 | $this->newAddSubscriptionMailer() |
|
| 622 | ); |
||
| 623 | } |
||
| 624 | |||
| 625 | 119 | public function newConfirmSubscriptionUseCase(): ConfirmSubscriptionUseCase { |
|
| 626 | 119 | return new ConfirmSubscriptionUseCase( |
|
| 627 | $this->getSubscriptionRepository(), |
||
| 628 | $this->newConfirmSubscriptionMailer() |
||
| 629 | 6 | ); |
|
| 630 | 6 | } |
|
| 631 | |||
| 632 | private function newAddSubscriptionMailer(): TemplateMailerInterface { |
||
| 633 | 127 | return $this->newTemplateMailer( |
|
| 634 | 127 | $this->getSuborganizationMessenger(), |
|
| 635 | new TwigTemplate( |
||
| 636 | $this->getTwig(), |
||
| 637 | 109 | 'Mail_Subscription_Request.txt.twig', |
|
| 638 | 109 | [ |
|
| 639 | 'greeting_generator' => $this->getGreetingGenerator() |
||
| 640 | ] |
||
| 641 | ), |
||
| 642 | 'mail_subject_subscription' |
||
| 643 | ); |
||
| 644 | } |
||
| 645 | |||
| 646 | private function newConfirmSubscriptionMailer(): TemplateMailerInterface { |
||
| 647 | return $this->newTemplateMailer( |
||
| 648 | $this->getSuborganizationMessenger(), |
||
| 649 | 7 | new TwigTemplate( |
|
| 650 | 7 | $this->getTwig(), |
|
| 651 | 7 | 'Mail_Subscription_Confirmation.txt.twig', |
|
| 652 | 7 | [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 653 | 7 | ), |
|
| 654 | 'mail_subject_subscription_confirmed' |
||
| 655 | ); |
||
| 656 | } |
||
| 657 | 3 | ||
| 658 | 3 | /** |
|
| 659 | 3 | * Create a new TemplateMailer instance |
|
| 660 | 3 | * |
|
| 661 | * So much decoration going on that explicitly hinting what we return (Robustness principle) would be confusing |
||
| 662 | * (you'd expect a TemplateBasedMailer, not a LoggingMailer), so we hint the interface instead. |
||
| 663 | */ |
||
| 664 | 7 | private function newTemplateMailer( Messenger $messenger, TwigTemplate $template, string $messageKey ): TemplateMailerInterface { |
|
| 665 | 7 | $mailer = new TemplateBasedMailer( |
|
| 666 | 7 | $messenger, |
|
| 667 | 7 | $template, |
|
| 668 | 7 | $this->getTranslator()->trans( $messageKey ) |
|
| 669 | 7 | ); |
|
| 670 | |||
| 671 | 7 | $mailer = new LoggingMailer( $mailer, $this->getLogger() ); |
|
| 672 | 7 | ||
| 673 | return $this->addProfilingDecorator( $mailer, 'Mailer' ); |
||
| 674 | } |
||
| 675 | 7 | ||
| 676 | public function getGreetingGenerator() { |
||
| 677 | return $this->pimple['greeting_generator']; |
||
| 678 | } |
||
| 679 | 3 | ||
| 680 | 3 | public function newCheckIbanUseCase(): CheckIbanUseCase { |
|
| 681 | 3 | return new CheckIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() ); |
|
| 682 | 3 | } |
|
| 683 | 3 | ||
| 684 | 3 | public function newGenerateIbanUseCase(): GenerateIbanUseCase { |
|
| 685 | 3 | return new GenerateIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() ); |
|
| 686 | } |
||
| 687 | 3 | ||
| 688 | public function newIbanPresenter(): IbanPresenter { |
||
| 689 | return new IbanPresenter(); |
||
| 690 | } |
||
| 691 | 59 | ||
| 692 | 59 | public function newBankDataConverter() { |
|
| 693 | return new BankDataConverter( $this->config['bank-data-file'] ); |
||
| 694 | } |
||
| 695 | 59 | ||
| 696 | public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ) { |
||
| 697 | $this->pimple['subscription_validator'] = $subscriptionValidator; |
||
| 698 | 59 | } |
|
| 699 | |||
| 700 | 59 | public function newGetInTouchUseCase() { |
|
| 701 | return new GetInTouchUseCase( |
||
| 702 | $this->getContactValidator(), |
||
| 703 | 56 | $this->newContactOperatorMailer(), |
|
| 704 | 56 | $this->newContactUserMailer() |
|
| 705 | ); |
||
| 706 | } |
||
| 707 | |||
| 708 | private function newContactUserMailer(): TemplateMailerInterface { |
||
| 709 | return $this->newTemplateMailer( |
||
| 710 | $this->getSuborganizationMessenger(), |
||
| 711 | new TwigTemplate( $this->getTwig(), 'Mail_Contact_Confirm_to_User.txt.twig' ), |
||
| 712 | 'mail_subject_getintouch' |
||
| 713 | ); |
||
| 714 | } |
||
| 715 | |||
| 716 | private function newContactOperatorMailer(): OperatorMailer { |
||
| 717 | return new OperatorMailer( |
||
| 718 | $this->getSuborganizationMessenger(), |
||
| 719 | 31 | new TwigTemplate( $this->getTwig(), 'Mail_Contact_Forward_to_Operator.txt.twig' ), |
|
| 720 | 31 | $this->getTranslator()->trans( 'mail_subject_getintouch_forward' ) |
|
| 721 | ); |
||
| 722 | } |
||
| 723 | |||
| 724 | private function getContactValidator(): GetInTouchValidator { |
||
| 725 | return $this->pimple['contact_validator']; |
||
| 726 | } |
||
| 727 | |||
| 728 | private function newSubscriptionDuplicateValidator(): SubscriptionDuplicateValidator { |
||
| 729 | return new SubscriptionDuplicateValidator( |
||
| 730 | $this->getSubscriptionRepository(), |
||
| 731 | 3 | $this->newSubscriptionDuplicateCutoffDate() |
|
| 732 | 3 | ); |
|
| 733 | 3 | } |
|
| 734 | 3 | ||
| 735 | 3 | private function newSubscriptionDuplicateCutoffDate(): \DateTime { |
|
| 736 | $cutoffDateTime = new \DateTime(); |
||
| 737 | $cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) ); |
||
| 738 | return $cutoffDateTime; |
||
| 739 | 3 | } |
|
| 740 | 3 | ||
| 741 | 3 | private function newHonorificValidator(): AllowedValuesValidator { |
|
| 742 | 3 | return new AllowedValuesValidator( $this->getHonorifics()->getKeys() ); |
|
| 743 | 3 | } |
|
| 744 | |||
| 745 | private function getHonorifics(): Honorifics { |
||
| 746 | return $this->pimple['honorifics']; |
||
| 747 | 3 | } |
|
| 748 | 3 | ||
| 749 | 3 | public function newAuthorizedCachePurger(): AuthorizedCachePurger { |
|
| 750 | 3 | return new AuthorizedCachePurger( |
|
| 751 | 3 | new AllOfTheCachePurger( $this->getTwig(), $this->getPageCache(), $this->getRenderedPageCache() ), |
|
| 752 | $this->config['purging-secret'] |
||
| 753 | ); |
||
| 754 | } |
||
| 755 | 3 | ||
| 756 | 3 | private function newBankDataValidator(): BankDataValidator { |
|
| 757 | return new BankDataValidator( $this->newIbanValidator() ); |
||
| 758 | } |
||
| 759 | 7 | ||
| 760 | 7 | private function getSuborganizationMessenger(): Messenger { |
|
| 761 | 7 | return $this->pimple['messenger_suborganization']; |
|
| 762 | 7 | } |
|
| 763 | |||
| 764 | public function setSuborganizationMessenger( Messenger $messenger ) { |
||
| 765 | $this->pimple['messenger_suborganization'] = $messenger; |
||
| 766 | 7 | } |
|
| 767 | 7 | ||
| 768 | 7 | private function getOrganizationMessenger(): Messenger { |
|
| 769 | 7 | return $this->pimple['messenger_organization']; |
|
| 770 | } |
||
| 771 | |||
| 772 | 7 | public function setOrganizationMessenger( Messenger $messenger ) { |
|
| 773 | 7 | $this->pimple['messenger_organization'] = $messenger; |
|
| 774 | } |
||
| 775 | |||
| 776 | 78 | public function setNullMessenger() { |
|
| 777 | 78 | $this->setSuborganizationMessenger( new Messenger( |
|
| 778 | Swift_NullTransport::newInstance(), |
||
| 779 | $this->getSubOrganizationEmailAddress() |
||
| 780 | 1 | ) ); |
|
| 781 | 1 | $this->setOrganizationMessenger( new Messenger( |
|
| 782 | 1 | Swift_NullTransport::newInstance(), |
|
| 783 | 1 | $this->getOrganizationEmailAddress() |
|
| 784 | ) ); |
||
| 785 | } |
||
| 786 | |||
| 787 | 31 | public function getSubOrganizationEmailAddress(): EmailAddress { |
|
| 788 | 31 | return new EmailAddress( $this->config['contact-info']['suborganization']['email'] ); |
|
| 789 | } |
||
| 790 | |||
| 791 | 46 | public function getOrganizationEmailAddress() { |
|
| 792 | 46 | return new EmailAddress( $this->config['contact-info']['organization']['email'] ); |
|
| 793 | } |
||
| 794 | |||
| 795 | 160 | public function newInternalErrorHtmlPresenter(): InternalErrorHtmlPresenter { |
|
| 796 | 160 | return new InternalErrorHtmlPresenter( $this->getIncludeTemplate( 'Error_Page.html.twig' ) ); |
|
| 797 | 160 | } |
|
| 798 | |||
| 799 | 13 | public function newAccessDeniedHtmlPresenter(): InternalErrorHtmlPresenter { |
|
| 800 | 13 | return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'Access_Denied.twig' ) ); |
|
| 801 | } |
||
| 802 | |||
| 803 | 160 | public function getTranslator(): TranslatorInterface { |
|
| 804 | 160 | return $this->pimple['translator']; |
|
| 805 | 160 | } |
|
| 806 | |||
| 807 | 160 | public function setTranslator( TranslatorInterface $translator ) { |
|
| 808 | 160 | $this->pimple['translator'] = $translator; |
|
| 809 | 160 | } |
|
| 810 | 160 | ||
| 811 | public function getTwigFactory(): TwigFactory { |
||
| 814 | 160 | ||
| 815 | private function newTextPolicyValidator( string $policyName ): TextPolicyValidator { |
||
| 816 | 160 | $fetcher = new ErrorLoggingFileFetcher( |
|
| 817 | new SimpleFileFetcher(), |
||
| 818 | 160 | $this->getLogger() |
|
| 819 | 160 | ); |
|
| 820 | $textPolicyConfig = $this->config['text-policies'][$policyName]; |
||
| 821 | return new TextPolicyValidator( |
||
| 822 | 160 | new WordListFileReader( |
|
| 823 | 160 | $fetcher, |
|
| 824 | $textPolicyConfig['badwords'] ? $this->getAbsolutePath( $textPolicyConfig['badwords'] ) : '' |
||
| 825 | ), |
||
| 826 | 3 | new WordListFileReader( |
|
| 827 | 3 | $fetcher, |
|
| 828 | $textPolicyConfig['whitewords'] ? $this->getAbsolutePath( $textPolicyConfig['whitewords'] ) : '' |
||
| 829 | ) |
||
| 830 | 3 | ); |
|
| 831 | 3 | } |
|
| 832 | |||
| 833 | private function newCommentPolicyValidator(): TextPolicyValidator { |
||
| 834 | 116 | return $this->newTextPolicyValidator( 'comment' ); |
|
| 835 | 116 | } |
|
| 836 | |||
| 837 | public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase { |
||
| 838 | 2 | return new CancelDonationUseCase( |
|
| 839 | 2 | $this->getDonationRepository(), |
|
| 840 | 2 | $this->newCancelDonationMailer(), |
|
| 841 | $this->newDonationAuthorizer( $updateToken ), |
||
| 842 | 109 | $this->newDonationEventLogger() |
|
| 843 | 109 | ); |
|
| 844 | } |
||
| 845 | |||
| 846 | 41 | private function newCancelDonationMailer(): TemplateMailerInterface { |
|
| 847 | 41 | return $this->newTemplateMailer( |
|
| 848 | 41 | $this->getSuborganizationMessenger(), |
|
| 849 | new TwigTemplate( |
||
| 850 | 41 | $this->getTwig(), |
|
| 851 | 41 | 'Mail_Donation_Cancellation_Confirmation.txt.twig', |
|
| 852 | 41 | [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 853 | ), |
||
| 854 | 'mail_subject_confirm_cancellation' |
||
| 855 | ); |
||
| 856 | 3 | } |
|
| 857 | 3 | ||
| 858 | public function newAddDonationUseCase(): AddDonationUseCase { |
||
| 859 | return new AddDonationUseCase( |
||
| 860 | 5 | $this->getDonationRepository(), |
|
| 861 | 5 | $this->newDonationValidator(), |
|
| 862 | 5 | $this->newDonationPolicyValidator(), |
|
| 863 | 5 | $this->newReferrerGeneralizer(), |
|
| 864 | 5 | $this->newDonationConfirmationMailer(), |
|
| 865 | 5 | $this->newBankTransferCodeGenerator(), |
|
| 866 | $this->newDonationTokenFetcher() |
||
| 867 | ); |
||
| 868 | } |
||
| 869 | 5 | ||
| 870 | 5 | private function newBankTransferCodeGenerator(): TransferCodeGenerator { |
|
| 871 | 5 | return new UniqueTransferCodeGenerator( |
|
| 872 | 5 | new SimpleTransferCodeGenerator(), |
|
| 873 | 5 | $this->getEntityManager() |
|
| 874 | 5 | ); |
|
| 875 | 5 | } |
|
| 876 | |||
| 877 | 5 | private function newDonationValidator(): AddDonationValidator { |
|
| 878 | return new AddDonationValidator( |
||
| 879 | $this->newPaymentDataValidator(), |
||
| 880 | $this->newBankDataValidator(), |
||
| 881 | 20 | $this->getEmailValidator() |
|
| 882 | 20 | ); |
|
| 883 | 20 | } |
|
| 884 | 20 | ||
| 885 | 20 | public function newPersonalInfoValidator(): DonorValidator { |
|
| 886 | 20 | return new DonorValidator( |
|
| 887 | 20 | new DonorNameValidator(), |
|
| 888 | 20 | new DonorAddressValidator(), |
|
| 889 | 20 | $this->getEmailValidator() |
|
| 890 | ); |
||
| 891 | } |
||
| 892 | |||
| 893 | 20 | private function newDonationConfirmationMailer(): DonationConfirmationMailer { |
|
| 894 | 20 | return new DonationConfirmationMailer( |
|
| 895 | 20 | $this->newTemplateMailer( |
|
| 896 | 20 | $this->getSuborganizationMessenger(), |
|
| 897 | new TwigTemplate( |
||
| 898 | $this->getTwig(), |
||
| 899 | 'Mail_Donation_Confirmation.txt.twig', |
||
| 900 | 20 | [ |
|
| 901 | 20 | 'greeting_generator' => $this->getGreetingGenerator() |
|
| 902 | 20 | ] |
|
| 903 | 20 | ), |
|
| 904 | 20 | 'mail_subject_confirm_donation' |
|
| 905 | ) |
||
| 906 | ); |
||
| 907 | } |
||
| 908 | 2 | ||
| 909 | 2 | public function newPayPalUrlGeneratorForDonations() { |
|
| 910 | 2 | return new PayPalUrlGenerator( $this->getPayPalUrlConfigForDonations() ); |
|
| 911 | 2 | } |
|
| 912 | 2 | ||
| 913 | public function newPayPalUrlGeneratorForMembershipApplications() { |
||
| 914 | return new PayPalUrlGenerator( $this->getPayPalUrlConfigForMembershipApplications() ); |
||
| 915 | } |
||
| 916 | 28 | ||
| 917 | 28 | private function getPayPalUrlConfigForDonations() { |
|
| 918 | 28 | return PayPalUrlConfig::newFromConfig( $this->config['paypal-donation'] ); |
|
| 919 | 28 | } |
|
| 920 | 28 | ||
| 921 | 28 | private function getPayPalUrlConfigForMembershipApplications() { |
|
| 922 | 28 | return PayPalUrlConfig::newFromConfig( $this->config['paypal-membership'] ); |
|
| 923 | } |
||
| 924 | 28 | ||
| 925 | 28 | public function newSofortUrlGeneratorForDonations(): SofortUrlGenerator { |
|
| 926 | $config = $this->config['sofort']; |
||
| 927 | |||
| 928 | 28 | return new SofortUrlGenerator( |
|
| 929 | new SofortUrlConfig( |
||
| 930 | $this->getTranslator()->trans( 'item_name_donation', [], 'messages' ), |
||
| 931 | $config['return-url'], |
||
| 932 | $config['cancel-url'] |
||
| 933 | 2 | ), |
|
| 934 | 2 | $this->getSofortClient() |
|
| 935 | ); |
||
| 936 | } |
||
| 937 | 2 | ||
| 938 | 2 | public function setSofortClient( SofortClient $client ): void { |
|
| 939 | $this->pimple['sofort-client'] = $client; |
||
| 940 | } |
||
| 941 | 2 | ||
| 942 | 2 | private function getSofortClient(): SofortClient { |
|
| 943 | return $this->pimple['sofort-client']; |
||
| 944 | } |
||
| 945 | 2 | ||
| 946 | 2 | private function newCreditCardUrlGenerator() { |
|
| 947 | return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() ); |
||
| 948 | } |
||
| 949 | 3 | ||
| 950 | 3 | private function newCreditCardUrlConfig() { |
|
| 951 | return CreditCardUrlConfig::newFromConfig( $this->config['creditcard'] ); |
||
| 952 | } |
||
| 953 | 3 | ||
| 954 | 3 | public function getDonationRepository(): DonationRepository { |
|
| 955 | return $this->pimple['donation_repository']; |
||
| 956 | } |
||
| 957 | 47 | ||
| 958 | 47 | public function newPaymentDataValidator(): PaymentDataValidator { |
|
| 959 | return new PaymentDataValidator( |
||
| 960 | $this->config['donation-minimum-amount'], |
||
| 961 | 36 | $this->config['donation-maximum-amount'], |
|
| 962 | 36 | $this->getEnabledDonationPaymentTypes() |
|
| 963 | ); |
||
| 964 | } |
||
| 965 | 19 | ||
| 966 | 19 | private function newAmountFormatter(): AmountFormatter { |
|
| 969 | 2 | ||
| 970 | 2 | public function newDecimalNumberFormatter(): NumberFormatter { |
|
| 973 | 3 | ||
| 974 | 3 | public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase { |
|
| 982 | 29 | ||
| 983 | 29 | private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer { |
|
| 990 | 90 | ||
| 991 | 90 | public function getTokenGenerator(): TokenGenerator { |
|
| 994 | 10 | ||
| 995 | 10 | public function newDonationConfirmationPresenter() { |
|
| 1000 | 3 | ||
| 1001 | 3 | public function newCreditCardPaymentHtmlPresenter() { |
|
| 1008 | 5 | ||
| 1009 | 5 | public function newCancelDonationHtmlPresenter() { |
|
| 1014 | 11 | ||
| 1015 | 11 | public function newApplyForMembershipUseCase(): ApplyForMembershipUseCase { |
|
| 1016 | 11 | return new ApplyForMembershipUseCase( |
|
| 1017 | 11 | $this->getMembershipApplicationRepository(), |
|
| 1018 | 11 | $this->newMembershipApplicationTokenFetcher(), |
|
| 1019 | 11 | $this->newApplyForMembershipMailer(), |
|
| 1020 | 11 | $this->newMembershipApplicationValidator(), |
|
| 1021 | 11 | $this->newApplyForMembershipPolicyValidator(), |
|
| 1022 | 11 | $this->newMembershipApplicationTracker(), |
|
| 1023 | $this->newMembershipApplicationPiwikTracker(), |
||
| 1024 | $this->getPaymentDelayCalculator() |
||
| 1025 | ); |
||
| 1026 | 11 | } |
|
| 1027 | 11 | ||
| 1028 | 11 | private function newApplyForMembershipMailer(): TemplateMailerInterface { |
|
| 1029 | 11 | return $this->newTemplateMailer( |
|
| 1030 | 11 | $this->getOrganizationMessenger(), |
|
| 1031 | 11 | new TwigTemplate( |
|
| 1032 | 11 | $this->getTwig(), |
|
| 1033 | 'Mail_Membership_Application_Confirmation.txt.twig', |
||
| 1034 | 11 | [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 1035 | ), |
||
| 1036 | 'mail_subject_confirm_membership_application' |
||
| 1037 | ); |
||
| 1038 | 11 | } |
|
| 1039 | 11 | ||
| 1040 | 11 | private function newMembershipApplicationValidator(): MembershipApplicationValidator { |
|
| 1041 | 11 | return new MembershipApplicationValidator( |
|
| 1042 | 11 | new MembershipFeeValidator(), |
|
| 1043 | $this->newBankDataValidator(), |
||
| 1044 | $this->getEmailValidator() |
||
| 1045 | ); |
||
| 1046 | 11 | } |
|
| 1047 | 11 | ||
| 1048 | private function newMembershipApplicationTracker(): ApplicationTracker { |
||
| 1049 | return new DoctrineApplicationTracker( $this->getEntityManager() ); |
||
| 1050 | 11 | } |
|
| 1051 | 11 | ||
| 1052 | private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker { |
||
| 1053 | return new DoctrineApplicationPiwikTracker( $this->getEntityManager() ); |
||
| 1054 | 11 | } |
|
| 1055 | 11 | ||
| 1056 | private function getPaymentDelayCalculator() { |
||
| 1057 | return $this->pimple['payment-delay-calculator']; |
||
| 1058 | 2 | } |
|
| 1059 | 2 | ||
| 1060 | 2 | public function setPaymentDelayCalculator( PaymentDelayCalculator $paymentDelayCalculator ) { |
|
| 1061 | 2 | $this->pimple['payment-delay-calculator'] = $paymentDelayCalculator; |
|
| 1062 | 2 | } |
|
| 1063 | |||
| 1064 | private function newApplyForMembershipPolicyValidator(): ApplyForMembershipPolicyValidator { |
||
| 1065 | return new ApplyForMembershipPolicyValidator( |
||
| 1066 | 3 | $this->newTextPolicyValidator( 'fields' ), |
|
| 1067 | $this->config['email-address-blacklist'] |
||
| 1068 | ); |
||
| 1069 | 3 | } |
|
| 1070 | 3 | ||
| 1071 | public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase { |
||
| 1078 | |||
| 1079 | private function newMembershipApplicationAuthorizer( |
||
| 1088 | 2 | ||
| 1089 | public function getMembershipApplicationRepository(): ApplicationRepository { |
||
| 1092 | 1 | ||
| 1093 | 1 | private function newCancelMembershipApplicationMailer(): TemplateMailerInterface { |
|
| 1104 | |||
| 1105 | public function newMembershipApplicationConfirmationUseCase( string $accessToken ) { |
||
| 1111 | 10 | ||
| 1112 | 10 | public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase { |
|
| 1119 | 4 | ||
| 1120 | public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ) { |
||
| 1123 | |||
| 1124 | public function getDonationConfirmationPageSelector(): DonationConfirmationPageSelector { |
||
| 1127 | |||
| 1128 | public function newDonationFormViolationPresenter() { |
||
| 1129 | 4 | return new DonationFormViolationPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() ); |
|
| 1130 | 4 | } |
|
| 1131 | 4 | ||
| 1132 | 4 | public function newDonationFormPresenter() { |
|
| 1133 | 4 | return new DonationFormPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() ); |
|
| 1134 | 4 | } |
|
| 1135 | |||
| 1136 | private function getDonationFormTemplate(): TwigTemplate { |
||
| 1137 | // TODO make the template name dependent on the 'form' value from the HTTP POST request |
||
| 1138 | 7 | // (we need different form pages for A/B testing) |
|
| 1139 | 7 | return $this->getLayoutTemplate( 'Donation_Form.html.twig', [ |
|
| 1140 | 'paymentTypes' => $this->getEnabledDonationPaymentTypes() |
||
| 1141 | ] ); |
||
| 1142 | 7 | } |
|
| 1143 | 7 | ||
| 1144 | 7 | private function getEnabledDonationPaymentTypes(): array { |
|
| 1145 | return array_keys( array_filter( $this->config['payment-types'], function ( $config ) { |
||
| 1146 | 2 | return ( $config['donation-enabled'] === true ); |
|
| 1147 | 2 | } ) ); |
|
| 1148 | 2 | } |
|
| 1149 | 2 | ||
| 1150 | 2 | public function newHandlePayPalPaymentNotificationUseCase( string $updateToken ) { |
|
| 1151 | 2 | return new HandlePayPalPaymentNotificationUseCase( |
|
| 1152 | 2 | $this->getDonationRepository(), |
|
| 1153 | 2 | $this->newDonationAuthorizer( $updateToken ), |
|
| 1154 | $this->newDonationConfirmationMailer(), |
||
| 1155 | $this->newDonationEventLogger() |
||
| 1156 | ); |
||
| 1157 | 2 | } |
|
| 1158 | 2 | ||
| 1159 | 2 | public function newMembershipApplicationSubscriptionSignupNotificationUseCase( string $updateToken ) { |
|
| 1160 | return new HandleSubscriptionSignupNotificationUseCase( |
||
| 1161 | $this->getMembershipApplicationRepository(), |
||
| 1162 | $this->newMembershipApplicationAuthorizer( $updateToken ), |
||
| 1163 | 1 | $this->newApplyForMembershipMailer(), |
|
| 1164 | 1 | $this->getLogger() |
|
| 1165 | 1 | ); |
|
| 1166 | } |
||
| 1167 | |||
| 1168 | public function newMembershipApplicationSubscriptionPaymentNotificationUseCase( string $updateToken ) { |
||
| 1169 | 2 | return new HandleSubscriptionPaymentNotificationUseCase( |
|
| 1170 | 2 | $this->getMembershipApplicationRepository(), |
|
| 1171 | 2 | $this->newMembershipApplicationAuthorizer( $updateToken ), |
|
| 1172 | $this->newApplyForMembershipMailer(), |
||
| 1173 | $this->getLogger() |
||
| 1174 | ); |
||
| 1175 | 2 | } |
|
| 1176 | 2 | ||
| 1177 | 2 | public function getPayPalPaymentNotificationVerifier(): PaymentNotificationVerifier { |
|
| 1178 | return $this->pimple['paypal-payment-notification-verifier']; |
||
| 1179 | 2 | } |
|
| 1180 | 2 | ||
| 1181 | public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ) { |
||
| 1182 | $this->pimple['paypal-payment-notification-verifier'] = $verifier; |
||
| 1183 | 2 | } |
|
| 1184 | 2 | ||
| 1185 | 2 | public function getPayPalMembershipFeeNotificationVerifier(): PaymentNotificationVerifier { |
|
| 1186 | 2 | return $this->pimple['paypal-membership-fee-notification-verifier']; |
|
| 1187 | 2 | } |
|
| 1188 | 2 | ||
| 1189 | public function setPayPalMembershipFeeNotificationVerifier( PaymentNotificationVerifier $verifier ) { |
||
| 1190 | $this->pimple['paypal-membership-fee-notification-verifier'] = $verifier; |
||
| 1191 | } |
||
| 1192 | |||
| 1193 | 90 | public function newCreditCardNotificationUseCase( string $updateToken ) { |
|
| 1194 | 90 | return new CreditCardNotificationUseCase( |
|
| 1195 | 90 | $this->getDonationRepository(), |
|
| 1196 | $this->newDonationAuthorizer( $updateToken ), |
||
| 1197 | $this->getCreditCardService(), |
||
| 1198 | $this->newDonationConfirmationMailer(), |
||
| 1199 | $this->getLogger(), |
||
| 1200 | $this->newDonationEventLogger() |
||
| 1201 | 90 | ); |
|
| 1202 | 90 | } |
|
| 1203 | 90 | ||
| 1204 | public function newCancelMembershipApplicationHtmlPresenter() { |
||
| 1205 | return new CancelMembershipApplicationHtmlPresenter( |
||
| 1206 | $this->getIncludeTemplate( 'Membership_Application_Cancellation_Confirmation.html.twig' ) |
||
| 1207 | ); |
||
| 1208 | } |
||
| 1209 | 21 | ||
| 1210 | 21 | public function newMembershipApplicationConfirmationHtmlPresenter() { |
|
| 1211 | 21 | return new MembershipApplicationConfirmationHtmlPresenter( |
|
| 1212 | $this->getIncludeTemplate( 'Membership_Application_Confirmation.html.twig' ) |
||
| 1213 | ); |
||
| 1214 | } |
||
| 1215 | |||
| 1216 | public function newMembershipFormViolationPresenter() { |
||
| 1217 | 30 | return new MembershipFormViolationPresenter( |
|
| 1218 | 30 | $this->getLayoutTemplate( 'Membership_Application.html.twig' ) |
|
| 1219 | 30 | ); |
|
| 1220 | } |
||
| 1221 | |||
| 1222 | public function setCreditCardService( CreditCardService $ccService ) { |
||
| 1223 | 12 | $this->pimple['credit-card-api-service'] = $ccService; |
|
| 1224 | 12 | } |
|
| 1225 | 12 | ||
| 1226 | public function getCreditCardService(): CreditCardService { |
||
| 1227 | return $this->pimple['credit-card-api-service']; |
||
| 1228 | } |
||
| 1229 | 20 | ||
| 1230 | 20 | public function newCreditCardNotificationPresenter(): CreditCardNotificationPresenter { |
|
| 1231 | 20 | return new CreditCardNotificationPresenter( |
|
| 1232 | 20 | new TwigTemplate( |
|
| 1233 | $this->getTwig(), |
||
| 1234 | 'Credit_Card_Payment_Notification.txt.twig', |
||
| 1235 | [ 'returnUrl' => $this->config['creditcard']['return-url'] ] |
||
| 1236 | 20 | ) |
|
| 1239 | |||
| 1240 | private function newDoctrineDonationPrePersistSubscriber(): DoctrineDonationPrePersistSubscriber { |
||
| 1247 | 2 | ||
| 1248 | private function newDoctrineMembershipApplicationPrePersistSubscriber(): DoctrineMembershipApplicationPrePersistSubscriber { |
||
| 1255 | 3 | ||
| 1256 | public function setTokenGenerator( TokenGenerator $tokenGenerator ) { |
||
| 1259 | 112 | ||
| 1260 | public function disableDoctrineSubscribers() { |
||
| 1263 | 109 | ||
| 1264 | private function newDonationTokenFetcher(): DonationTokenFetcher { |
||
| 1269 | |||
| 1270 | private function newMembershipApplicationTokenFetcher(): ApplicationTokenFetcher { |
||
| 1275 | |||
| 1276 | 118 | private function newDonationPolicyValidator(): AddDonationPolicyValidator { |
|
| 1283 | |||
| 1284 | private function newDonationAmountPolicyValidator(): AmountPolicyValidator { |
||
| 1288 | |||
| 1289 | public function getDonationTimeframeLimit() { |
||
| 1292 | 2 | ||
| 1293 | public function newSystemMessageResponse( string $message ) { |
||
| 1297 | |||
| 1298 | 2 | public function getMembershipApplicationTimeframeLimit() { |
|
| 1301 | |||
| 1302 | private function newAddCommentValidator(): AddCommentValidator { |
||
| 1305 | |||
| 1306 | 31 | private function getPageCache(): Cache { |
|
| 1309 | |||
| 1310 | 109 | private function getRenderedPageCache(): Cache { |
|
| 1313 | |||
| 1314 | 109 | public function enablePageCache() { |
|
| 1323 | 2 | ||
| 1324 | 2 | private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) { |
|
| 1333 | |||
| 1334 | public function setProfiler( Stopwatch $profiler ) { |
||
| 1337 | |||
| 1338 | 2 | public function setEmailValidator( EmailValidator $validator ) { |
|
| 1341 | 1 | ||
| 1342 | public function setLogger( LoggerInterface $logger ) { |
||
| 1345 | |||
| 1346 | public function setPaypalLogger( LoggerInterface $logger ) { |
||
| 1349 | |||
| 1350 | public function getProfilerDataCollector(): ProfilerDataCollector { |
||
| 1353 | |||
| 1354 | private function newIbanValidator(): IbanValidator { |
||
| 1357 | |||
| 1358 | public function setFilePrefixer( FilePrefixer $prefixer ): void { |
||
| 1361 | |||
| 1362 | private function getFilePrefixer(): FilePrefixer { |
||
| 1365 | |||
| 1366 | private function getFilePrefix(): string { |
||
| 1373 | |||
| 1374 | public function newDonationAcceptedEventHandler( string $updateToken ): DonationAcceptedEventHandler { |
||
| 1381 | |||
| 1382 | public function newPageNotFoundHtmlPresenter(): PageNotFoundPresenter { |
||
| 1385 | |||
| 1386 | public function setPageViewTracker( PageViewTracker $tracker ) { |
||
| 1391 | |||
| 1392 | public function getPageViewTracker(): PageViewTracker { |
||
| 1395 | |||
| 1396 | public function newServerSideTracker(): ServerSideTracker { |
||
| 1403 | |||
| 1404 | public function getI18nDirectory(): string { |
||
| 1407 | |||
| 1408 | /** |
||
| 1409 | * If the pathname does not start with a slash, make the path absolute to root dir of application |
||
| 1410 | */ |
||
| 1411 | private function getAbsolutePath( string $path ): string { |
||
| 1417 | |||
| 1418 | public function setContentPagePageSelector( PageSelector $pageSelector ): void { |
||
| 1421 | |||
| 1422 | public function getContentPagePageSelector(): PageSelector { |
||
| 1425 | |||
| 1426 | public function setContentProvider( ContentProvider $contentProvider ): void { |
||
| 1429 | |||
| 1430 | private function getContentProvider(): ContentProvider { |
||
| 1433 | |||
| 1434 | public function newMailTemplateFilenameTraversable(): MailTemplateFilenameTraversable { |
||
| 1439 | |||
| 1440 | } |
||
| 1441 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.