|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Frontend\Factories; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Common\Cache\Cache; |
|
8
|
|
|
use Doctrine\Common\Cache\FilesystemCache; |
|
9
|
|
|
use Doctrine\Common\Cache\VoidCache; |
|
10
|
|
|
use Doctrine\DBAL\Connection; |
|
11
|
|
|
use Doctrine\DBAL\DriverManager; |
|
12
|
|
|
use Doctrine\ORM\EntityManager; |
|
13
|
|
|
use GuzzleHttp\Client; |
|
14
|
|
|
use GuzzleHttp\ClientInterface; |
|
15
|
|
|
use GuzzleHttp\Handler\CurlHandler; |
|
16
|
|
|
use GuzzleHttp\HandlerStack; |
|
17
|
|
|
use Mediawiki\Api\ApiUser; |
|
18
|
|
|
use Mediawiki\Api\Guzzle\MiddlewareFactory; |
|
19
|
|
|
use Mediawiki\Api\MediawikiApi; |
|
20
|
|
|
use NumberFormatter; |
|
21
|
|
|
use Pimple\Container; |
|
22
|
|
|
use Psr\Log\LoggerInterface; |
|
23
|
|
|
use Psr\Log\NullLogger; |
|
24
|
|
|
use Swift_MailTransport; |
|
25
|
|
|
use Swift_NullTransport; |
|
26
|
|
|
use Symfony\Component\Stopwatch\Stopwatch; |
|
27
|
|
|
use Symfony\Component\Translation\TranslatorInterface; |
|
28
|
|
|
use TNvpServiceDispatcher; |
|
29
|
|
|
use Twig_Environment; |
|
30
|
|
|
use Twig_Extensions_Extension_Intl; |
|
31
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\DonationAcceptedEventHandler; |
|
32
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\Cache\AllOfTheCachePurger; |
|
33
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Honorifics; |
|
34
|
|
|
use WMDE\Fundraising\Frontend\UseCases\GetInTouch\GetInTouchUseCase; |
|
35
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\Cache\AuthorizedCachePurger; |
|
36
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Authorization\DonationAuthorizer; |
|
37
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Authorization\DonationTokenFetcher; |
|
38
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineCommentFinder; |
|
39
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationAuthorizer; |
|
40
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationEventLogger; |
|
41
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationPrePersistSubscriber; |
|
42
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationRepository; |
|
43
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationTokenFetcher; |
|
44
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Domain\Repositories\CommentFinder; |
|
45
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Domain\Repositories\DonationRepository; |
|
46
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\BestEffortDonationEventLogger; |
|
47
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\DonationConfirmationMailer; |
|
48
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\DonationEventLogger; |
|
49
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\LoggingCommentFinder; |
|
50
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\LoggingDonationRepository; |
|
51
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddComment\AddCommentUseCase; |
|
52
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddComment\AddCommentValidator; |
|
53
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationPolicyValidator; |
|
54
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationUseCase; |
|
55
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationValidator; |
|
56
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\ReferrerGeneralizer; |
|
57
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\CancelDonation\CancelDonationUseCase; |
|
58
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\CreditCardPaymentNotification\CreditCardNotificationUseCase; |
|
59
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\HandlePayPalPaymentNotification\HandlePayPalPaymentNotificationUseCase; |
|
60
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ListComments\ListCommentsUseCase; |
|
61
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ShowDonationConfirmation\ShowDonationConfirmationUseCase; |
|
62
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Validation\DonorAddressValidator; |
|
63
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Validation\DonorNameValidator; |
|
64
|
|
|
use WMDE\Fundraising\Frontend\DonationContext\Validation\DonorValidator; |
|
65
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\InternetDomainNameValidator; |
|
66
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\LoggingMailer; |
|
67
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\LoggingPaymentNotificationVerifier; |
|
68
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\Messenger; |
|
69
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\OperatorMailer; |
|
70
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\PageRetrieverBasedStringList; |
|
71
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\PaymentNotificationVerifier; |
|
72
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\PayPalPaymentNotificationVerifier; |
|
73
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\ProfilerDataCollector; |
|
74
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\ProfilingDecoratorBuilder; |
|
75
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\RandomTokenGenerator; |
|
76
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\TemplateBasedMailer; |
|
77
|
|
|
use WMDE\Fundraising\Frontend\Infrastructure\TokenGenerator; |
|
78
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\ApplicationAuthorizer; |
|
79
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\ApplicationTokenFetcher; |
|
80
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationAuthorizer; |
|
81
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationPiwikTracker; |
|
82
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationRepository; |
|
83
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationTokenFetcher; |
|
84
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationTracker; |
|
85
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineMembershipApplicationPrePersistSubscriber; |
|
86
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Domain\Model\EmailAddress; |
|
87
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Domain\Repositories\ApplicationRepository; |
|
88
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Infrastructure\LoggingApplicationRepository; |
|
89
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Tracking\ApplicationPiwikTracker; |
|
90
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Tracking\ApplicationTracker; |
|
91
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\ApplyForMembershipUseCase; |
|
92
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\MembershipApplicationValidator; |
|
93
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\CancelMembershipApplication\CancelMembershipApplicationUseCase; |
|
94
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ShowMembershipApplicationConfirmation\ShowMembershipApplicationConfirmationUseCase; |
|
95
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\McpCreditCardService; |
|
96
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\UniqueTransferCodeGenerator; |
|
97
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\Domain\BankDataConverter; |
|
98
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\Domain\SimpleTransferCodeGenerator; |
|
99
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\Domain\TransferCodeGenerator; |
|
100
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\Infrastructure\CreditCardService; |
|
101
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\CheckIban\CheckIbanUseCase; |
|
102
|
|
|
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\GenerateIban\GenerateIbanUseCase; |
|
103
|
|
|
use WMDE\Fundraising\Frontend\Presentation\AmountFormatter; |
|
104
|
|
|
use WMDE\Fundraising\Frontend\Presentation\CreditCardUrlConfig; |
|
105
|
|
|
use WMDE\Fundraising\Frontend\Presentation\CreditCardUrlGenerator; |
|
106
|
|
|
use WMDE\Fundraising\Frontend\Presentation\DonationConfirmationPageSelector; |
|
107
|
|
|
use WMDE\Fundraising\Frontend\Presentation\FilePrefixer; |
|
108
|
|
|
use WMDE\Fundraising\Frontend\Presentation\GreetingGenerator; |
|
109
|
|
|
use WMDE\Fundraising\Frontend\Presentation\PayPalUrlConfig; |
|
110
|
|
|
use WMDE\Fundraising\Frontend\Presentation\PayPalUrlGenerator; |
|
111
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionHtmlPresenter; |
|
112
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionJsonPresenter; |
|
113
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelDonationHtmlPresenter; |
|
114
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelMembershipApplicationHtmlPresenter; |
|
115
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListHtmlPresenter; |
|
116
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListJsonPresenter; |
|
117
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListRssPresenter; |
|
118
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\ConfirmSubscriptionHtmlPresenter; |
|
119
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardNotificationPresenter; |
|
120
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardPaymentHtmlPresenter; |
|
121
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationConfirmationHtmlPresenter; |
|
122
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormPresenter; |
|
123
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormViolationPresenter; |
|
124
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\GetInTouchHtmlPresenter; |
|
125
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\IbanPresenter; |
|
126
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\InternalErrorHtmlPresenter; |
|
127
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipApplicationConfirmationHtmlPresenter; |
|
128
|
|
|
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipFormViolationPresenter; |
|
129
|
|
|
use WMDE\Fundraising\Frontend\Presentation\TwigTemplate; |
|
130
|
|
|
use WMDE\Fundraising\Frontend\SubscriptionContext\DataAccess\DoctrineSubscriptionRepository; |
|
131
|
|
|
use WMDE\Fundraising\Frontend\SubscriptionContext\Domain\Repositories\SubscriptionRepository; |
|
132
|
|
|
use WMDE\Fundraising\Frontend\SubscriptionContext\Infrastructure\LoggingSubscriptionRepository; |
|
133
|
|
|
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\AddSubscription\AddSubscriptionUseCase; |
|
134
|
|
|
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\ConfirmSubscription\ConfirmSubscriptionUseCase; |
|
135
|
|
|
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionDuplicateValidator; |
|
136
|
|
|
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionValidator; |
|
137
|
|
|
use WMDE\Fundraising\Frontend\Validation\AllowedValuesValidator; |
|
138
|
|
|
use WMDE\Fundraising\Frontend\Validation\AmountPolicyValidator; |
|
139
|
|
|
use WMDE\Fundraising\Frontend\Validation\PaymentDataValidator; |
|
140
|
|
|
use WMDE\Fundraising\Frontend\Validation\BankDataValidator; |
|
141
|
|
|
use WMDE\Fundraising\Frontend\Validation\EmailValidator; |
|
142
|
|
|
use WMDE\Fundraising\Frontend\Validation\GetInTouchValidator; |
|
143
|
|
|
use WMDE\Fundraising\Frontend\Validation\IbanValidator; |
|
144
|
|
|
use WMDE\Fundraising\Frontend\Validation\MembershipFeeValidator; |
|
145
|
|
|
use WMDE\Fundraising\Frontend\Validation\TemplateNameValidator; |
|
146
|
|
|
use WMDE\Fundraising\Frontend\Validation\TextPolicyValidator; |
|
147
|
|
|
use WMDE\Fundraising\Store\Factory as StoreFactory; |
|
148
|
|
|
use WMDE\Fundraising\Store\Installer; |
|
149
|
|
|
use WMDE\PageRetriever\ApiBasedPageRetriever; |
|
150
|
|
|
use WMDE\PageRetriever\CachingPageRetriever; |
|
151
|
|
|
use WMDE\PageRetriever\PageRetriever; |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @licence GNU GPL v2+ |
|
155
|
|
|
*/ |
|
156
|
|
|
class FunFunFactory { |
|
157
|
|
|
|
|
158
|
|
|
private $config; |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @var Container |
|
162
|
|
|
*/ |
|
163
|
|
|
private $pimple; |
|
164
|
|
|
|
|
165
|
|
|
private $addDoctrineSubscribers = true; |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @var Stopwatch|null |
|
169
|
|
|
*/ |
|
170
|
|
|
private $profiler = null; |
|
171
|
|
|
|
|
172
|
150 |
|
public function __construct( array $config ) { |
|
173
|
150 |
|
$this->config = $config; |
|
174
|
150 |
|
$this->pimple = $this->newPimple(); |
|
175
|
150 |
|
} |
|
176
|
|
|
|
|
177
|
150 |
|
private function newPimple(): Container { |
|
178
|
150 |
|
$pimple = new Container(); |
|
179
|
|
|
|
|
180
|
|
|
$pimple['logger'] = function() { |
|
181
|
113 |
|
return new NullLogger(); |
|
182
|
|
|
}; |
|
183
|
|
|
|
|
184
|
|
|
$pimple['profiler_data_collector'] = function() { |
|
185
|
|
|
return new ProfilerDataCollector(); |
|
186
|
|
|
}; |
|
187
|
|
|
|
|
188
|
|
|
$pimple['dbal_connection'] = function() { |
|
189
|
150 |
|
return DriverManager::getConnection( $this->config['db'] ); |
|
190
|
|
|
}; |
|
191
|
|
|
|
|
192
|
|
|
$pimple['entity_manager'] = function() { |
|
193
|
80 |
|
$entityManager = ( new StoreFactory( $this->getConnection() ) )->getEntityManager(); |
|
194
|
80 |
|
if ( $this->addDoctrineSubscribers ) { |
|
195
|
80 |
|
$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() ); |
|
196
|
80 |
|
$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() ); |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
80 |
|
return $entityManager; |
|
200
|
|
|
}; |
|
201
|
|
|
|
|
202
|
|
|
$pimple['subscription_repository'] = function() { |
|
203
|
8 |
|
return new LoggingSubscriptionRepository( |
|
204
|
8 |
|
new DoctrineSubscriptionRepository( $this->getEntityManager() ), |
|
205
|
8 |
|
$this->getLogger() |
|
206
|
|
|
); |
|
207
|
|
|
}; |
|
208
|
|
|
|
|
209
|
|
|
$pimple['donation_repository'] = function() { |
|
210
|
39 |
|
return new LoggingDonationRepository( |
|
211
|
39 |
|
new DoctrineDonationRepository( $this->getEntityManager() ), |
|
212
|
39 |
|
$this->getLogger() |
|
213
|
|
|
); |
|
214
|
|
|
}; |
|
215
|
|
|
|
|
216
|
|
|
$pimple['membership_application_repository'] = function() { |
|
217
|
13 |
|
return new LoggingApplicationRepository( |
|
218
|
13 |
|
new DoctrineApplicationRepository( $this->getEntityManager() ), |
|
219
|
13 |
|
$this->getLogger() |
|
220
|
|
|
); |
|
221
|
|
|
}; |
|
222
|
|
|
|
|
223
|
|
|
$pimple['comment_repository'] = function() { |
|
224
|
12 |
|
$finder = new LoggingCommentFinder( |
|
225
|
12 |
|
new DoctrineCommentFinder( $this->getEntityManager() ), |
|
226
|
12 |
|
$this->getLogger() |
|
227
|
|
|
); |
|
228
|
|
|
|
|
229
|
12 |
|
return $this->addProfilingDecorator( $finder, 'CommentFinder' ); |
|
230
|
|
|
}; |
|
231
|
|
|
|
|
232
|
|
|
$pimple['mail_validator'] = function() { |
|
233
|
39 |
|
return new EmailValidator( new InternetDomainNameValidator() ); |
|
234
|
|
|
}; |
|
235
|
|
|
|
|
236
|
|
|
$pimple['subscription_validator'] = function() { |
|
237
|
6 |
|
return new SubscriptionValidator( |
|
238
|
6 |
|
$this->getEmailValidator(), |
|
239
|
6 |
|
$this->newTextPolicyValidator( 'fields' ), |
|
240
|
6 |
|
$this->newSubscriptionDuplicateValidator(), |
|
241
|
6 |
|
$this->newHonorificValidator() |
|
242
|
|
|
); |
|
243
|
|
|
}; |
|
244
|
|
|
|
|
245
|
|
|
$pimple['template_name_validator'] = function() { |
|
246
|
8 |
|
return new TemplateNameValidator( $this->getTwig() ); |
|
247
|
|
|
}; |
|
248
|
|
|
|
|
249
|
|
|
$pimple['contact_validator'] = function() { |
|
250
|
3 |
|
return new GetInTouchValidator( $this->getEmailValidator() ); |
|
251
|
|
|
}; |
|
252
|
|
|
|
|
253
|
|
|
$pimple['greeting_generator'] = function() { |
|
254
|
46 |
|
return new GreetingGenerator(); |
|
255
|
|
|
}; |
|
256
|
|
|
|
|
257
|
|
|
$pimple['mw_api'] = function() { |
|
258
|
91 |
|
return new MediawikiApi( |
|
259
|
91 |
|
$this->config['cms-wiki-api-url'], |
|
260
|
91 |
|
$this->getGuzzleClient() |
|
261
|
|
|
); |
|
262
|
|
|
}; |
|
263
|
|
|
|
|
264
|
|
|
$pimple['guzzle_client'] = function() { |
|
265
|
91 |
|
$middlewareFactory = new MiddlewareFactory(); |
|
266
|
91 |
|
$middlewareFactory->setLogger( $this->getLogger() ); |
|
267
|
|
|
|
|
268
|
91 |
|
$handlerStack = HandlerStack::create( new CurlHandler() ); |
|
269
|
91 |
|
$handlerStack->push( $middlewareFactory->retry() ); |
|
270
|
|
|
|
|
271
|
91 |
|
$guzzle = new Client( [ |
|
272
|
91 |
|
'cookies' => true, |
|
273
|
91 |
|
'handler' => $handlerStack, |
|
274
|
|
|
'headers' => [ 'User-Agent' => 'WMDE Fundraising Frontend' ], |
|
275
|
|
|
] ); |
|
276
|
|
|
|
|
277
|
91 |
|
return $this->addProfilingDecorator( $guzzle, 'Guzzle Client' ); |
|
278
|
|
|
}; |
|
279
|
|
|
|
|
280
|
|
|
$pimple['translator'] = function() { |
|
281
|
103 |
|
$translationFactory = new TranslationFactory(); |
|
282
|
|
|
$loaders = [ |
|
283
|
103 |
|
'json' => $translationFactory->newJsonLoader() |
|
284
|
|
|
]; |
|
285
|
103 |
|
$locale = $this->config['locale']; |
|
286
|
103 |
|
$translator = $translationFactory->create( $loaders, $locale ); |
|
287
|
103 |
|
$translator->addResource( |
|
288
|
103 |
|
'json', |
|
289
|
103 |
|
__DIR__ . '/../../app/translations/messages.' . $locale . '.json', |
|
290
|
|
|
$locale |
|
291
|
|
|
); |
|
292
|
|
|
|
|
293
|
103 |
|
$translator->addResource( |
|
294
|
103 |
|
'json', |
|
295
|
103 |
|
__DIR__ . '/../../app/translations/paymentTypes.' . $locale . '.json', |
|
296
|
|
|
$locale, |
|
297
|
103 |
|
'paymentTypes' |
|
298
|
|
|
); |
|
299
|
|
|
|
|
300
|
103 |
|
$translator->addResource( |
|
301
|
103 |
|
'json', |
|
302
|
103 |
|
__DIR__ . '/../../app/translations/paymentIntervals.' . $locale . '.json', |
|
303
|
|
|
$locale, |
|
304
|
103 |
|
'paymentIntervals' |
|
305
|
|
|
); |
|
306
|
|
|
|
|
307
|
103 |
|
$translator->addResource( |
|
308
|
103 |
|
'json', |
|
309
|
103 |
|
__DIR__ . '/../../app/translations/donationStatus.' . $locale . '.json', |
|
310
|
|
|
$locale, |
|
311
|
103 |
|
'donationStatus' |
|
312
|
|
|
); |
|
313
|
|
|
|
|
314
|
103 |
|
$translator->addResource( |
|
315
|
103 |
|
'json', |
|
316
|
103 |
|
__DIR__ . '/../../app/translations/validations.' . $locale . '.json', |
|
317
|
|
|
$locale, |
|
318
|
103 |
|
'validations' |
|
319
|
|
|
); |
|
320
|
|
|
|
|
321
|
103 |
|
return $translator; |
|
322
|
|
|
}; |
|
323
|
|
|
|
|
324
|
|
|
// In the future, this could be locale-specific or filled from a DB table |
|
325
|
|
|
$pimple['honorifics'] = function() { |
|
326
|
74 |
|
return new Honorifics( [ |
|
327
|
74 |
|
'' => 'Kein Titel', |
|
328
|
|
|
'Dr.' => 'Dr.', |
|
329
|
|
|
'Prof.' => 'Prof.', |
|
330
|
|
|
'Prof. Dr.' => 'Prof. Dr.' |
|
331
|
|
|
] ); |
|
332
|
|
|
}; |
|
333
|
|
|
|
|
334
|
|
|
$pimple['twig_factory'] = function () { |
|
335
|
|
|
// TODO: like this we end up with two Twig instance, one created here and on in the framework |
|
336
|
98 |
|
return new TwigFactory( $this->config['twig'], $this->getCachePath() . '/twig' ); |
|
337
|
|
|
}; |
|
338
|
|
|
|
|
339
|
|
|
$pimple['twig'] = function() { |
|
340
|
98 |
|
$twigFactory = $this->getTwigFactory(); |
|
341
|
98 |
|
$loaders = array_filter( [ |
|
342
|
98 |
|
$twigFactory->newFileSystemLoader(), |
|
343
|
98 |
|
$twigFactory->newArrayLoader(), // This is just a fallback for testing |
|
344
|
98 |
|
$twigFactory->newWikiPageLoader( |
|
345
|
98 |
|
$this->newRawWikiPageRetriever(), |
|
346
|
98 |
|
$this->newRenderedWikiPageRetriever() |
|
347
|
|
|
), |
|
348
|
|
|
] ); |
|
349
|
|
|
$extensions = [ |
|
350
|
98 |
|
$twigFactory->newTranslationExtension( $this->getTranslator() ), |
|
351
|
98 |
|
new Twig_Extensions_Extension_Intl() |
|
352
|
|
|
]; |
|
353
|
|
|
$filters = [ |
|
354
|
98 |
|
$twigFactory->newFilePrefixFilter( |
|
355
|
98 |
|
$this->newFilePrefixer() |
|
356
|
|
|
) |
|
357
|
|
|
]; |
|
358
|
|
|
|
|
359
|
98 |
|
return $twigFactory->create( $loaders, $extensions, $filters ); |
|
360
|
|
|
}; |
|
361
|
|
|
|
|
362
|
|
|
$pimple['messenger'] = function() { |
|
363
|
6 |
|
return new Messenger( |
|
364
|
6 |
|
new Swift_MailTransport(), |
|
365
|
6 |
|
$this->getOperatorAddress(), |
|
366
|
6 |
|
$this->config['operator-displayname'] |
|
367
|
|
|
); |
|
368
|
|
|
}; |
|
369
|
|
|
|
|
370
|
|
|
$pimple['confirmation-page-selector'] = function() { |
|
371
|
6 |
|
return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] ); |
|
372
|
|
|
}; |
|
373
|
|
|
|
|
374
|
|
|
// TODO split verifiers for donation and membership |
|
375
|
|
|
$pimple['paypal-payment-notification-verifier'] = function() { |
|
376
|
|
|
return new LoggingPaymentNotificationVerifier( |
|
377
|
|
|
new PayPalPaymentNotificationVerifier( |
|
378
|
|
|
new Client(), |
|
379
|
|
|
$this->config['paypal-donation'] |
|
380
|
|
|
), |
|
381
|
|
|
$this->getLogger() |
|
382
|
|
|
); |
|
383
|
|
|
}; |
|
384
|
|
|
|
|
385
|
|
|
$pimple['credit-card-api-service'] = function() { |
|
386
|
|
|
return new McpCreditCardService( |
|
387
|
|
|
new TNvpServiceDispatcher( |
|
388
|
|
|
'IMcpCreditcardService_v1_5', |
|
389
|
|
|
'https://sipg.micropayment.de/public/creditcard/v1.5/nvp/' |
|
390
|
|
|
), |
|
391
|
|
|
$this->config['creditcard']['access-key'], |
|
392
|
|
|
$this->config['creditcard']['testmode'] |
|
393
|
|
|
); |
|
394
|
|
|
}; |
|
395
|
|
|
|
|
396
|
|
|
$pimple['token_generator'] = function() { |
|
397
|
59 |
|
return new RandomTokenGenerator( |
|
398
|
59 |
|
$this->config['token-length'], |
|
399
|
59 |
|
new \DateInterval( $this->config['token-validity-timestamp'] ) |
|
400
|
|
|
); |
|
401
|
|
|
}; |
|
402
|
|
|
|
|
403
|
|
|
$pimple['page_cache'] = function() { |
|
404
|
101 |
|
return new VoidCache(); |
|
405
|
|
|
}; |
|
406
|
|
|
|
|
407
|
|
|
$pimple['rendered_page_cache'] = function() { |
|
408
|
98 |
|
return new VoidCache(); |
|
409
|
|
|
}; |
|
410
|
|
|
|
|
411
|
150 |
|
return $pimple; |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
150 |
|
public function getConnection(): Connection { |
|
415
|
150 |
|
return $this->pimple['dbal_connection']; |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
80 |
|
public function getEntityManager(): EntityManager { |
|
419
|
80 |
|
return $this->pimple['entity_manager']; |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
8 |
|
private function newDonationEventLogger(): DonationEventLogger { |
|
423
|
8 |
|
return new BestEffortDonationEventLogger( |
|
424
|
8 |
|
new DoctrineDonationEventLogger( $this->getEntityManager() ), |
|
425
|
8 |
|
$this->getLogger() |
|
426
|
|
|
); |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
150 |
|
public function newInstaller(): Installer { |
|
430
|
150 |
|
return ( new StoreFactory( $this->getConnection() ) )->newInstaller(); |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
12 |
|
public function newListCommentsUseCase(): ListCommentsUseCase { |
|
434
|
12 |
|
return new ListCommentsUseCase( $this->getCommentFinder() ); |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
6 |
|
public function newCommentListJsonPresenter(): CommentListJsonPresenter { |
|
438
|
6 |
|
return new CommentListJsonPresenter(); |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
2 |
|
public function newCommentListRssPresenter(): CommentListRssPresenter { |
|
442
|
2 |
|
return new CommentListRssPresenter( new TwigTemplate( |
|
443
|
2 |
|
$this->getTwig(), |
|
444
|
2 |
|
'CommentList.rss.twig' |
|
445
|
|
|
) ); |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
4 |
|
public function newCommentListHtmlPresenter(): CommentListHtmlPresenter { |
|
449
|
4 |
|
return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'CommentList.html.twig', [ 'piwikGoals' => [ 1 ] ] ) ); |
|
450
|
|
|
} |
|
451
|
|
|
|
|
452
|
12 |
|
private function getCommentFinder(): CommentFinder { |
|
453
|
12 |
|
return $this->pimple['comment_repository']; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
9 |
|
public function getSubscriptionRepository(): SubscriptionRepository { |
|
457
|
9 |
|
return $this->pimple['subscription_repository']; |
|
458
|
|
|
} |
|
459
|
|
|
|
|
460
|
1 |
|
public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ) { |
|
461
|
1 |
|
$this->pimple['subscription_repository'] = $subscriptionRepository; |
|
462
|
1 |
|
} |
|
463
|
|
|
|
|
464
|
6 |
|
private function getSubscriptionValidator(): SubscriptionValidator { |
|
465
|
6 |
|
return $this->pimple['subscription_validator']; |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
39 |
|
public function getEmailValidator(): EmailValidator { |
|
469
|
39 |
|
return $this->pimple['mail_validator']; |
|
470
|
|
|
} |
|
471
|
|
|
|
|
472
|
8 |
|
public function getTemplateNameValidator(): TemplateNameValidator { |
|
473
|
8 |
|
return $this->pimple['template_name_validator']; |
|
474
|
|
|
} |
|
475
|
|
|
|
|
476
|
1 |
|
public function newAddSubscriptionHTMLPresenter(): AddSubscriptionHtmlPresenter { |
|
477
|
1 |
|
return new AddSubscriptionHtmlPresenter( $this->getIncludeTemplate( 'Subscription_Form.twig' ), $this->getTranslator() ); |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
3 |
|
public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter { |
|
481
|
3 |
|
return new ConfirmSubscriptionHtmlPresenter( |
|
482
|
3 |
|
$this->getLayoutTemplate( 'ConfirmSubscription.html.twig' ), |
|
483
|
3 |
|
$this->getTranslator() |
|
484
|
|
|
); |
|
485
|
|
|
} |
|
486
|
|
|
|
|
487
|
2 |
|
public function newAddSubscriptionJSONPresenter(): AddSubscriptionJsonPresenter { |
|
488
|
2 |
|
return new AddSubscriptionJsonPresenter( $this->getTranslator() ); |
|
489
|
|
|
} |
|
490
|
|
|
|
|
491
|
1 |
|
public function newGetInTouchHTMLPresenter(): GetInTouchHtmlPresenter { |
|
492
|
1 |
|
return new GetInTouchHtmlPresenter( $this->getIncludeTemplate( 'Kontaktformular.twig' ), $this->getTranslator() ); |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
98 |
|
public function getTwig(): Twig_Environment { |
|
496
|
98 |
|
return $this->pimple['twig']; |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
/** |
|
500
|
|
|
* Get a template, with the content for the layout areas filled in. |
|
501
|
|
|
* |
|
502
|
|
|
* @param string $templateName |
|
503
|
|
|
* @param array $context Additional variables for the template |
|
504
|
|
|
* @return TwigTemplate |
|
505
|
|
|
*/ |
|
506
|
35 |
|
public function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
507
|
35 |
|
return new TwigTemplate( |
|
508
|
35 |
|
$this->getTwig(), |
|
509
|
|
|
$templateName, |
|
510
|
35 |
|
array_merge( $this->getDefaultTwigVariables(), $context ) |
|
511
|
|
|
); |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
/** |
|
515
|
|
|
* Get a layouted template that includes another template |
|
516
|
|
|
* |
|
517
|
|
|
* @param string $templateName Template to include |
|
518
|
|
|
* @return TwigTemplate |
|
519
|
|
|
*/ |
|
520
|
35 |
|
private function getIncludeTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
521
|
35 |
|
return new TwigTemplate( |
|
522
|
35 |
|
$this->getTwig(), |
|
523
|
35 |
|
'IncludeInLayout.twig', |
|
524
|
|
|
array_merge( |
|
525
|
35 |
|
$this->getDefaultTwigVariables(), |
|
526
|
35 |
|
[ 'main_template' => $templateName ], |
|
527
|
|
|
$context |
|
528
|
|
|
) |
|
529
|
|
|
); |
|
530
|
|
|
} |
|
531
|
|
|
|
|
532
|
69 |
|
private function getDefaultTwigVariables() { |
|
533
|
|
|
return [ |
|
534
|
69 |
|
'basepath' => $this->config['web-basepath'], |
|
535
|
69 |
|
'honorifics' => $this->getHonorifics()->getList(), |
|
536
|
69 |
|
'header_template' => $this->config['default-layout-templates']['header'], |
|
537
|
69 |
|
'footer_template' => $this->config['default-layout-templates']['footer'], |
|
538
|
69 |
|
'no_js_notice_template' => $this->config['default-layout-templates']['no-js-notice'], |
|
539
|
69 |
|
'piwik' => $this->config['piwik'], |
|
540
|
|
|
]; |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
15 |
|
private function newReferrerGeneralizer() { |
|
544
|
15 |
|
return new ReferrerGeneralizer( |
|
545
|
15 |
|
$this->config['referrer-generalization']['default'], |
|
546
|
15 |
|
$this->config['referrer-generalization']['domain-map'] |
|
547
|
|
|
); |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
101 |
|
private function getMediaWikiApi(): MediawikiApi { |
|
551
|
101 |
|
return $this->pimple['mw_api']; |
|
552
|
|
|
} |
|
553
|
|
|
|
|
554
|
10 |
|
public function setMediaWikiApi( MediawikiApi $api ) { |
|
555
|
10 |
|
$this->pimple['mw_api'] = $api; |
|
556
|
10 |
|
} |
|
557
|
|
|
|
|
558
|
91 |
|
private function getGuzzleClient(): ClientInterface { |
|
559
|
91 |
|
return $this->pimple['guzzle_client']; |
|
560
|
|
|
} |
|
561
|
|
|
|
|
562
|
101 |
|
private function newRawWikiPageRetriever(): PageRetriever { |
|
563
|
101 |
|
$pageRetriever = new CachingPageRetriever( |
|
564
|
101 |
|
$this->newApiRawPageRetriever(), |
|
565
|
101 |
|
$this->getPageCache() |
|
566
|
|
|
); |
|
567
|
|
|
|
|
568
|
101 |
|
return $this->addProfilingDecorator( $pageRetriever, 'PageRetriever' ); |
|
569
|
|
|
} |
|
570
|
|
|
|
|
571
|
98 |
|
private function newRenderedWikiPageRetriever(): PageRetriever { |
|
572
|
98 |
|
$pageRetriever = new CachingPageRetriever( |
|
573
|
98 |
|
$this->newApiRenderedPageRetriever(), |
|
574
|
98 |
|
$this->getRenderedPageCache() |
|
575
|
|
|
); |
|
576
|
|
|
|
|
577
|
98 |
|
return $this->addProfilingDecorator( $pageRetriever, 'PageRetriever' ); |
|
578
|
|
|
} |
|
579
|
|
|
|
|
580
|
101 |
|
private function newApiRawPageRetriever(): PageRetriever { |
|
581
|
101 |
|
return new ApiBasedPageRetriever( |
|
582
|
101 |
|
$this->getMediaWikiApi(), |
|
583
|
101 |
|
new ApiUser( $this->config['cms-wiki-user'], $this->config['cms-wiki-password'] ), |
|
584
|
101 |
|
$this->getLogger(), |
|
585
|
101 |
|
$this->config['cms-wiki-title-prefix'], |
|
586
|
101 |
|
ApiBasedPageRetriever::MODE_RAW |
|
587
|
|
|
); |
|
588
|
|
|
} |
|
589
|
|
|
|
|
590
|
98 |
|
private function newApiRenderedPageRetriever(): PageRetriever { |
|
591
|
98 |
|
return new ApiBasedPageRetriever( |
|
592
|
98 |
|
$this->getMediaWikiApi(), |
|
593
|
98 |
|
new ApiUser( $this->config['cms-wiki-user'], $this->config['cms-wiki-password'] ), |
|
594
|
98 |
|
$this->getLogger(), |
|
595
|
98 |
|
$this->config['cms-wiki-title-prefix'], |
|
596
|
98 |
|
ApiBasedPageRetriever::MODE_RENDERED |
|
597
|
|
|
); |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
113 |
|
public function getLogger(): LoggerInterface { |
|
601
|
113 |
|
return $this->pimple['logger']; |
|
602
|
|
|
} |
|
603
|
|
|
|
|
604
|
98 |
|
private function getVarPath(): string { |
|
605
|
98 |
|
return __DIR__ . '/../../var'; |
|
606
|
|
|
} |
|
607
|
|
|
|
|
608
|
98 |
|
public function getCachePath(): string { |
|
609
|
98 |
|
return $this->getVarPath() . '/cache'; |
|
610
|
|
|
} |
|
611
|
|
|
|
|
612
|
|
|
public function getLoggingPath(): string { |
|
613
|
|
|
return $this->getVarPath() . '/log'; |
|
614
|
|
|
} |
|
615
|
|
|
|
|
616
|
|
|
public function getTemplatePath(): string { |
|
617
|
|
|
return __DIR__ . '/../../app/templates'; |
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
6 |
|
public function newAddSubscriptionUseCase(): AddSubscriptionUseCase { |
|
621
|
6 |
|
return new AddSubscriptionUseCase( |
|
622
|
6 |
|
$this->getSubscriptionRepository(), |
|
623
|
6 |
|
$this->getSubscriptionValidator(), |
|
624
|
6 |
|
$this->newAddSubscriptionMailer() |
|
625
|
|
|
); |
|
626
|
|
|
} |
|
627
|
|
|
|
|
628
|
3 |
|
public function newConfirmSubscriptionUseCase(): ConfirmSubscriptionUseCase { |
|
629
|
3 |
|
return new ConfirmSubscriptionUseCase( |
|
630
|
3 |
|
$this->getSubscriptionRepository(), |
|
631
|
3 |
|
$this->newConfirmSubscriptionMailer() |
|
632
|
|
|
); |
|
633
|
|
|
} |
|
634
|
|
|
|
|
635
|
6 |
|
private function newAddSubscriptionMailer(): TemplateBasedMailer { |
|
636
|
6 |
|
return $this->newTemplateMailer( |
|
637
|
6 |
|
new TwigTemplate( |
|
638
|
6 |
|
$this->getTwig(), |
|
639
|
6 |
|
'Mail_Subscription_Request.twig', |
|
640
|
|
|
[ |
|
641
|
6 |
|
'basepath' => $this->config['web-basepath'], |
|
642
|
6 |
|
'greeting_generator' => $this->getGreetingGenerator() |
|
643
|
|
|
] |
|
644
|
|
|
), |
|
645
|
6 |
|
'mail_subject_membership' |
|
646
|
|
|
); |
|
647
|
|
|
} |
|
648
|
|
|
|
|
649
|
3 |
|
private function newConfirmSubscriptionMailer(): TemplateBasedMailer { |
|
650
|
3 |
|
return $this->newTemplateMailer( |
|
651
|
3 |
|
new TwigTemplate( |
|
652
|
3 |
|
$this->getTwig(), |
|
653
|
3 |
|
'Mail_Subscription_Confirmation.twig', |
|
654
|
3 |
|
[ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
655
|
|
|
), |
|
656
|
3 |
|
'mail_subject_membership' |
|
657
|
|
|
); |
|
658
|
|
|
} |
|
659
|
|
|
|
|
660
|
49 |
|
private function newTemplateMailer( TwigTemplate $template, string $messageKey ): TemplateBasedMailer { |
|
661
|
49 |
|
$mailer = new TemplateBasedMailer( |
|
662
|
49 |
|
$this->getMessenger(), |
|
663
|
|
|
$template, |
|
664
|
49 |
|
$this->getTranslator()->trans( $messageKey ) |
|
665
|
|
|
); |
|
666
|
|
|
|
|
667
|
49 |
|
$mailer = new LoggingMailer( $mailer, $this->getLogger() ); |
|
668
|
|
|
|
|
669
|
49 |
|
return $this->addProfilingDecorator( $mailer, 'Mailer' ); |
|
670
|
|
|
} |
|
671
|
|
|
|
|
672
|
46 |
|
public function getGreetingGenerator() { |
|
673
|
46 |
|
return $this->pimple['greeting_generator']; |
|
674
|
|
|
} |
|
675
|
|
|
|
|
676
|
|
|
public function newCheckIbanUseCase(): CheckIbanUseCase { |
|
677
|
|
|
return new CheckIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() ); |
|
678
|
|
|
} |
|
679
|
|
|
|
|
680
|
|
|
public function newGenerateIbanUseCase(): GenerateIbanUseCase { |
|
681
|
|
|
return new GenerateIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() ); |
|
682
|
|
|
} |
|
683
|
|
|
|
|
684
|
|
|
public function newIbanPresenter(): IbanPresenter { |
|
685
|
|
|
return new IbanPresenter(); |
|
686
|
|
|
} |
|
687
|
|
|
|
|
688
|
25 |
|
public function newBankDataConverter() { |
|
689
|
25 |
|
return new BankDataConverter( $this->config['bank-data-file'] ); |
|
690
|
|
|
} |
|
691
|
|
|
|
|
692
|
|
|
public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ) { |
|
693
|
|
|
$this->pimple['subscription_validator'] = $subscriptionValidator; |
|
694
|
|
|
} |
|
695
|
|
|
|
|
696
|
|
|
public function setPageTitlePrefix( string $prefix ) { |
|
697
|
|
|
$this->config['cms-wiki-title-prefix'] = $prefix; |
|
698
|
|
|
} |
|
699
|
|
|
|
|
700
|
3 |
|
public function newGetInTouchUseCase() { |
|
701
|
3 |
|
return new GetInTouchUseCase( |
|
702
|
3 |
|
$this->getContactValidator(), |
|
703
|
3 |
|
$this->newContactOperatorMailer(), |
|
704
|
3 |
|
$this->newContactUserMailer() |
|
705
|
|
|
); |
|
706
|
|
|
} |
|
707
|
|
|
|
|
708
|
3 |
|
private function newContactUserMailer(): TemplateBasedMailer { |
|
709
|
3 |
|
return $this->newTemplateMailer( |
|
710
|
3 |
|
new TwigTemplate( $this->getTwig(), 'KontaktMailExtern.twig' ), |
|
711
|
3 |
|
'mail_subject_getintouch' |
|
712
|
|
|
); |
|
713
|
|
|
} |
|
714
|
|
|
|
|
715
|
3 |
|
private function newContactOperatorMailer(): OperatorMailer { |
|
716
|
3 |
|
return new OperatorMailer( |
|
717
|
3 |
|
$this->getMessenger(), |
|
718
|
3 |
|
new TwigTemplate( $this->getTwig(), 'KontaktMailIntern.twig' ), |
|
719
|
3 |
|
$this->getTranslator()->trans( 'mail_subject_getintouch_forward' ) |
|
720
|
|
|
); |
|
721
|
|
|
} |
|
722
|
|
|
|
|
723
|
3 |
|
private function getContactValidator(): GetInTouchValidator { |
|
724
|
3 |
|
return $this->pimple['contact_validator']; |
|
725
|
|
|
} |
|
726
|
|
|
|
|
727
|
6 |
|
private function newSubscriptionDuplicateValidator(): SubscriptionDuplicateValidator { |
|
728
|
6 |
|
return new SubscriptionDuplicateValidator( |
|
729
|
6 |
|
$this->getSubscriptionRepository(), |
|
730
|
6 |
|
$this->newSubscriptionDuplicateCutoffDate() |
|
731
|
|
|
); |
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
6 |
|
private function newSubscriptionDuplicateCutoffDate(): \DateTime { |
|
735
|
6 |
|
$cutoffDateTime = new \DateTime(); |
|
736
|
6 |
|
$cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) ); |
|
737
|
6 |
|
return $cutoffDateTime; |
|
738
|
|
|
} |
|
739
|
|
|
|
|
740
|
6 |
|
private function newHonorificValidator(): AllowedValuesValidator { |
|
741
|
6 |
|
return new AllowedValuesValidator( $this->getHonorifics()->getKeys() ); |
|
742
|
|
|
} |
|
743
|
|
|
|
|
744
|
74 |
|
private function getHonorifics(): Honorifics { |
|
745
|
74 |
|
return $this->pimple['honorifics']; |
|
746
|
|
|
} |
|
747
|
|
|
|
|
748
|
1 |
|
public function newAuthorizedCachePurger(): AuthorizedCachePurger { |
|
749
|
1 |
|
return new AuthorizedCachePurger( |
|
750
|
1 |
|
new AllOfTheCachePurger( $this->getTwig(), $this->getPageCache() ), |
|
751
|
1 |
|
$this->config['purging-secret'] |
|
752
|
|
|
); |
|
753
|
|
|
} |
|
754
|
|
|
|
|
755
|
25 |
|
private function newBankDataValidator(): BankDataValidator { |
|
756
|
25 |
|
return new BankDataValidator( $this->newIbanValidator() ); |
|
757
|
|
|
} |
|
758
|
|
|
|
|
759
|
49 |
|
private function getMessenger(): Messenger { |
|
760
|
49 |
|
return $this->pimple['messenger']; |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
46 |
|
public function setMessenger( Messenger $messenger ) { |
|
764
|
46 |
|
$this->pimple['messenger'] = $messenger; |
|
765
|
46 |
|
} |
|
766
|
|
|
|
|
767
|
45 |
|
public function setNullMessenger() { |
|
768
|
45 |
|
$this->setMessenger( new Messenger( |
|
769
|
45 |
|
Swift_NullTransport::newInstance(), |
|
770
|
45 |
|
$this->getOperatorAddress() |
|
771
|
|
|
) ); |
|
772
|
45 |
|
} |
|
773
|
|
|
|
|
774
|
51 |
|
public function getOperatorAddress() { |
|
775
|
51 |
|
return new EmailAddress( $this->config['operator-email'] ); |
|
776
|
|
|
} |
|
777
|
|
|
|
|
778
|
9 |
|
public function newInternalErrorHTMLPresenter(): InternalErrorHtmlPresenter { |
|
779
|
9 |
|
return new InternalErrorHtmlPresenter( $this->getIncludeTemplate( 'ErrorPage.twig' ) ); |
|
780
|
|
|
} |
|
781
|
|
|
|
|
782
|
3 |
|
public function newAccessDeniedHTMLPresenter(): InternalErrorHtmlPresenter { |
|
783
|
3 |
|
return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'AccessDenied.twig' ) ); |
|
784
|
|
|
} |
|
785
|
|
|
|
|
786
|
105 |
|
public function getTranslator(): TranslatorInterface { |
|
787
|
105 |
|
return $this->pimple['translator']; |
|
788
|
|
|
} |
|
789
|
|
|
|
|
790
|
2 |
|
public function setTranslator( TranslatorInterface $translator ) { |
|
791
|
2 |
|
$this->pimple['translator'] = $translator; |
|
792
|
2 |
|
} |
|
793
|
|
|
|
|
794
|
98 |
|
private function getTwigFactory(): TwigFactory { |
|
795
|
98 |
|
return $this->pimple['twig_factory']; |
|
796
|
|
|
} |
|
797
|
|
|
|
|
798
|
24 |
|
private function newTextPolicyValidator( string $policyName ): TextPolicyValidator { |
|
799
|
24 |
|
$contentProvider = $this->newRawWikiPageRetriever(); |
|
800
|
24 |
|
$textPolicyConfig = $this->config['text-policies'][$policyName]; |
|
801
|
|
|
|
|
802
|
24 |
|
return new TextPolicyValidator( |
|
803
|
24 |
|
new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['badwords'] ?? '' ), |
|
804
|
24 |
|
new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['whitewords'] ?? '' ) |
|
805
|
|
|
); |
|
806
|
|
|
} |
|
807
|
|
|
|
|
808
|
3 |
|
private function newCommentPolicyValidator(): TextPolicyValidator { |
|
809
|
3 |
|
return $this->newTextPolicyValidator( 'comment' ); |
|
810
|
|
|
} |
|
811
|
|
|
|
|
812
|
5 |
|
public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase { |
|
813
|
5 |
|
return new CancelDonationUseCase( |
|
814
|
5 |
|
$this->getDonationRepository(), |
|
815
|
5 |
|
$this->newCancelDonationMailer(), |
|
816
|
5 |
|
$this->newDonationAuthorizer( $updateToken ), |
|
817
|
5 |
|
$this->newDonationEventLogger() |
|
818
|
|
|
); |
|
819
|
|
|
} |
|
820
|
|
|
|
|
821
|
5 |
|
private function newCancelDonationMailer(): TemplateBasedMailer { |
|
822
|
5 |
|
return $this->newTemplateMailer( |
|
823
|
5 |
|
new TwigTemplate( |
|
824
|
5 |
|
$this->getTwig(), |
|
825
|
5 |
|
'Mail_Donation_Cancellation_Confirmation.twig', |
|
826
|
5 |
|
[ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
827
|
|
|
), |
|
828
|
5 |
|
'mail_subject_confirm_cancellation' |
|
829
|
|
|
); |
|
830
|
|
|
} |
|
831
|
|
|
|
|
832
|
15 |
|
public function newAddDonationUseCase(): AddDonationUseCase { |
|
833
|
15 |
|
return new AddDonationUseCase( |
|
834
|
15 |
|
$this->getDonationRepository(), |
|
835
|
15 |
|
$this->newDonationValidator(), |
|
836
|
15 |
|
$this->newDonationPolicyValidator(), |
|
837
|
15 |
|
$this->newReferrerGeneralizer(), |
|
838
|
15 |
|
$this->newDonationConfirmationMailer(), |
|
839
|
15 |
|
$this->newBankTransferCodeGenerator(), |
|
840
|
15 |
|
$this->newDonationTokenFetcher() |
|
841
|
|
|
); |
|
842
|
|
|
} |
|
843
|
|
|
|
|
844
|
15 |
|
private function newBankTransferCodeGenerator(): TransferCodeGenerator { |
|
845
|
15 |
|
return new UniqueTransferCodeGenerator( |
|
846
|
15 |
|
new SimpleTransferCodeGenerator(), |
|
847
|
15 |
|
$this->getEntityManager() |
|
848
|
|
|
); |
|
849
|
|
|
} |
|
850
|
|
|
|
|
851
|
15 |
|
private function newDonationValidator(): AddDonationValidator { |
|
852
|
15 |
|
return new AddDonationValidator( |
|
853
|
15 |
|
$this->newPaymentDataValidator(), |
|
854
|
15 |
|
$this->newBankDataValidator(), |
|
855
|
15 |
|
$this->getEmailValidator() |
|
856
|
|
|
); |
|
857
|
|
|
} |
|
858
|
|
|
|
|
859
|
2 |
|
public function newPersonalInfoValidator(): DonorValidator { |
|
860
|
2 |
|
return new DonorValidator( |
|
861
|
2 |
|
new DonorNameValidator(), |
|
862
|
2 |
|
new DonorAddressValidator(), |
|
863
|
2 |
|
$this->getEmailValidator() |
|
864
|
|
|
); |
|
865
|
|
|
} |
|
866
|
|
|
|
|
867
|
20 |
|
private function newDonationConfirmationMailer(): DonationConfirmationMailer { |
|
868
|
20 |
|
return new DonationConfirmationMailer( |
|
869
|
20 |
|
$this->newTemplateMailer( |
|
870
|
20 |
|
new TwigTemplate( |
|
871
|
20 |
|
$this->getTwig(), |
|
872
|
20 |
|
'Mail_Donation_Confirmation.twig', // TODO: ongoing unification of different templates |
|
873
|
|
|
[ |
|
874
|
20 |
|
'basepath' => $this->config['web-basepath'], |
|
875
|
20 |
|
'greeting_generator' => $this->getGreetingGenerator() |
|
876
|
|
|
] |
|
877
|
|
|
), |
|
878
|
20 |
|
'mail_subject_confirm_donation' |
|
879
|
|
|
) |
|
880
|
|
|
); |
|
881
|
|
|
} |
|
882
|
|
|
|
|
883
|
1 |
|
public function newPayPalUrlGeneratorForDonations() { |
|
884
|
1 |
|
return new PayPalUrlGenerator( $this->getPayPalUrlConfigForDonations() ); |
|
885
|
|
|
} |
|
886
|
|
|
|
|
887
|
2 |
|
public function newPayPalUrlGeneratorForMembershipApplications() { |
|
888
|
2 |
|
return new PayPalUrlGenerator( $this->getPayPalUrlConfigForMembershipApplications() ); |
|
889
|
|
|
} |
|
890
|
|
|
|
|
891
|
1 |
|
private function getPayPalUrlConfigForDonations() { |
|
892
|
1 |
|
return PayPalUrlConfig::newFromConfig( $this->config['paypal-donation'] ); |
|
893
|
|
|
} |
|
894
|
|
|
|
|
895
|
2 |
|
private function getPayPalUrlConfigForMembershipApplications() { |
|
896
|
2 |
|
return PayPalUrlConfig::newFromConfig( $this->config['paypal-membership'] ); |
|
897
|
|
|
} |
|
898
|
|
|
|
|
899
|
2 |
|
private function newCreditCardUrlGenerator() { |
|
900
|
2 |
|
return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() ); |
|
901
|
|
|
} |
|
902
|
|
|
|
|
903
|
2 |
|
private function newCreditCardUrlConfig() { |
|
904
|
2 |
|
return CreditCardUrlConfig::newFromConfig( $this->config['creditcard'] ); |
|
905
|
|
|
} |
|
906
|
|
|
|
|
907
|
39 |
|
public function getDonationRepository(): DonationRepository { |
|
908
|
39 |
|
return $this->pimple['donation_repository']; |
|
909
|
|
|
} |
|
910
|
|
|
|
|
911
|
30 |
|
public function newPaymentDataValidator(): PaymentDataValidator { |
|
912
|
30 |
|
return new PaymentDataValidator( $this->config['donation-minimum-amount'], $this->config['donation-maximum-amount'] ); |
|
913
|
|
|
} |
|
914
|
|
|
|
|
915
|
17 |
|
private function newAmountFormatter(): AmountFormatter { |
|
916
|
17 |
|
return new AmountFormatter( $this->config['locale'] ); |
|
917
|
|
|
} |
|
918
|
|
|
|
|
919
|
2 |
|
public function newDecimalNumberFormatter(): NumberFormatter { |
|
920
|
2 |
|
return new NumberFormatter( $this->config['locale'], NumberFormatter::DECIMAL ); |
|
921
|
|
|
} |
|
922
|
|
|
|
|
923
|
3 |
|
public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase { |
|
924
|
3 |
|
return new AddCommentUseCase( |
|
925
|
3 |
|
$this->getDonationRepository(), |
|
926
|
3 |
|
$this->newDonationAuthorizer( $updateToken ), |
|
927
|
3 |
|
$this->newCommentPolicyValidator(), |
|
928
|
3 |
|
$this->newAddCommentValidator() |
|
929
|
|
|
); |
|
930
|
|
|
} |
|
931
|
|
|
|
|
932
|
26 |
|
private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer { |
|
933
|
26 |
|
return new DoctrineDonationAuthorizer( |
|
934
|
26 |
|
$this->getEntityManager(), |
|
935
|
|
|
$updateToken, |
|
936
|
|
|
$accessToken |
|
937
|
|
|
); |
|
938
|
|
|
} |
|
939
|
|
|
|
|
940
|
80 |
|
public function getTokenGenerator(): TokenGenerator { |
|
941
|
80 |
|
return $this->pimple['token_generator']; |
|
942
|
|
|
} |
|
943
|
|
|
|
|
944
|
10 |
|
public function newDonationConfirmationPresenter() { |
|
945
|
10 |
|
return new DonationConfirmationHtmlPresenter( |
|
946
|
10 |
|
$this->getIncludeTemplate( 'DonationConfirmation.twig', [ 'piwikGoals' => [ 3 ] ] ) |
|
947
|
|
|
); |
|
948
|
|
|
} |
|
949
|
|
|
|
|
950
|
2 |
|
public function newCreditCardPaymentHtmlPresenter() { |
|
951
|
2 |
|
return new CreditCardPaymentHtmlPresenter( |
|
952
|
2 |
|
$this->getIncludeTemplate( 'CreditCardPaymentIframe.twig' ), |
|
953
|
2 |
|
$this->getTranslator(), |
|
954
|
2 |
|
$this->newCreditCardUrlGenerator() |
|
955
|
|
|
); |
|
956
|
|
|
} |
|
957
|
|
|
|
|
958
|
5 |
|
public function newCancelDonationHtmlPresenter() { |
|
959
|
5 |
|
return new CancelDonationHtmlPresenter( |
|
960
|
5 |
|
$this->getIncludeTemplate( 'Donation_Cancellation_Confirmation.twig' ) |
|
961
|
|
|
); |
|
962
|
|
|
} |
|
963
|
|
|
|
|
964
|
10 |
|
public function newApplyForMembershipUseCase(): ApplyForMembershipUseCase { |
|
965
|
10 |
|
return new ApplyForMembershipUseCase( |
|
966
|
10 |
|
$this->getMembershipApplicationRepository(), |
|
967
|
10 |
|
$this->newMembershipApplicationTokenFetcher(), |
|
968
|
10 |
|
$this->newApplyForMembershipMailer(), |
|
969
|
10 |
|
$this->newMembershipApplicationValidator(), |
|
970
|
10 |
|
$this->newMembershipApplicationTracker(), |
|
971
|
10 |
|
$this->newMembershipApplicationPiwikTracker() |
|
972
|
|
|
); |
|
973
|
|
|
} |
|
974
|
|
|
|
|
975
|
10 |
|
private function newApplyForMembershipMailer(): TemplateBasedMailer { |
|
976
|
10 |
|
return $this->newTemplateMailer( |
|
977
|
10 |
|
new TwigTemplate( |
|
978
|
10 |
|
$this->getTwig(), |
|
979
|
10 |
|
'Mail_Membership_Application_Confirmation.twig', |
|
980
|
10 |
|
[ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
981
|
|
|
), |
|
982
|
10 |
|
'mail_subject_confirm_membership_application' |
|
983
|
|
|
); |
|
984
|
|
|
} |
|
985
|
|
|
|
|
986
|
10 |
|
private function newMembershipApplicationValidator(): MembershipApplicationValidator { |
|
987
|
10 |
|
return new MembershipApplicationValidator( |
|
988
|
10 |
|
new MembershipFeeValidator(), |
|
989
|
10 |
|
$this->newBankDataValidator(), |
|
990
|
10 |
|
$this->getEmailValidator() |
|
991
|
|
|
); |
|
992
|
|
|
} |
|
993
|
|
|
|
|
994
|
10 |
|
private function newMembershipApplicationTracker(): ApplicationTracker { |
|
995
|
10 |
|
return new DoctrineApplicationTracker( $this->getEntityManager() ); |
|
996
|
|
|
} |
|
997
|
|
|
|
|
998
|
10 |
|
private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker { |
|
999
|
10 |
|
return new DoctrineApplicationPiwikTracker( $this->getEntityManager() ); |
|
1000
|
|
|
} |
|
1001
|
|
|
|
|
1002
|
2 |
|
public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase { |
|
1003
|
2 |
|
return new CancelMembershipApplicationUseCase( |
|
1004
|
2 |
|
$this->newMembershipApplicationAuthorizer( $updateToken ), |
|
1005
|
2 |
|
$this->getMembershipApplicationRepository(), |
|
1006
|
2 |
|
$this->newCancelMembershipApplicationMailer() |
|
1007
|
|
|
); |
|
1008
|
|
|
} |
|
1009
|
|
|
|
|
1010
|
3 |
|
private function newMembershipApplicationAuthorizer( |
|
1011
|
|
|
string $updateToken = null, string $accessToken = null ): ApplicationAuthorizer { |
|
1012
|
|
|
|
|
1013
|
3 |
|
return new DoctrineApplicationAuthorizer( |
|
1014
|
3 |
|
$this->getEntityManager(), |
|
1015
|
|
|
$updateToken, |
|
1016
|
|
|
$accessToken |
|
1017
|
|
|
); |
|
1018
|
|
|
} |
|
1019
|
|
|
|
|
1020
|
13 |
|
public function getMembershipApplicationRepository(): ApplicationRepository { |
|
1021
|
13 |
|
return $this->pimple['membership_application_repository']; |
|
1022
|
|
|
} |
|
1023
|
|
|
|
|
1024
|
2 |
|
private function newCancelMembershipApplicationMailer(): TemplateBasedMailer { |
|
1025
|
2 |
|
return $this->newTemplateMailer( |
|
1026
|
2 |
|
new TwigTemplate( |
|
1027
|
2 |
|
$this->getTwig(), |
|
1028
|
2 |
|
'Mail_Membership_Application_Cancellation_Confirmation.twig', |
|
1029
|
2 |
|
[ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
1030
|
|
|
), |
|
1031
|
2 |
|
'mail_subject_confirm_membership_application_cancellation' |
|
1032
|
|
|
); |
|
1033
|
|
|
} |
|
1034
|
|
|
|
|
1035
|
1 |
|
public function newMembershipApplicationConfirmationUseCase( string $accessToken ) { |
|
1036
|
1 |
|
return new ShowMembershipApplicationConfirmationUseCase( |
|
1037
|
1 |
|
$this->newMembershipApplicationAuthorizer( null, $accessToken ), $this->getMembershipApplicationRepository(), |
|
1038
|
1 |
|
$this->newMembershipApplicationTokenFetcher() |
|
1039
|
|
|
); |
|
1040
|
|
|
} |
|
1041
|
|
|
|
|
1042
|
13 |
|
public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase { |
|
1043
|
13 |
|
return new ShowDonationConfirmationUseCase( |
|
1044
|
13 |
|
$this->newDonationAuthorizer( null, $accessToken ), |
|
1045
|
13 |
|
$this->newDonationTokenFetcher(), |
|
1046
|
13 |
|
$this->getDonationRepository() |
|
1047
|
|
|
); |
|
1048
|
|
|
} |
|
1049
|
|
|
|
|
1050
|
7 |
|
public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ) { |
|
1051
|
7 |
|
$this->pimple['confirmation-page-selector'] = $selector; |
|
1052
|
7 |
|
} |
|
1053
|
|
|
|
|
1054
|
10 |
|
public function getDonationConfirmationPageSelector() { |
|
1055
|
10 |
|
return $this->pimple['confirmation-page-selector']; |
|
1056
|
|
|
} |
|
1057
|
|
|
|
|
1058
|
3 |
|
public function newDonationFormViolationPresenter() { |
|
1059
|
|
|
// TODO make the template name dependent on the 'form' value from the HTTP POST request |
|
1060
|
|
|
// (we need different form pages for A/B testing) |
|
1061
|
3 |
|
$template = $this->getLayoutTemplate( 'DisplayPageLayout.twig', [ 'main_template' => 'DonationForm.twig' ] ); |
|
1062
|
3 |
|
return new DonationFormViolationPresenter( $template, $this->newAmountFormatter() ); |
|
1063
|
|
|
} |
|
1064
|
|
|
|
|
1065
|
14 |
|
public function newDonationFormPresenter() { |
|
1066
|
|
|
// TODO make the template name dependent on the 'form' value from the HTTP POST request |
|
1067
|
|
|
// (we need different form pages for A/B testing) |
|
1068
|
14 |
|
$template = $this->getLayoutTemplate( 'DisplayPageLayout.twig', [ 'main_template' => 'DonationForm.twig' ] ); |
|
1069
|
14 |
|
return new DonationFormPresenter( $template, $this->newAmountFormatter() ); |
|
1070
|
|
|
} |
|
1071
|
|
|
|
|
1072
|
1 |
|
public function newHandlePayPalPaymentNotificationUseCase( string $updateToken ) { |
|
1073
|
1 |
|
return new HandlePayPalPaymentNotificationUseCase( |
|
1074
|
1 |
|
$this->getDonationRepository(), |
|
1075
|
1 |
|
$this->newDonationAuthorizer( $updateToken ), |
|
1076
|
1 |
|
$this->newDonationConfirmationMailer(), |
|
1077
|
1 |
|
$this->getLogger(), |
|
1078
|
1 |
|
$this->newDonationEventLogger() |
|
1079
|
|
|
); |
|
1080
|
|
|
} |
|
1081
|
|
|
|
|
1082
|
5 |
|
public function getPayPalPaymentNotificationVerifier(): PaymentNotificationVerifier { |
|
1083
|
5 |
|
return $this->pimple['paypal-payment-notification-verifier']; |
|
1084
|
|
|
} |
|
1085
|
|
|
|
|
1086
|
5 |
|
public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ) { |
|
1087
|
5 |
|
$this->pimple['paypal-payment-notification-verifier'] = $verifier; |
|
1088
|
5 |
|
} |
|
1089
|
|
|
|
|
1090
|
2 |
|
public function newCreditCardNotificationUseCase( string $updateToken ) { |
|
1091
|
2 |
|
return new CreditCardNotificationUseCase( |
|
1092
|
2 |
|
$this->getDonationRepository(), |
|
1093
|
2 |
|
$this->newDonationAuthorizer( $updateToken ), |
|
1094
|
2 |
|
$this->getCreditCardService(), |
|
1095
|
2 |
|
$this->newDonationConfirmationMailer(), |
|
1096
|
2 |
|
$this->getLogger(), |
|
1097
|
2 |
|
$this->newDonationEventLogger() |
|
1098
|
|
|
); |
|
1099
|
|
|
} |
|
1100
|
|
|
|
|
1101
|
2 |
|
public function newCancelMembershipApplicationHtmlPresenter() { |
|
1102
|
2 |
|
return new CancelMembershipApplicationHtmlPresenter( |
|
1103
|
2 |
|
$this->getIncludeTemplate( 'Membership_Application_Cancellation_Confirmation.twig' ) |
|
1104
|
|
|
); |
|
1105
|
|
|
} |
|
1106
|
|
|
|
|
1107
|
1 |
|
public function newMembershipApplicationConfirmationHtmlPresenter() { |
|
1108
|
1 |
|
return new MembershipApplicationConfirmationHtmlPresenter( |
|
1109
|
1 |
|
$this->getIncludeTemplate( 'MembershipApplicationConfirmation.twig' ) |
|
1110
|
|
|
); |
|
1111
|
|
|
} |
|
1112
|
|
|
|
|
1113
|
2 |
|
public function newMembershipFormViolationPresenter() { |
|
1114
|
2 |
|
return new MembershipFormViolationPresenter( |
|
1115
|
2 |
|
$this->getIncludeTemplate( 'MembershipApplication.twig' ) |
|
1116
|
|
|
); |
|
1117
|
|
|
} |
|
1118
|
|
|
|
|
1119
|
2 |
|
public function setCreditCardService( CreditCardService $ccService ) { |
|
1120
|
2 |
|
$this->pimple['credit-card-api-service'] = $ccService; |
|
1121
|
2 |
|
} |
|
1122
|
|
|
|
|
1123
|
2 |
|
public function getCreditCardService(): CreditCardService { |
|
1124
|
2 |
|
return $this->pimple['credit-card-api-service']; |
|
1125
|
|
|
} |
|
1126
|
|
|
|
|
1127
|
2 |
|
public function newCreditCardNotificationPresenter(): CreditCardNotificationPresenter { |
|
1128
|
2 |
|
return new CreditCardNotificationPresenter( |
|
1129
|
2 |
|
new TwigTemplate( |
|
1130
|
2 |
|
$this->getTwig(), |
|
1131
|
2 |
|
'CreditCardPaymentNotification.twig', |
|
1132
|
2 |
|
[ 'returnUrl' => $this->config['creditcard']['return-url'] ] |
|
1133
|
|
|
) |
|
1134
|
|
|
); |
|
1135
|
|
|
} |
|
1136
|
|
|
|
|
1137
|
80 |
|
private function newDoctrineDonationPrePersistSubscriber(): DoctrineDonationPrePersistSubscriber { |
|
1138
|
80 |
|
$tokenGenerator = $this->getTokenGenerator(); |
|
1139
|
80 |
|
return new DoctrineDonationPrePersistSubscriber( |
|
1140
|
|
|
$tokenGenerator, |
|
1141
|
|
|
$tokenGenerator |
|
1142
|
|
|
); |
|
1143
|
|
|
} |
|
1144
|
|
|
|
|
1145
|
80 |
|
private function newDoctrineMembershipApplicationPrePersistSubscriber(): DoctrineMembershipApplicationPrePersistSubscriber { |
|
1146
|
80 |
|
$tokenGenerator = $this->getTokenGenerator(); |
|
1147
|
80 |
|
return new DoctrineMembershipApplicationPrePersistSubscriber( |
|
1148
|
|
|
$tokenGenerator, |
|
1149
|
|
|
$tokenGenerator |
|
1150
|
|
|
); |
|
1151
|
|
|
} |
|
1152
|
|
|
|
|
1153
|
21 |
|
public function setTokenGenerator( TokenGenerator $tokenGenerator ) { |
|
1154
|
21 |
|
$this->pimple['token_generator'] = $tokenGenerator; |
|
1155
|
21 |
|
} |
|
1156
|
|
|
|
|
1157
|
|
|
public function disableDoctrineSubscribers() { |
|
1158
|
|
|
$this->addDoctrineSubscribers = false; |
|
1159
|
|
|
} |
|
1160
|
|
|
|
|
1161
|
25 |
|
private function newDonationTokenFetcher(): DonationTokenFetcher { |
|
1162
|
25 |
|
return new DoctrineDonationTokenFetcher( |
|
1163
|
25 |
|
$this->getEntityManager() |
|
1164
|
|
|
); |
|
1165
|
|
|
} |
|
1166
|
|
|
|
|
1167
|
11 |
|
private function newMembershipApplicationTokenFetcher(): ApplicationTokenFetcher { |
|
1168
|
11 |
|
return new DoctrineApplicationTokenFetcher( |
|
1169
|
11 |
|
$this->getEntityManager() |
|
1170
|
|
|
); |
|
1171
|
|
|
} |
|
1172
|
|
|
|
|
1173
|
15 |
|
private function newDonationPolicyValidator(): AddDonationPolicyValidator { |
|
1174
|
15 |
|
return new AddDonationPolicyValidator( |
|
1175
|
15 |
|
$this->newDonationAmountPolicyValidator(), |
|
1176
|
15 |
|
$this->newTextPolicyValidator( 'fields' ) |
|
1177
|
|
|
); |
|
1178
|
|
|
} |
|
1179
|
|
|
|
|
1180
|
15 |
|
private function newDonationAmountPolicyValidator(): AmountPolicyValidator { |
|
1181
|
|
|
// in the future, this might come from the configuration |
|
1182
|
15 |
|
return new AmountPolicyValidator( 1000, 1000 ); |
|
1183
|
|
|
} |
|
1184
|
|
|
|
|
1185
|
2 |
|
public function getDonationTimeframeLimit() { |
|
1186
|
2 |
|
return $this->config['donation-timeframe-limit']; |
|
1187
|
|
|
} |
|
1188
|
|
|
|
|
1189
|
2 |
|
public function newSystemMessageResponse( string $message ) { |
|
1190
|
2 |
|
$test = $this->getIncludeTemplate( 'System_Message.twig' ); |
|
1191
|
2 |
|
return $test->render( [ 'message' => $message ] ); |
|
1192
|
|
|
} |
|
1193
|
|
|
|
|
1194
|
2 |
|
public function getMembershipApplicationTimeframeLimit() { |
|
1195
|
2 |
|
return $this->config['membership-application-timeframe-limit']; |
|
1196
|
|
|
} |
|
1197
|
|
|
|
|
1198
|
3 |
|
private function newAddCommentValidator(): AddCommentValidator { |
|
1199
|
3 |
|
return new AddCommentValidator(); |
|
1200
|
|
|
} |
|
1201
|
|
|
|
|
1202
|
101 |
|
private function getPageCache(): Cache { |
|
1203
|
101 |
|
return $this->pimple['page_cache']; |
|
1204
|
|
|
} |
|
1205
|
|
|
|
|
1206
|
98 |
|
private function getRenderedPageCache(): Cache { |
|
1207
|
98 |
|
return $this->pimple['rendered_page_cache']; |
|
1208
|
|
|
} |
|
1209
|
|
|
|
|
1210
|
|
|
public function enablePageCache() { |
|
1211
|
|
|
$this->pimple['page_cache'] = function() { |
|
1212
|
|
|
return new FilesystemCache( $this->getCachePath() . '/pages/raw' ); |
|
1213
|
|
|
}; |
|
1214
|
|
|
|
|
1215
|
|
|
$this->pimple['rendered_page_cache'] = function() { |
|
1216
|
|
|
return new FilesystemCache( $this->getCachePath() . '/pages/rendered' ); |
|
1217
|
|
|
}; |
|
1218
|
|
|
} |
|
1219
|
|
|
|
|
1220
|
107 |
|
private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) { |
|
1221
|
107 |
|
if ( $this->profiler === null ) { |
|
1222
|
107 |
|
return $objectToDecorate; |
|
1223
|
|
|
} |
|
1224
|
|
|
|
|
1225
|
|
|
$builder = new ProfilingDecoratorBuilder( $this->profiler, $this->getProfilerDataCollector() ); |
|
1226
|
|
|
|
|
1227
|
|
|
return $builder->decorate( $objectToDecorate, $profilingLabel ); |
|
1228
|
|
|
} |
|
1229
|
|
|
|
|
1230
|
|
|
public function setProfiler( Stopwatch $profiler ) { |
|
1231
|
|
|
$this->profiler = $profiler; |
|
1232
|
|
|
} |
|
1233
|
|
|
|
|
1234
|
|
|
public function setLogger( LoggerInterface $logger ) { |
|
1235
|
|
|
$this->pimple['logger'] = $logger; |
|
1236
|
|
|
} |
|
1237
|
|
|
|
|
1238
|
|
|
public function getProfilerDataCollector(): ProfilerDataCollector { |
|
1239
|
|
|
return $this->pimple['profiler_data_collector']; |
|
1240
|
|
|
} |
|
1241
|
|
|
|
|
1242
|
25 |
|
private function newIbanValidator(): IbanValidator { |
|
1243
|
25 |
|
return new IbanValidator( $this->newBankDataConverter(), $this->config['banned-ibans'] ); |
|
1244
|
|
|
} |
|
1245
|
|
|
|
|
1246
|
98 |
|
private function newFilePrefixer(): FilePrefixer { |
|
1247
|
98 |
|
return new FilePrefixer( $this->getFilePrefix() ); |
|
1248
|
|
|
} |
|
1249
|
|
|
|
|
1250
|
98 |
|
private function getFilePrefix(): string { |
|
1251
|
98 |
|
$prefixContentFile = $this->getVarPath() . '/file_prefix.txt'; |
|
1252
|
98 |
|
if ( !file_exists( $prefixContentFile ) ) { |
|
1253
|
98 |
|
return ''; |
|
1254
|
|
|
} |
|
1255
|
|
|
return $prefix = preg_replace( '/[^0-9a-f]/', '', file_get_contents( $prefixContentFile ) ); |
|
|
|
|
|
|
1256
|
|
|
} |
|
1257
|
|
|
|
|
1258
|
2 |
|
public function newDonationAcceptedEventHandler( string $updateToken ): DonationAcceptedEventHandler { |
|
1259
|
2 |
|
return new DonationAcceptedEventHandler( |
|
1260
|
2 |
|
$this->newDonationAuthorizer( $updateToken ), |
|
1261
|
2 |
|
$this->getDonationRepository(), |
|
1262
|
2 |
|
$this->newDonationConfirmationMailer() |
|
1263
|
|
|
); |
|
1264
|
|
|
} |
|
1265
|
|
|
|
|
1266
|
|
|
} |
|
1267
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.