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 |
||
| 156 | class FunFunFactory { |
||
| 157 | |||
| 158 | private $config; |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @var \Pimple |
||
| 162 | */ |
||
| 163 | private $pimple; |
||
| 164 | |||
| 165 | private $addDoctrineSubscribers = true; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @var Stopwatch|null |
||
| 169 | */ |
||
| 170 | private $profiler = null; |
||
| 171 | |||
| 172 | 130 | public function __construct( array $config ) { |
|
| 176 | |||
| 177 | 130 | private function newPimple(): \Pimple { |
|
| 400 | |||
| 401 | 130 | public function getConnection(): Connection { |
|
| 404 | |||
| 405 | 76 | public function getEntityManager(): EntityManager { |
|
| 408 | |||
| 409 | 8 | private function newDonationEventLogger(): DonationEventLogger { |
|
| 415 | |||
| 416 | 130 | public function newInstaller(): Installer { |
|
| 419 | |||
| 420 | 12 | public function newListCommentsUseCase(): ListCommentsUseCase { |
|
| 423 | |||
| 424 | 6 | public function newCommentListJsonPresenter(): CommentListJsonPresenter { |
|
| 427 | |||
| 428 | 2 | public function newCommentListRssPresenter(): CommentListRssPresenter { |
|
| 434 | |||
| 435 | 4 | public function newCommentListHtmlPresenter(): CommentListHtmlPresenter { |
|
| 438 | |||
| 439 | 12 | private function getCommentFinder(): CommentFinder { |
|
| 442 | |||
| 443 | 9 | public function getSubscriptionRepository(): SubscriptionRepository { |
|
| 446 | |||
| 447 | 1 | public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ) { |
|
| 450 | |||
| 451 | 6 | private function getSubscriptionValidator(): SubscriptionValidator { |
|
| 454 | |||
| 455 | 35 | public function getEmailValidator(): EmailValidator { |
|
| 458 | |||
| 459 | 2 | private function getTemplateNameValidator(): TemplateNameValidator { |
|
| 462 | |||
| 463 | 2 | public function newDisplayPageUseCase(): DisplayPageUseCase { |
|
| 468 | |||
| 469 | 2 | public function newDisplayPagePresenter(): DisplayPagePresenter { |
|
| 472 | |||
| 473 | 1 | public function newAddSubscriptionHTMLPresenter(): AddSubscriptionHtmlPresenter { |
|
| 476 | |||
| 477 | 3 | public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter { |
|
| 483 | |||
| 484 | 2 | public function newAddSubscriptionJSONPresenter(): AddSubscriptionJsonPresenter { |
|
| 487 | |||
| 488 | 1 | public function newGetInTouchHTMLPresenter(): GetInTouchHtmlPresenter { |
|
| 491 | |||
| 492 | 77 | public function getTwig(): Twig_Environment { |
|
| 495 | |||
| 496 | /** |
||
| 497 | * Get a template, with the content for the layout areas filled in. |
||
| 498 | * |
||
| 499 | * @param string $templateName |
||
| 500 | * @return TwigTemplate |
||
| 501 | */ |
||
| 502 | 23 | private function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
| 509 | |||
| 510 | /** |
||
| 511 | * Get a layouted template that includes another template |
||
| 512 | * |
||
| 513 | * @param string $templateName Template to include |
||
| 514 | * @return TwigTemplate |
||
| 515 | */ |
||
| 516 | 37 | private function getIncludeTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
| 527 | |||
| 528 | 59 | private function getDefaultTwigVariables() { |
|
| 538 | |||
| 539 | 13 | private function newReferrerGeneralizer() { |
|
| 545 | |||
| 546 | 80 | private function getMediaWikiApi(): MediawikiApi { |
|
| 549 | |||
| 550 | 3 | public function setMediaWikiApi( MediawikiApi $api ) { |
|
| 553 | |||
| 554 | 77 | private function getGuzzleClient(): ClientInterface { |
|
| 557 | |||
| 558 | 80 | private function newWikiPageRetriever(): PageRetriever { |
|
| 559 | 80 | $PageRetriever = $this->newCachedPageRetriever(); |
|
| 560 | |||
| 561 | 80 | return $this->addProfilingDecorator( $PageRetriever, 'PageRetriever' ); |
|
| 562 | } |
||
| 563 | |||
| 564 | 80 | private function newCachedPageRetriever(): PageRetriever { |
|
| 565 | 80 | return new CachingPageRetriever( |
|
| 566 | 80 | $this->newNonCachedApiPageRetriever(), |
|
| 567 | 80 | $this->getPageCache() |
|
| 568 | ); |
||
| 569 | } |
||
| 570 | |||
| 571 | 80 | private function newNonCachedApiPageRetriever(): PageRetriever { |
|
| 572 | 80 | return new ApiBasedPageRetriever( |
|
| 573 | 80 | $this->getMediaWikiApi(), |
|
| 574 | 80 | new ApiUser( $this->config['cms-wiki-user'], $this->config['cms-wiki-password'] ), |
|
| 575 | 80 | $this->getLogger(), |
|
| 576 | 80 | $this->config['cms-wiki-title-prefix'] |
|
| 577 | ); |
||
| 578 | } |
||
| 579 | |||
| 580 | 89 | public function getLogger(): LoggerInterface { |
|
| 581 | 89 | return $this->pimple['logger']; |
|
| 582 | } |
||
| 583 | |||
| 584 | 77 | private function getVarPath(): string { |
|
| 585 | 77 | return __DIR__ . '/../../var'; |
|
| 586 | } |
||
| 587 | |||
| 588 | 77 | public function getCachePath(): string { |
|
| 589 | 77 | return $this->getVarPath() . '/cache'; |
|
| 590 | } |
||
| 591 | |||
| 592 | public function getLoggingPath(): string { |
||
| 593 | return $this->getVarPath() . '/log'; |
||
| 594 | } |
||
| 595 | |||
| 596 | public function getTemplatePath(): string { |
||
| 597 | return __DIR__ . '/../../app/templates'; |
||
| 598 | } |
||
| 599 | |||
| 600 | 6 | public function newAddSubscriptionUseCase(): AddSubscriptionUseCase { |
|
| 601 | 6 | return new AddSubscriptionUseCase( |
|
| 602 | 6 | $this->getSubscriptionRepository(), |
|
| 603 | 6 | $this->getSubscriptionValidator(), |
|
| 604 | 6 | $this->newAddSubscriptionMailer() |
|
| 605 | ); |
||
| 606 | } |
||
| 607 | |||
| 608 | 3 | public function newConfirmSubscriptionUseCase(): ConfirmSubscriptionUseCase { |
|
| 609 | 3 | return new ConfirmSubscriptionUseCase( |
|
| 610 | 3 | $this->getSubscriptionRepository(), |
|
| 611 | 3 | $this->newConfirmSubscriptionMailer() |
|
| 612 | ); |
||
| 613 | } |
||
| 614 | |||
| 615 | 6 | private function newAddSubscriptionMailer(): TemplateBasedMailer { |
|
| 628 | |||
| 629 | 3 | private function newConfirmSubscriptionMailer(): TemplateBasedMailer { |
|
| 630 | 3 | return $this->newTemplateMailer( |
|
| 631 | 3 | new TwigTemplate( |
|
| 632 | 3 | $this->getTwig(), |
|
| 633 | 3 | 'Mail_Subscription_Confirmation.twig', |
|
| 634 | 3 | [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 635 | ), |
||
| 636 | 3 | 'mail_subject_membership' |
|
| 637 | ); |
||
| 638 | } |
||
| 639 | |||
| 640 | 43 | private function newTemplateMailer( TwigTemplate $template, string $messageKey ): TemplateBasedMailer { |
|
| 641 | 43 | $mailer = new TemplateBasedMailer( |
|
| 642 | 43 | $this->getMessenger(), |
|
| 643 | $template, |
||
| 644 | 43 | $this->getTranslator()->trans( $messageKey ) |
|
| 645 | ); |
||
| 646 | |||
| 647 | 43 | $mailer = new LoggingMailer( $mailer, $this->getLogger() ); |
|
| 648 | |||
| 649 | 43 | return $this->addProfilingDecorator( $mailer, 'Mailer' ); |
|
| 650 | } |
||
| 651 | |||
| 652 | 40 | public function getGreetingGenerator() { |
|
| 653 | 40 | return $this->pimple['greeting_generator']; |
|
| 654 | } |
||
| 655 | |||
| 656 | public function newCheckIbanUseCase(): CheckIbanUseCase { |
||
| 657 | return new CheckIbanUseCase( $this->newBankDataConverter() ); |
||
| 658 | } |
||
| 659 | |||
| 660 | public function newGenerateIbanUseCase(): GenerateIbanUseCase { |
||
| 661 | return new GenerateIbanUseCase( $this->newBankDataConverter() ); |
||
| 662 | } |
||
| 663 | |||
| 664 | public function newIbanPresenter(): IbanPresenter { |
||
| 667 | |||
| 668 | 21 | public function newBankDataConverter() { |
|
| 669 | 21 | return new BankDataConverter( $this->config['bank-data-file'] ); |
|
| 670 | } |
||
| 671 | |||
| 672 | public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ) { |
||
| 673 | $this->pimple['subscription_validator'] = $subscriptionValidator; |
||
| 674 | } |
||
| 675 | |||
| 676 | public function setPageTitlePrefix( string $prefix ) { |
||
| 677 | $this->config['cms-wiki-title-prefix'] = $prefix; |
||
| 678 | } |
||
| 679 | |||
| 680 | 3 | public function newGetInTouchUseCase() { |
|
| 681 | 3 | return new GetInTouchUseCase( |
|
| 682 | 3 | $this->getContactValidator(), |
|
| 683 | 3 | $this->getMessenger(), |
|
| 684 | 3 | $this->newContactConfirmationMailer() |
|
| 685 | ); |
||
| 686 | } |
||
| 687 | |||
| 688 | 3 | private function newContactConfirmationMailer(): TemplateBasedMailer { |
|
| 689 | 3 | return $this->newTemplateMailer( |
|
| 690 | 3 | new TwigTemplate( $this->getTwig(), 'KontaktMailExtern.twig' ), |
|
| 691 | 3 | 'mail_subject_getintouch' |
|
| 692 | ); |
||
| 693 | } |
||
| 694 | |||
| 695 | 3 | private function getContactValidator(): GetInTouchValidator { |
|
| 696 | 3 | return $this->pimple['contact_validator']; |
|
| 697 | } |
||
| 698 | |||
| 699 | 6 | private function newSubscriptionDuplicateValidator(): SubscriptionDuplicateValidator { |
|
| 700 | 6 | return new SubscriptionDuplicateValidator( |
|
| 701 | 6 | $this->getSubscriptionRepository(), |
|
| 702 | 6 | $this->newSubscriptionDuplicateCutoffDate() |
|
| 703 | ); |
||
| 704 | } |
||
| 705 | |||
| 706 | 6 | private function newSubscriptionDuplicateCutoffDate(): \DateTime { |
|
| 707 | 6 | $cutoffDateTime = new \DateTime(); |
|
| 708 | 6 | $cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) ); |
|
| 709 | 6 | return $cutoffDateTime; |
|
| 710 | } |
||
| 711 | |||
| 712 | 6 | private function newHonorificValidator(): AllowedValuesValidator { |
|
| 713 | 6 | return new AllowedValuesValidator( $this->getHonorifics()->getKeys() ); |
|
| 714 | } |
||
| 715 | |||
| 716 | 64 | private function getHonorifics(): Honorifics { |
|
| 717 | 64 | return $this->pimple['honorifics']; |
|
| 718 | } |
||
| 719 | |||
| 720 | public function newPurgeCacheUseCase(): PurgeCacheUseCase { |
||
| 721 | return new PurgeCacheUseCase( |
||
| 722 | new AllOfTheCachePurger( $this->getTwig(), $this->getPageCache() ), |
||
| 723 | $this->config['purging-secret'] |
||
| 724 | ); |
||
| 725 | } |
||
| 726 | |||
| 727 | 21 | private function newBankDataValidator(): BankDataValidator { |
|
| 728 | 21 | return new BankDataValidator( new IbanValidator( $this->newBankDataConverter() ) ); |
|
| 729 | } |
||
| 730 | |||
| 731 | 43 | private function getMessenger(): Messenger { |
|
| 732 | 43 | return $this->pimple['messenger']; |
|
| 733 | } |
||
| 734 | |||
| 735 | 41 | public function setMessenger( Messenger $messenger ) { |
|
| 736 | 41 | $this->pimple['messenger'] = $messenger; |
|
| 737 | 41 | } |
|
| 738 | |||
| 739 | 40 | public function setNullMessenger() { |
|
| 740 | 40 | $this->setMessenger( new Messenger( |
|
| 741 | 40 | Swift_NullTransport::newInstance(), |
|
| 742 | 40 | $this->getOperatorAddress() |
|
| 743 | ) ); |
||
| 744 | 40 | } |
|
| 745 | |||
| 746 | 45 | public function getOperatorAddress() { |
|
| 749 | |||
| 750 | 8 | public function newInternalErrorHTMLPresenter(): InternalErrorHtmlPresenter { |
|
| 753 | |||
| 754 | 3 | public function newAccessDeniedHTMLPresenter(): InternalErrorHtmlPresenter { |
|
| 757 | |||
| 758 | 84 | public function getTranslator(): TranslatorInterface { |
|
| 761 | |||
| 762 | 2 | public function setTranslator( TranslatorInterface $translator ) { |
|
| 763 | 2 | $this->pimple['translator'] = $translator; |
|
| 764 | 2 | } |
|
| 765 | |||
| 766 | 77 | private function getTwigFactory(): TwigFactory { |
|
| 769 | |||
| 770 | 22 | private function newTextPolicyValidator( string $policyName ): TextPolicyValidator { |
|
| 771 | 22 | $contentProvider = $this->newWikiPageRetriever(); |
|
| 772 | 22 | $textPolicyConfig = $this->config['text-policies'][$policyName]; |
|
| 773 | |||
| 774 | 22 | return new TextPolicyValidator( |
|
| 775 | 22 | new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['badwords'] ?? '' ), |
|
| 776 | 22 | new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['whitewords'] ?? '' ) |
|
| 777 | ); |
||
| 778 | } |
||
| 779 | |||
| 780 | 3 | private function newCommentPolicyValidator(): TextPolicyValidator { |
|
| 783 | |||
| 784 | 5 | public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase { |
|
| 785 | 5 | return new CancelDonationUseCase( |
|
| 786 | 5 | $this->getDonationRepository(), |
|
| 787 | 5 | $this->newCancelDonationMailer(), |
|
| 788 | 5 | $this->newDonationAuthorizer( $updateToken ), |
|
| 789 | 5 | $this->newDonationEventLogger() |
|
| 790 | ); |
||
| 791 | } |
||
| 792 | |||
| 793 | 5 | private function newCancelDonationMailer(): TemplateBasedMailer { |
|
| 803 | |||
| 804 | 13 | public function newAddDonationUseCase(): AddDonationUseCase { |
|
| 805 | 13 | return new AddDonationUseCase( |
|
| 806 | 13 | $this->getDonationRepository(), |
|
| 807 | 13 | $this->newDonationValidator(), |
|
| 808 | 13 | $this->newDonationPolicyValidator(), |
|
| 809 | 13 | $this->newReferrerGeneralizer(), |
|
| 810 | 13 | $this->newDonationConfirmationMailer(), |
|
| 811 | 13 | $this->newBankTransferCodeGenerator(), |
|
| 812 | 13 | $this->newDonationTokenFetcher() |
|
| 813 | ); |
||
| 814 | } |
||
| 815 | |||
| 816 | 13 | private function newBankTransferCodeGenerator(): TransferCodeGenerator { |
|
| 817 | 13 | return new UniqueTransferCodeGenerator( |
|
| 818 | 13 | new SimpleTransferCodeGenerator(), |
|
| 819 | 13 | $this->getEntityManager() |
|
| 820 | ); |
||
| 821 | } |
||
| 822 | |||
| 823 | 13 | private function newDonationValidator(): AddDonationValidator { |
|
| 824 | 13 | return new AddDonationValidator( |
|
| 825 | 13 | $this->newAmountValidator(), |
|
| 826 | 13 | $this->newBankDataValidator(), |
|
| 827 | 13 | $this->getEmailValidator() |
|
| 828 | ); |
||
| 829 | } |
||
| 830 | |||
| 831 | 2 | public function newPersonalInfoValidator(): DonorValidator { |
|
| 838 | |||
| 839 | 16 | private function newDonationConfirmationMailer(): DonationConfirmationMailer { |
|
| 840 | 16 | return new DonationConfirmationMailer( |
|
| 841 | 16 | $this->newTemplateMailer( |
|
| 842 | 16 | new TwigTemplate( |
|
| 843 | 16 | $this->getTwig(), |
|
| 844 | 16 | 'Mail_Donation_Confirmation.twig', // TODO: ongoing unification of different templates |
|
| 845 | [ |
||
| 846 | 16 | 'basepath' => $this->config['web-basepath'], |
|
| 847 | 16 | 'greeting_generator' => $this->getGreetingGenerator() |
|
| 848 | ] |
||
| 849 | ), |
||
| 850 | 16 | 'mail_subject_confirm_donation' |
|
| 851 | ) |
||
| 852 | ); |
||
| 853 | } |
||
| 854 | |||
| 855 | 1 | public function newPayPalUrlGenerator() { |
|
| 858 | |||
| 859 | 1 | private function getPayPalUrlConfig() { |
|
| 860 | 1 | return PayPalUrlConfig::newFromConfig( $this->config['paypal'] ); |
|
| 861 | } |
||
| 862 | |||
| 863 | 2 | private function newCreditCardUrlGenerator() { |
|
| 866 | |||
| 867 | 2 | private function newCreditCardUrlConfig() { |
|
| 870 | |||
| 871 | 34 | public function getDonationRepository(): DonationRepository { |
|
| 874 | |||
| 875 | 15 | public function newAmountValidator(): AmountValidator { |
|
| 878 | |||
| 879 | 11 | private function newAmountFormatter(): AmountFormatter { |
|
| 882 | |||
| 883 | 2 | public function newDecimalNumberFormatter(): NumberFormatter { |
|
| 886 | |||
| 887 | 3 | public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase { |
|
| 888 | 3 | return new AddCommentUseCase( |
|
| 889 | 3 | $this->getDonationRepository(), |
|
| 890 | 3 | $this->newDonationAuthorizer( $updateToken ), |
|
| 891 | 3 | $this->newCommentPolicyValidator(), |
|
| 892 | 3 | $this->newAddCommentValidator() |
|
| 893 | ); |
||
| 894 | } |
||
| 895 | |||
| 896 | 20 | private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer { |
|
| 897 | 20 | return new DoctrineDonationAuthorizer( |
|
| 898 | 20 | $this->getEntityManager(), |
|
| 899 | $updateToken, |
||
| 900 | $accessToken |
||
| 901 | ); |
||
| 902 | } |
||
| 903 | |||
| 904 | 76 | public function getTokenGenerator(): TokenGenerator { |
|
| 907 | |||
| 908 | 14 | public function newDonationConfirmationPresenter() { |
|
| 909 | 14 | return new DonationConfirmationHtmlPresenter( |
|
| 910 | 14 | $this->getIncludeTemplate( 'DonationConfirmation.twig', [ 'piwikGoals' => [ 3 ] ] ) |
|
| 911 | ); |
||
| 912 | } |
||
| 913 | |||
| 914 | 2 | public function newCreditCardPaymentHtmlPresenter() { |
|
| 915 | 2 | return new CreditCardPaymentHtmlPresenter( |
|
| 916 | 2 | $this->getIncludeTemplate( 'CreditCardPaymentIframe.twig' ), |
|
| 917 | 2 | $this->getTranslator(), |
|
| 918 | 2 | $this->newCreditCardUrlGenerator() |
|
| 919 | ); |
||
| 920 | } |
||
| 921 | |||
| 922 | 5 | public function newCancelDonationHtmlPresenter() { |
|
| 923 | 5 | return new CancelDonationHtmlPresenter( |
|
| 924 | 5 | $this->getIncludeTemplate( 'Donation_Cancellation_Confirmation.twig' ) |
|
| 925 | ); |
||
| 926 | } |
||
| 927 | |||
| 928 | 8 | public function newApplyForMembershipUseCase(): ApplyForMembershipUseCase { |
|
| 929 | 8 | return new ApplyForMembershipUseCase( |
|
| 930 | 8 | $this->getMembershipApplicationRepository(), |
|
| 931 | 8 | $this->newMembershipApplicationTokenFetcher(), |
|
| 932 | 8 | $this->newApplyForMembershipMailer(), |
|
| 933 | 8 | $this->newMembershipApplicationValidator(), |
|
| 934 | 8 | $this->newMembershipApplicationTracker(), |
|
| 935 | 8 | $this->newMembershipApplicationPiwikTracker() |
|
| 936 | ); |
||
| 937 | } |
||
| 938 | |||
| 939 | 8 | private function newApplyForMembershipMailer(): TemplateBasedMailer { |
|
| 949 | |||
| 950 | 8 | private function newMembershipApplicationValidator(): MembershipApplicationValidator { |
|
| 957 | |||
| 958 | 8 | private function newMembershipApplicationTracker(): ApplicationTracker { |
|
| 961 | |||
| 962 | 8 | private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker { |
|
| 965 | |||
| 966 | 2 | public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase { |
|
| 967 | 2 | return new CancelMembershipApplicationUseCase( |
|
| 968 | 2 | $this->newMembershipApplicationAuthorizer( $updateToken ), |
|
| 969 | 2 | $this->getMembershipApplicationRepository(), |
|
| 970 | 2 | $this->newCancelMembershipApplicationMailer() |
|
| 971 | ); |
||
| 972 | } |
||
| 973 | |||
| 974 | 2 | private function newMembershipApplicationAuthorizer( |
|
| 975 | string $updateToken = null, string $accessToken = null ): ApplicationAuthorizer { |
||
| 976 | |||
| 977 | 2 | return new DoctrineApplicationAuthorizer( |
|
| 978 | 2 | $this->getEntityManager(), |
|
| 979 | $updateToken, |
||
| 980 | $accessToken |
||
| 981 | ); |
||
| 982 | } |
||
| 983 | |||
| 984 | 10 | public function getMembershipApplicationRepository(): ApplicationRepository { |
|
| 985 | 10 | return $this->pimple['membership_application_repository']; |
|
| 986 | } |
||
| 987 | |||
| 988 | 2 | private function newCancelMembershipApplicationMailer(): TemplateBasedMailer { |
|
| 989 | 2 | return $this->newTemplateMailer( |
|
| 990 | 2 | new TwigTemplate( |
|
| 991 | 2 | $this->getTwig(), |
|
| 992 | 2 | 'Mail_Membership_Application_Cancellation_Confirmation.twig', |
|
| 993 | 2 | [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 994 | ), |
||
| 995 | 2 | 'mail_subject_confirm_membership_application_cancellation' |
|
| 996 | ); |
||
| 997 | } |
||
| 998 | |||
| 999 | public function newMembershipApplicationConfirmationUseCase( string $accessToken ) { |
||
| 1000 | return new ShowMembershipApplicationConfirmationUseCase( |
||
| 1001 | $this->newMembershipApplicationAuthorizer( null, $accessToken ), $this->getMembershipApplicationRepository(), |
||
| 1002 | $this->newMembershipApplicationTokenFetcher() |
||
| 1003 | ); |
||
| 1004 | } |
||
| 1005 | |||
| 1006 | 9 | public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase { |
|
| 1007 | 9 | return new ShowDonationConfirmationUseCase( |
|
| 1008 | 9 | $this->newDonationAuthorizer( null, $accessToken ), |
|
| 1009 | 9 | $this->getDonationRepository() |
|
| 1010 | ); |
||
| 1011 | } |
||
| 1012 | |||
| 1013 | 7 | public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ) { |
|
| 1014 | 7 | $this->pimple['confirmation-page-selector'] = $selector; |
|
| 1015 | 7 | } |
|
| 1016 | |||
| 1017 | 17 | public function getDonationConfirmationPageSelector() { |
|
| 1020 | |||
| 1021 | 2 | public function newDonationFormViolationPresenter() { |
|
| 1022 | 2 | $template = $this->getLayoutTemplate( 'DisplayPageLayout.twig' ); |
|
| 1023 | // TODO make this dependent on the 'form' value from the HTTP POST request |
||
| 1024 | // (we need different form pages for A/B testing) |
||
| 1025 | 2 | $template->context['main_template'] = 'DonationForm.twig'; |
|
|
|
|||
| 1026 | 2 | return new DonationFormViolationPresenter( $template, $this->newAmountFormatter() ); |
|
| 1027 | } |
||
| 1028 | |||
| 1029 | 9 | public function newDonationFormPresenter() { |
|
| 1036 | |||
| 1037 | 1 | public function newHandlePayPalPaymentNotificationUseCase( string $updateToken ) { |
|
| 1038 | 1 | return new HandlePayPalPaymentNotificationUseCase( |
|
| 1039 | 1 | $this->getDonationRepository(), |
|
| 1040 | 1 | $this->newDonationAuthorizer( $updateToken ), |
|
| 1041 | 1 | $this->newDonationConfirmationMailer(), |
|
| 1042 | 1 | $this->getLogger(), |
|
| 1043 | 1 | $this->newDonationEventLogger() |
|
| 1044 | ); |
||
| 1045 | } |
||
| 1046 | |||
| 1047 | 2 | public function getPayPalPaymentNotificationVerifier(): PaymentNotificationVerifier { |
|
| 1048 | 2 | return $this->pimple['paypal-payment-notification-verifier']; |
|
| 1049 | } |
||
| 1050 | |||
| 1051 | 2 | public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ) { |
|
| 1052 | 2 | $this->pimple['paypal-payment-notification-verifier'] = $verifier; |
|
| 1053 | 2 | } |
|
| 1054 | |||
| 1055 | 2 | public function newCreditCardNotificationUseCase( string $updateToken ) { |
|
| 1056 | 2 | return new CreditCardNotificationUseCase( |
|
| 1057 | 2 | $this->getDonationRepository(), |
|
| 1058 | 2 | $this->newDonationAuthorizer( $updateToken ), |
|
| 1059 | 2 | $this->getCreditCardService(), |
|
| 1060 | 2 | $this->newDonationConfirmationMailer(), |
|
| 1061 | 2 | $this->getLogger(), |
|
| 1062 | 2 | $this->newDonationEventLogger() |
|
| 1063 | ); |
||
| 1064 | } |
||
| 1065 | |||
| 1066 | 2 | public function newCancelMembershipApplicationHtmlPresenter() { |
|
| 1067 | 2 | return new CancelMembershipApplicationHtmlPresenter( |
|
| 1068 | 2 | $this->getIncludeTemplate( 'Membership_Application_Cancellation_Confirmation.twig' ) |
|
| 1069 | ); |
||
| 1070 | } |
||
| 1071 | |||
| 1072 | public function newMembershipApplicationConfirmationHtmlPresenter() { |
||
| 1073 | return new MembershipApplicationConfirmationHtmlPresenter( |
||
| 1074 | $this->getIncludeTemplate( 'MembershipApplicationConfirmation.twig' ) |
||
| 1075 | ); |
||
| 1076 | } |
||
| 1077 | |||
| 1078 | 2 | public function newMembershipFormViolationPresenter() { |
|
| 1079 | 2 | return new MembershipFormViolationPresenter( |
|
| 1080 | 2 | $this->getIncludeTemplate( 'MembershipApplication.twig' ) |
|
| 1081 | ); |
||
| 1082 | } |
||
| 1083 | |||
| 1084 | 2 | public function setCreditCardService( CreditCardService $ccService ) { |
|
| 1085 | 2 | $this->pimple['credit-card-api-service'] = $ccService; |
|
| 1086 | 2 | } |
|
| 1087 | |||
| 1088 | 2 | public function getCreditCardService(): CreditCardService { |
|
| 1091 | |||
| 1092 | 2 | public function newCreditCardNotificationPresenter(): CreditCardNotificationPresenter { |
|
| 1093 | 2 | return new CreditCardNotificationPresenter( |
|
| 1094 | 2 | new TwigTemplate( |
|
| 1095 | 2 | $this->getTwig(), |
|
| 1096 | 2 | 'CreditCardPaymentNotification.twig', |
|
| 1097 | 2 | [ 'returnUrl' => $this->config['creditcard']['return-url'] ] |
|
| 1098 | ) |
||
| 1099 | ); |
||
| 1100 | } |
||
| 1101 | |||
| 1102 | 76 | private function newDoctrineDonationPrePersistSubscriber(): DoctrineDonationPrePersistSubscriber { |
|
| 1103 | 76 | $tokenGenerator = $this->getTokenGenerator(); |
|
| 1104 | 76 | return new DoctrineDonationPrePersistSubscriber( |
|
| 1105 | $tokenGenerator, |
||
| 1106 | $tokenGenerator |
||
| 1107 | ); |
||
| 1108 | } |
||
| 1109 | |||
| 1110 | 76 | private function newDoctrineMembershipApplicationPrePersistSubscriber(): DoctrineMembershipApplicationPrePersistSubscriber { |
|
| 1117 | |||
| 1118 | 16 | public function setTokenGenerator( TokenGenerator $tokenGenerator ) { |
|
| 1119 | 16 | $this->pimple['token_generator'] = $tokenGenerator; |
|
| 1120 | 16 | } |
|
| 1121 | |||
| 1122 | public function disableDoctrineSubscribers() { |
||
| 1123 | $this->addDoctrineSubscribers = false; |
||
| 1124 | } |
||
| 1125 | |||
| 1126 | 13 | private function newDonationTokenFetcher(): DonationTokenFetcher { |
|
| 1131 | |||
| 1132 | 8 | private function newMembershipApplicationTokenFetcher(): ApplicationTokenFetcher { |
|
| 1133 | 8 | return new DoctrineApplicationTokenFetcher( |
|
| 1134 | 8 | $this->getEntityManager() |
|
| 1135 | ); |
||
| 1136 | } |
||
| 1137 | |||
| 1138 | 13 | private function newDonationPolicyValidator(): AddDonationPolicyValidator { |
|
| 1139 | 13 | return new AddDonationPolicyValidator( |
|
| 1140 | 13 | $this->newDonationAmountPolicyValidator(), |
|
| 1141 | 13 | $this->newTextPolicyValidator( 'fields' ) |
|
| 1142 | ); |
||
| 1143 | } |
||
| 1144 | |||
| 1145 | 13 | private function newDonationAmountPolicyValidator(): AmountPolicyValidator { |
|
| 1149 | |||
| 1150 | 2 | public function getDonationTimeframeLimit() { |
|
| 1151 | 2 | return $this->config['donation-timeframe-limit']; |
|
| 1152 | } |
||
| 1153 | |||
| 1154 | 2 | public function newSystemMessageResponse( string $message ) { |
|
| 1155 | 2 | $test = $this->getIncludeTemplate( 'System_Message.twig' ); |
|
| 1156 | 2 | return $test->render( [ 'message' => $message ] ); |
|
| 1157 | } |
||
| 1158 | |||
| 1159 | 2 | public function getMembershipApplicationTimeframeLimit() { |
|
| 1162 | |||
| 1163 | 3 | private function newAddCommentValidator(): AddCommentValidator { |
|
| 1164 | 3 | return new AddCommentValidator(); |
|
| 1165 | } |
||
| 1166 | |||
| 1167 | 80 | private function getPageCache(): Cache { |
|
| 1170 | |||
| 1171 | public function enablePageCache() { |
||
| 1172 | $this->pimple['page_cache'] = $this->pimple->share( function() { |
||
| 1173 | return new FilesystemCache( $this->getCachePath() . '/pages' ); |
||
| 1174 | } ); |
||
| 1175 | } |
||
| 1176 | |||
| 1177 | 86 | private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) { |
|
| 1178 | 86 | if ( $this->profiler === null ) { |
|
| 1179 | 86 | return $objectToDecorate; |
|
| 1180 | } |
||
| 1181 | |||
| 1182 | $builder = new ProfilingDecoratorBuilder( $this->profiler, $this->getProfilerDataCollector() ); |
||
| 1183 | |||
| 1184 | return $builder->decorate( $objectToDecorate, $profilingLabel ); |
||
| 1185 | } |
||
| 1186 | |||
| 1187 | public function setProfiler( Stopwatch $profiler ) { |
||
| 1188 | $this->profiler = $profiler; |
||
| 1189 | } |
||
| 1190 | |||
| 1191 | public function setLogger( LoggerInterface $logger ) { |
||
| 1192 | $this->pimple['logger'] = $logger; |
||
| 1193 | } |
||
| 1194 | |||
| 1195 | public function getProfilerDataCollector(): ProfilerDataCollector { |
||
| 1198 | |||
| 1199 | } |
||
| 1200 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.