Completed
Push — master ( 324cad...e6dbd1 )
by Gabriel
107:45 queued 42:39
created

newHandlePayPalPaymentNotificationUseCase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
crap 1
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 FileFetcher\ErrorLoggingFileFetcher;
14
use FileFetcher\SimpleFileFetcher;
15
use GuzzleHttp\Client;
16
use NumberFormatter;
17
use Pimple\Container;
18
use Psr\Log\LoggerInterface;
19
use Psr\Log\NullLogger;
20
use Swift_MailTransport;
21
use Swift_NullTransport;
22
use Symfony\Component\Stopwatch\Stopwatch;
23
use Symfony\Component\Translation\TranslatorInterface;
24
use Symfony\Component\Validator\Constraint as ValidatorConstraint;
25
use Symfony\Component\Validator\Constraints\Range as RangeConstraint;
26
use Symfony\Component\Validator\Constraints\Type as TypeConstraint;
27
use Symfony\Component\Validator\Constraints\Required as RequiredConstraint;
28
use TNvpServiceDispatcher;
29
use Twig_Environment;
30
use Twig_Extensions_Extension_Intl;
31
use Twig_SimpleFunction;
32
use WMDE\EmailAddress\EmailAddress;
33
use WMDE\Euro\Euro;
34
use WMDE\Fundraising\ContentProvider\ContentProvider;
35
use WMDE\Fundraising\Frontend\DonationContext\Authorization\DonationAuthorizer;
36
use WMDE\Fundraising\Frontend\DonationContext\Authorization\DonationTokenFetcher;
37
use WMDE\Fundraising\Frontend\DonationContext\Authorization\RandomTokenGenerator;
38
use WMDE\Fundraising\Frontend\DonationContext\Authorization\TokenGenerator;
39
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineCommentFinder;
40
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationAuthorizer;
41
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationEventLogger;
42
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationPrePersistSubscriber;
43
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationRepository;
44
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationTokenFetcher;
45
use WMDE\Fundraising\Frontend\DonationContext\Domain\Repositories\CommentFinder;
46
use WMDE\Fundraising\Frontend\DonationContext\Domain\Repositories\DonationRepository;
47
use WMDE\Fundraising\Frontend\DonationContext\DonationAcceptedEventHandler;
48
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\BestEffortDonationEventLogger;
49
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\DonationConfirmationMailer;
50
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\DonationEventLogger;
51
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\LoggingCommentFinder;
52
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\LoggingDonationRepository;
53
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddComment\AddCommentUseCase;
54
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddComment\AddCommentValidator;
55
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationPolicyValidator;
56
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationUseCase;
57
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationValidator;
58
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\InitialDonationStatusPicker;
59
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\ReferrerGeneralizer;
60
use WMDE\Fundraising\Frontend\DonationContext\UseCases\CancelDonation\CancelDonationUseCase;
61
use WMDE\Fundraising\Frontend\DonationContext\UseCases\CreditCardPaymentNotification\CreditCardNotificationUseCase;
62
use WMDE\Fundraising\Frontend\DonationContext\UseCases\HandlePayPalPaymentNotification\HandlePayPalPaymentCompletionNotificationUseCase;
63
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ListComments\ListCommentsUseCase;
64
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ShowDonationConfirmation\ShowDonationConfirmationUseCase;
65
use WMDE\Fundraising\Frontend\DonationContext\UseCases\SofortPaymentNotification\SofortPaymentNotificationUseCase;
66
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ValidateDonor\ValidateDonorUseCase;
67
use WMDE\Fundraising\Frontend\Infrastructure\Cache\AllOfTheCachePurger;
68
use WMDE\Fundraising\Frontend\Infrastructure\Cache\AuthorizedCachePurger;
69
use WMDE\Fundraising\Frontend\Infrastructure\CookieBuilder;
70
use WMDE\Fundraising\Frontend\Infrastructure\InternetDomainNameValidator;
71
use WMDE\Fundraising\Frontend\Infrastructure\LoggingMailer;
72
use WMDE\Fundraising\Frontend\Infrastructure\LoggingPaymentNotificationVerifier;
73
use WMDE\Fundraising\Frontend\Infrastructure\MailTemplateFilenameTraversable;
74
use WMDE\Fundraising\Frontend\Infrastructure\Messenger;
75
use WMDE\Fundraising\Frontend\Infrastructure\OperatorMailer;
76
use WMDE\Fundraising\Frontend\Infrastructure\PageViewTracker;
77
use WMDE\Fundraising\Frontend\Infrastructure\PaymentNotificationVerifier;
78
use WMDE\Fundraising\Frontend\Infrastructure\PayPalPaymentNotificationVerifier;
79
use WMDE\Fundraising\Frontend\Infrastructure\PiwikServerSideTracker;
80
use WMDE\Fundraising\Frontend\Infrastructure\ProfilerDataCollector;
81
use WMDE\Fundraising\Frontend\Infrastructure\ProfilingDecoratorBuilder;
82
use WMDE\Fundraising\Frontend\Infrastructure\ServerSideTracker;
83
use WMDE\Fundraising\Frontend\Infrastructure\TemplateBasedMailer;
84
use WMDE\Fundraising\Frontend\Infrastructure\TemplateMailerInterface;
85
use WMDE\Fundraising\Frontend\Infrastructure\UrlGenerator;
86
use WMDE\Fundraising\Frontend\Infrastructure\WordListFileReader;
87
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\ApplicationAuthorizer;
88
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\ApplicationTokenFetcher;
89
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\MembershipTokenGenerator;
90
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\RandomMembershipTokenGenerator;
91
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationAuthorizer;
92
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationPiwikTracker;
93
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationRepository;
94
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationTokenFetcher;
95
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationTracker;
96
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineMembershipApplicationPrePersistSubscriber;
97
use WMDE\Fundraising\Frontend\MembershipContext\Domain\Repositories\ApplicationRepository;
98
use WMDE\Fundraising\Frontend\MembershipContext\Infrastructure\LoggingApplicationRepository;
99
use WMDE\Fundraising\Frontend\MembershipContext\Tracking\ApplicationPiwikTracker;
100
use WMDE\Fundraising\Frontend\MembershipContext\Tracking\ApplicationTracker;
101
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\ApplyForMembershipPolicyValidator;
102
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\ApplyForMembershipUseCase;
103
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\MembershipApplicationValidator;
104
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\CancelMembershipApplication\CancelMembershipApplicationUseCase;
105
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\HandleSubscriptionPaymentNotification\HandleSubscriptionPaymentNotificationUseCase;
106
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\HandleSubscriptionSignupNotification\HandleSubscriptionSignupNotificationUseCase;
107
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ShowMembershipApplicationConfirmation\ShowMembershipApplicationConfirmationUseCase;
108
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\McpCreditCardService;
109
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\Sofort\Transfer\Client as SofortClient;
110
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\UniqueTransferCodeGenerator;
111
use WMDE\Fundraising\Frontend\PaymentContext\Domain\BankDataConverter;
112
use WMDE\Fundraising\Frontend\PaymentContext\Domain\BankDataValidator;
113
use WMDE\Fundraising\Frontend\PaymentContext\Domain\DefaultPaymentDelayCalculator;
114
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentDelayCalculator;
115
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\CreditCard as CreditCardUrlGenerator;
116
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\CreditCardConfig;
117
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\PayPal as PayPalUrlGenerator;
118
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\PayPalConfig;
119
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\Sofort as SofortUrlGenerator;
120
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\SofortConfig;
121
use WMDE\Fundraising\Frontend\PaymentContext\Domain\SimpleTransferCodeGenerator;
122
use WMDE\Fundraising\Frontend\PaymentContext\Domain\TransferCodeGenerator;
123
use WMDE\Fundraising\Frontend\PaymentContext\Infrastructure\CreditCardService;
124
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\CheckIban\CheckIbanUseCase;
125
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\GenerateIban\GenerateIbanUseCase;
126
use WMDE\Fundraising\Frontend\Presentation\AmountFormatter;
127
use WMDE\Fundraising\Frontend\Presentation\ContentPage\PageSelector;
128
use WMDE\Fundraising\Frontend\Presentation\DonationConfirmationPageSelector;
129
use WMDE\Fundraising\Frontend\Presentation\FilePrefixer;
130
use WMDE\Fundraising\Frontend\Presentation\GreetingGenerator;
131
use WMDE\Fundraising\Frontend\Presentation\Honorifics;
132
use WMDE\Fundraising\Frontend\Presentation\PaymentTypesSettings;
133
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionHtmlPresenter;
134
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionJsonPresenter;
135
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelDonationHtmlPresenter;
136
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelMembershipApplicationHtmlPresenter;
137
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListHtmlPresenter;
138
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListJsonPresenter;
139
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListRssPresenter;
140
use WMDE\Fundraising\Frontend\Presentation\Presenters\ConfirmSubscriptionHtmlPresenter;
141
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardNotificationPresenter;
142
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardPaymentUrlGenerator;
143
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationConfirmationHtmlPresenter;
144
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormPresenter;
145
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormViolationPresenter;
146
use WMDE\Fundraising\Frontend\Presentation\Presenters\GetInTouchHtmlPresenter;
147
use WMDE\Fundraising\Frontend\Presentation\Presenters\IbanPresenter;
148
use WMDE\Fundraising\Frontend\Presentation\Presenters\InternalErrorHtmlPresenter;
149
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipApplicationConfirmationHtmlPresenter;
150
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipFormViolationPresenter;
151
use WMDE\Fundraising\Frontend\Presentation\Presenters\PageNotFoundPresenter;
152
use WMDE\Fundraising\Frontend\Presentation\SkinSettings;
153
use WMDE\Fundraising\Frontend\Presentation\TwigTemplate;
154
use WMDE\Fundraising\Frontend\SubscriptionContext\DataAccess\DoctrineSubscriptionRepository;
155
use WMDE\Fundraising\Frontend\SubscriptionContext\Domain\Repositories\SubscriptionRepository;
156
use WMDE\Fundraising\Frontend\SubscriptionContext\Infrastructure\LoggingSubscriptionRepository;
157
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\AddSubscription\AddSubscriptionUseCase;
158
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\ConfirmSubscription\ConfirmSubscriptionUseCase;
159
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionDuplicateValidator;
160
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionValidator;
161
use WMDE\Fundraising\Frontend\UseCases\GetInTouch\GetInTouchUseCase;
162
use WMDE\FunValidators\Validators\AllowedValuesValidator;
163
use WMDE\FunValidators\Validators\AmountPolicyValidator;
164
use WMDE\FunValidators\Validators\EmailValidator;
165
use WMDE\Fundraising\Frontend\Validation\GetInTouchValidator;
166
use WMDE\Fundraising\Frontend\Validation\KontoCheckIbanValidator;
167
use WMDE\Fundraising\Frontend\Validation\MembershipFeeValidator;
168
use WMDE\Fundraising\Frontend\Validation\TemplateNameValidator;
169
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentDataValidator;
170
use WMDE\FunValidators\Validators\TextPolicyValidator;
171
use WMDE\Fundraising\Store\Factory as StoreFactory;
172
use WMDE\Fundraising\Store\Installer;
173
174
/**
175
 * @licence GNU GPL v2+
176
 */
177 160
class FunFunFactory {
178 160
179 160
	private $config;
180 160
181
	/**
182 160
	 * @var Container
183 160
	 */
184
	private $pimple;
185
186 119
	private $addDoctrineSubscribers = true;
187
188
	/**
189
	 * @var Stopwatch|null
190 4
	 */
191
	private $profiler = null;
192
193
	public function __construct( array $config ) {
194
		$this->config = $config;
195
		$this->pimple = $this->newPimple();
196
	}
197
198 160
	private function newPimple(): Container {
199
		$pimple = new Container();
200
201
		$pimple['logger'] = function() {
202 90
			return new NullLogger();
203 90
		};
204 90
205 90
		$pimple['paypal_logger'] = function() {
206 90
			return new NullLogger();
207
		};
208
209 90
		$pimple['sofort_logger'] = function() {
210
			return new NullLogger();
211
		};
212
213 9
		$pimple['profiler_data_collector'] = function() {
214 9
			return new ProfilerDataCollector();
215 9
		};
216
217
		$pimple['dbal_connection'] = function() {
218
			return DriverManager::getConnection( $this->config['db'] );
219
		};
220 47
221 47
		$pimple['entity_manager'] = function() {
222 47
			$entityManager = ( new StoreFactory( $this->getConnection(), $this->getVarPath() . '/doctrine_proxies' ) )
223
				->getEntityManager();
224
			if ( $this->addDoctrineSubscribers ) {
225
				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() );
226
				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() );
227 14
			}
228 14
229 14
			return $entityManager;
230
		};
231
232
		$pimple['subscription_repository'] = function() {
233
			return new LoggingSubscriptionRepository(
234 12
				new DoctrineSubscriptionRepository( $this->getEntityManager() ),
235 12
				$this->getLogger()
236 12
			);
237
		};
238
239 12
		$pimple['donation_repository'] = function() {
240
			return new LoggingDonationRepository(
241
				new DoctrineDonationRepository( $this->getEntityManager() ),
242
				$this->getLogger()
243 44
			);
244
		};
245
246
		$pimple['membership_application_repository'] = function() {
247 7
			return new LoggingApplicationRepository(
248 7
				new DoctrineApplicationRepository( $this->getEntityManager() ),
249 7
				$this->getLogger()
250 7
			);
251 7
		};
252
253
		$pimple['comment_repository'] = function() {
254
			$finder = new LoggingCommentFinder(
255
				new DoctrineCommentFinder( $this->getEntityManager() ),
256 8
				$this->getLogger()
257
			);
258
259
			return $this->addProfilingDecorator( $finder, 'CommentFinder' );
260 3
		};
261
262
		$pimple['mail_validator'] = function() {
263
			return new EmailValidator( new InternetDomainNameValidator() );
264 56
		};
265
266
		$pimple['subscription_validator'] = function() {
267
			return new SubscriptionValidator(
268 102
				$this->getEmailValidator(),
269 102
				$this->newTextPolicyValidator( 'fields' ),
270 102
				$this->newSubscriptionDuplicateValidator(),
271
				$this->newHonorificValidator()
272
			);
273
		};
274
275 102
		$pimple['template_name_validator'] = function() {
276 102
			return new TemplateNameValidator( $this->getSkinTwig() );
277
		};
278 102
279 102
		$pimple['contact_validator'] = function() {
280
			return new GetInTouchValidator( $this->getEmailValidator() );
281 102
		};
282 102
283 102
		$pimple['greeting_generator'] = function() {
284
			return new GreetingGenerator();
285
		};
286
287 102
		$pimple['translator'] = function() {
288
			$translationFactory = new TranslationFactory();
289
			$loaders = [
290
				'json' => $translationFactory->newJsonLoader()
291 114
			];
292
			$locale = $this->config['locale'];
293 114
			$messagesPath = $this->getI18nDirectory() . $this->config['translation']['message-dir'];
294
			$translator = $translationFactory->create( $loaders, $locale );
295 114
			foreach ($this->config['translation']['files'] as $domain => $file) {
296 114
				$translator->addResource( 'json', $messagesPath . '/' . $file, $locale, $domain );
297 114
			}
298 114
299 114
			return $translator;
300
		};
301
302
		// In the future, this could be locale-specific or filled from a DB table
303 114
		$pimple['honorifics'] = function() {
304 114
			return new Honorifics( [
305 114
				'' => 'Kein Titel',
306
				'Dr.' => 'Dr.',
307 114
				'Prof.' => 'Prof.',
308
				'Prof. Dr.' => 'Prof. Dr.'
309
			] );
310 114
		};
311 114
312 114
		$pimple['twig'] = function() {
313
			$config = $this->config['twig'];
314 114
			$config['loaders']['filesystem']['template-dir'] = 'skins/' . $this->getSkinSettings()->getSkin() . '/templates';
315
316
			$twigFactory = $this->newTwigFactory( $config );
317 114
			$configurator = $twigFactory->newTwigEnvironmentConfigurator();
318 114
319 114
			$loaders = array_filter( [
320
				$twigFactory->newFileSystemLoader(),
321 114
				$twigFactory->newArrayLoader(), // This is just a fallback for testing
322
			] );
323
			$extensions = [
324 114
				$twigFactory->newTranslationExtension( $this->getTranslator() ),
325 114
				new Twig_Extensions_Extension_Intl()
326 114
			];
327
			$filters = [
328 114
				$twigFactory->newFilePrefixFilter(
329
					$this->getFilePrefixer()
330
				)
331 114
			];
332
			$functions = [
333
				new Twig_SimpleFunction(
334
					'web_content',
335
					function( string $name, array $context = [] ): string {
336 78
						return $this->getContentProvider()->getWeb( $name, $context );
337 78
					},
338
					[ 'is_safe' => [ 'html' ] ]
339
				),
340
			];
341
342
			return $configurator->getEnvironment( $this->pimple['skin_twig_environment'], $loaders, $extensions, $filters, $functions );
343
		};
344
345 109
		$pimple['mailer_twig'] = function() {
346
			$twigFactory = $this->newTwigFactory( $this->config['mailer-twig'] );
347
			$configurator = $twigFactory->newTwigEnvironmentConfigurator();
348
349 109
			$loaders = array_filter( [
350 109
				$twigFactory->newFileSystemLoader(),
351 109
				$twigFactory->newArrayLoader(), // This is just a fallback for testing
352 109
			] );
353 109
			$extensions = [
354 109
				$twigFactory->newTranslationExtension( $this->getTranslator() ),
355 109
				new Twig_Extensions_Extension_Intl(),
356
			];
357
			$filters = [];
358
			$functions = [
359 109
				new Twig_SimpleFunction(
360 109
					'mail_content',
361
					function( string $name, array $context = [] ): string {
362
						return $this->getContentProvider()->getMail( $name, $context );
363 109
					},
364 109
					[ 'is_safe' => [ 'all' ] ]
365
				),
366
				new Twig_SimpleFunction(
367
					'url',
368 109
					function( string $name, array $parameters = [] ): string {
369
						return $this->getUrlGenerator()->generateUrl( $name, $parameters );
370
					}
371
				)
372
			];
373
374
			$twigEnvironment = new Twig_Environment();
375
376
			return $configurator->getEnvironment( $twigEnvironment, $loaders, $extensions, $filters, $functions );
377
		};
378
379
		$pimple['messenger_suborganization'] = function() {
380
			return new Messenger(
381
				new Swift_MailTransport(),
0 ignored issues
show
Deprecated Code introduced by
The class Swift_MailTransport has been deprecated with message: since 5.4.5 (to be removed in 6.0)

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.

Loading history...
382
				$this->getSubOrganizationEmailAddress(),
383
				$this->config['contact-info']['suborganization']['name']
384
			);
385
		};
386
387
		$pimple['messenger_organization'] = function() {
388 6
			return new Messenger(
389
				new Swift_MailTransport(),
0 ignored issues
show
Deprecated Code introduced by
The class Swift_MailTransport has been deprecated with message: since 5.4.5 (to be removed in 6.0)

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.

Loading history...
390
				$this->getOrganizationEmailAddress(),
391
				$this->config['contact-info']['organization']['name']
392
			);
393
		};
394
395
		$pimple['confirmation-page-selector'] = function() {
396
			return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] );
397
		};
398
399
		$pimple['paypal-payment-notification-verifier'] = function() {
400
			return new LoggingPaymentNotificationVerifier(
401
				new PayPalPaymentNotificationVerifier(
402
					new Client(),
403
					$this->config['paypal-donation']['base-url'],
404
					$this->config['paypal-donation']['account-address']
405
				),
406
				$this->getLogger()
407
			);
408
		};
409
410
		$pimple['paypal-membership-fee-notification-verifier'] = function() {
411
			return new LoggingPaymentNotificationVerifier(
412
				new PayPalPaymentNotificationVerifier(
413
					new Client(),
414 69
					$this->config['paypal-membership']['base-url'],
415 69
					$this->config['paypal-membership']['account-address']
416 69
				),
417
				$this->getLogger()
418
			);
419
		};
420
421 112
		$pimple['credit-card-api-service'] = function() {
422
			return new McpCreditCardService(
423
				new TNvpServiceDispatcher(
424
					'IMcpCreditcardService_v1_5',
425 109
					'https://sipg.micropayment.de/public/creditcard/v1.5/nvp/'
426
				),
427
				$this->config['creditcard']['access-key'],
428
				$this->config['creditcard']['testmode']
429
			);
430
		};
431
432 160
		$pimple['donation_token_generator'] = function() {
433
			return new RandomTokenGenerator(
434
				$this->config['token-length'],
435 160
				new \DateInterval( $this->config['token-validity-timestamp'] )
436 160
			);
437
		};
438
439 90
		$pimple['membership_token_generator'] = function() {
440 90
			return new RandomMembershipTokenGenerator(
441
				$this->config['token-length'],
442
				new \DateInterval( $this->config['token-validity-timestamp'] )
443 11
			);
444 11
		};
445 11
446 11
		$pimple['page_cache'] = function() {
447
			return new VoidCache();
448
		};
449
450 160
		$pimple['rendered_page_cache'] = function() {
451 160
			return new VoidCache();
452
		};
453
454 12
		$pimple['page_view_tracker'] = function () {
455 12
			return new PageViewTracker( $this->newServerSideTracker(), $this->config['piwik']['siteUrlBase'] );
456
		};
457
458 6
		$pimple['cachebusting_fileprefixer'] = function () {
459 6
			return new FilePrefixer( $this->getFilePrefix() );
460
		};
461
462 2
		$pimple['content_page_selector'] = function () {
463 2
			$json = (new SimpleFileFetcher())->fetchFile( $this->getI18nDirectory() . '/data/pages.json' );
464 2
			$config = json_decode( $json, true ) ?? [];
465 2
466
			return new PageSelector( $config );
467
		};
468
469 4
		$pimple['content_provider'] = function () {
470 4
			return new ContentProvider( [
471
				'content_path' => $this->getI18nDirectory(),
472
				'cache' => $this->config['twig']['enable-cache'] ? $this->getCachePath() . '/content' : false,
473 12
				'globals' => [
474 12
					'basepath' => $this->config['web-basepath']
475
				]
476
			] );
477 10
		};
478 10
479
		$pimple['payment-delay-calculator'] = function() {
480
			return new DefaultPaymentDelayCalculator( $this->getPaymentDelayInDays() );
481 1
		};
482 1
483 1
		$pimple['sofort-client'] = function () {
484
			$config = $this->config['sofort'];
485 7
			return new SofortClient( $config['config-key'] );
486 7
		};
487
488
		$pimple['cookie-builder'] = function (): CookieBuilder {
489 46
			return new CookieBuilder(
490 46
				$this->config['cookie']['expiration'],
491
				$this->config['cookie']['path'],
492
				$this->config['cookie']['domain'],
493 8
				$this->config['cookie']['secure'],
494 8
				$this->config['cookie']['httpOnly'],
495
				$this->config['cookie']['raw'],
496
				$this->config['cookie']['sameSite']
497 1
			);
498 1
		};
499
500
		$pimple['skin-settings'] = function (): SkinSettings {
501 3
			$config = $this->config['skin'];
502 3
			return new SkinSettings( $config['options'], $config['default'], $config['cookie-lifetime'] );
503 3
		};
504 3
505
		$pimple['payment-types-settings'] = function (): PaymentTypesSettings {
506
			return new PaymentTypesSettings( $this->config['payment-types'] );
507
		};
508 3
509 3
		return $pimple;
510
	}
511
512 1
	public function getConnection(): Connection {
513 1
		return $this->pimple['dbal_connection'];
514
	}
515
516 160
	public function getEntityManager(): EntityManager {
517 160
		return $this->pimple['entity_manager'];
518 160
	}
519
520 109
	private function newDonationEventLogger(): DonationEventLogger {
521 109
		return new BestEffortDonationEventLogger(
522
			new DoctrineDonationEventLogger( $this->getEntityManager() ),
523
			$this->getLogger()
524
		);
525
	}
526
527
	public function newInstaller(): Installer {
528
		return ( new StoreFactory( $this->getConnection() ) )->newInstaller();
529
	}
530
531 43
	public function newListCommentsUseCase(): ListCommentsUseCase {
532 43
		return new ListCommentsUseCase( $this->getCommentFinder() );
533 43
	}
534
535 43
	public function newCommentListJsonPresenter(): CommentListJsonPresenter {
536
		return new CommentListJsonPresenter();
537
	}
538
539
	public function newCommentListRssPresenter(): CommentListRssPresenter {
540
		return new CommentListRssPresenter( new TwigTemplate(
541
			$this->getSkinTwig(),
542
			'Comment_List.rss.twig'
543
		) );
544
	}
545 30
546 30
	public function newCommentListHtmlPresenter(): CommentListHtmlPresenter {
547 30
		return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'Comment_List.html.twig', [ 'piwikGoals' => [ 1 ] ] ) );
548 30
	}
549
550 30
	private function getCommentFinder(): CommentFinder {
551 30
		return $this->pimple['comment_repository'];
552
	}
553
554
	public function getSubscriptionRepository(): SubscriptionRepository {
555
		return $this->pimple['subscription_repository'];
556
	}
557 72
558
	public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ): void {
559 72
		$this->pimple['subscription_repository'] = $subscriptionRepository;
560 72
	}
561 72
562 72
	private function getSubscriptionValidator(): SubscriptionValidator {
563 72
		return $this->pimple['subscription_validator'];
564 72
	}
565
566
	public function getEmailValidator(): EmailValidator {
567
		return $this->pimple['mail_validator'];
568 20
	}
569 20
570 20
	public function getTemplateNameValidator(): TemplateNameValidator {
571 20
		return $this->pimple['template_name_validator'];
572
	}
573
574
	public function newAddSubscriptionHtmlPresenter(): AddSubscriptionHtmlPresenter {
575 112
		return new AddSubscriptionHtmlPresenter( $this->getLayoutTemplate( 'Subscription_Form.html.twig' ), $this->getTranslator() );
576 112
	}
577
578
	public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter {
579 10
		return new ConfirmSubscriptionHtmlPresenter(
580 10
			$this->getLayoutTemplate( 'Confirm_Subscription.twig' ),
581 10
			$this->getTranslator()
582
		);
583 102
	}
584 102
585
	public function newAddSubscriptionJsonPresenter(): AddSubscriptionJsonPresenter {
586
		return new AddSubscriptionJsonPresenter( $this->getTranslator() );
587 112
	}
588 112
589 112
	public function newGetInTouchHtmlPresenter(): GetInTouchHtmlPresenter {
590 112
		return new GetInTouchHtmlPresenter( $this->getLayoutTemplate( 'contact_form.html.twig' ), $this->getTranslator() );
591
	}
592
593 112
	public function setSkinTwigEnvironment( Twig_Environment $twig ): void {
594
		$this->pimple['skin_twig_environment'] = $twig;
595
	}
596 109
597 109
	public function getSkinTwig(): Twig_Environment {
598 109
		return $this->pimple['twig'];
599 109
	}
600
601
	public function getMailerTwig(): Twig_Environment {
602 109
		return $this->pimple['mailer_twig'];
603
	}
604
605 112
	/**
606 112
	 * Get a template, with the content for the layout areas filled in.
607 112
	 *
608 112
	 * @param string $templateName
609 112
	 * @param array $context Additional variables for the template
610 112
	 * @return TwigTemplate
611 112
	 */
612
	public function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate {
613
		 return new TwigTemplate(
614
			$this->getSkinTwig(),
615 109
			$templateName,
616 109
			array_merge( $this->getDefaultTwigVariables(), $context )
617 109
		);
618 109
	}
619 109
620 109
	public function getMailerTemplate( string $templateName, array $context = [] ): TwigTemplate {
621 109
		return new TwigTemplate(
622
			$this->getMailerTwig(),
623
			$templateName,
624
			array_merge( $this->getDefaultTwigVariables(), $context )
625 119
		);
626 119
	}
627
628
	private function getDefaultTwigVariables(): array {
629 6
		return [
630 6
			'honorifics' => $this->getHonorifics()->getList(),
631
			'header_template' => $this->config['default-layout-templates']['header'],
632
			'footer_template' => $this->config['default-layout-templates']['footer'],
633 127
			'no_js_notice_template' => $this->config['default-layout-templates']['no-js-notice'],
634 127
			'piwik' => $this->config['piwik'],
635
			'locale' => $this->config['locale'],
636
		];
637 109
	}
638 109
639
	private function newReferrerGeneralizer(): ReferrerGeneralizer {
640
		return new ReferrerGeneralizer(
641
			$this->config['referrer-generalization']['default'],
642
			$this->config['referrer-generalization']['domain-map']
643
		);
644
	}
645
646
	public function getLogger(): LoggerInterface {
647
		return $this->pimple['logger'];
648
	}
649 7
650 7
	public function getPaypalLogger(): LoggerInterface {
651 7
		return $this->pimple['paypal_logger'];
652 7
	}
653 7
654
	public function getSofortLogger(): LoggerInterface {
655
		return $this->pimple['sofort_logger'];
656
	}
657 3
658 3
	private function getVarPath(): string {
659 3
		return __DIR__ . '/../../var';
660 3
	}
661
662
	public function getCachePath(): string {
663
		return $this->getVarPath() . '/cache';
664 7
	}
665 7
666 7
	public function getLoggingPath(): string {
667 7
		return $this->getVarPath() . '/log';
668 7
	}
669 7
670
	public function newAddSubscriptionUseCase(): AddSubscriptionUseCase {
671 7
		return new AddSubscriptionUseCase(
672 7
			$this->getSubscriptionRepository(),
673
			$this->getSubscriptionValidator(),
674
			$this->newAddSubscriptionMailer()
675 7
		);
676
	}
677
678
	public function newConfirmSubscriptionUseCase(): ConfirmSubscriptionUseCase {
679 3
		return new ConfirmSubscriptionUseCase(
680 3
			$this->getSubscriptionRepository(),
681 3
			$this->newConfirmSubscriptionMailer()
682 3
		);
683 3
	}
684 3
685 3
	private function newAddSubscriptionMailer(): TemplateMailerInterface {
686
		return $this->newTemplateMailer(
687 3
			$this->getSuborganizationMessenger(),
688
			new TwigTemplate(
689
				$this->getMailerTwig(),
690
				'Subscription_Request.txt.twig',
691 59
				[
692 59
					'greeting_generator' => $this->getGreetingGenerator()
693
				]
694
			),
695 59
			'mail_subject_subscription'
696
		);
697
	}
698 59
699
	private function newConfirmSubscriptionMailer(): TemplateMailerInterface {
700 59
		return $this->newTemplateMailer(
701
			$this->getSuborganizationMessenger(),
702
			new TwigTemplate(
703 56
					$this->getMailerTwig(),
704 56
					'Subscription_Confirmation.txt.twig',
705
					[ 'greeting_generator' => $this->getGreetingGenerator() ]
706
			),
707
			'mail_subject_subscription_confirmed'
708
		);
709
	}
710
711
	/**
712
	 * Create a new TemplateMailer instance
713
	 *
714
	 * So much decoration going on that explicitly hinting what we return (Robustness principle) would be confusing
715
	 * (you'd expect a TemplateBasedMailer, not a LoggingMailer), so we hint the interface instead.
716
	 */
717
	private function newTemplateMailer( Messenger $messenger, TwigTemplate $template, string $messageKey ): TemplateMailerInterface {
718
		$mailer = new TemplateBasedMailer(
719 31
			$messenger,
720 31
			$template,
721
			$this->getTranslator()->trans( $messageKey )
722
		);
723
724
		$mailer = new LoggingMailer( $mailer, $this->getLogger() );
725
726
		return $this->addProfilingDecorator( $mailer, 'Mailer' );
727
	}
728
729
	public function getGreetingGenerator(): GreetingGenerator {
730
		return $this->pimple['greeting_generator'];
731 3
	}
732 3
733 3
	public function newCheckIbanUseCase(): CheckIbanUseCase {
734 3
		return new CheckIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
735 3
	}
736
737
	public function newGenerateIbanUseCase(): GenerateIbanUseCase {
738
		return new GenerateIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
739 3
	}
740 3
741 3
	public function newIbanPresenter(): IbanPresenter {
742 3
		return new IbanPresenter();
743 3
	}
744
745
	public function newBankDataConverter(): BankDataConverter {
746
		return new BankDataConverter( $this->config['bank-data-file'] );
747 3
	}
748 3
749 3
	public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ): void {
750 3
		$this->pimple['subscription_validator'] = $subscriptionValidator;
751 3
	}
752
753
	public function newGetInTouchUseCase(): GetInTouchUseCase {
754
		return new GetInTouchUseCase(
755 3
			$this->getContactValidator(),
756 3
			$this->newContactOperatorMailer(),
757
			$this->newContactUserMailer()
758
		);
759 7
	}
760 7
761 7
	private function newContactUserMailer(): TemplateMailerInterface {
762 7
		return $this->newTemplateMailer(
763
			$this->getSuborganizationMessenger(),
764
			new TwigTemplate( $this->getMailerTwig(), 'Contact_Confirm_to_User.txt.twig' ),
765
			'mail_subject_getintouch'
766 7
		);
767 7
	}
768 7
769 7
	private function newContactOperatorMailer(): OperatorMailer {
770
		return new OperatorMailer(
771
			$this->getSuborganizationMessenger(),
772 7
			new TwigTemplate( $this->getMailerTwig(), 'Contact_Forward_to_Operator.txt.twig' ),
773 7
			$this->getTranslator()->trans( 'mail_subject_getintouch_forward' )
774
		);
775
	}
776 78
777 78
	private function getContactValidator(): GetInTouchValidator {
778
		return $this->pimple['contact_validator'];
779
	}
780 1
781 1
	private function newSubscriptionDuplicateValidator(): SubscriptionDuplicateValidator {
782 1
		return new SubscriptionDuplicateValidator(
783 1
				$this->getSubscriptionRepository(),
784
				$this->newSubscriptionDuplicateCutoffDate()
785
		);
786
	}
787 31
788 31
	private function newSubscriptionDuplicateCutoffDate(): \DateTime {
789
		$cutoffDateTime = new \DateTime();
790
		$cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) );
791 46
		return $cutoffDateTime;
792 46
	}
793
794
	private function newHonorificValidator(): AllowedValuesValidator {
795 160
		return new AllowedValuesValidator( $this->getHonorifics()->getKeys() );
796 160
	}
797 160
798
	private function getHonorifics(): Honorifics {
799 13
		return $this->pimple['honorifics'];
800 13
	}
801
802
	public function newAuthorizedCachePurger(): AuthorizedCachePurger {
803 160
		return new AuthorizedCachePurger(
804 160
			new AllOfTheCachePurger( $this->getSkinTwig(), $this->getPageCache(), $this->getRenderedPageCache() ),
805 160
			$this->config['purging-secret']
806
		);
807 160
	}
808 160
809 160
	private function newBankDataValidator(): BankDataValidator {
810 160
		return new BankDataValidator( $this->newIbanValidator() );
811
	}
812 160
813 160
	private function getSuborganizationMessenger(): Messenger {
814 160
		return $this->pimple['messenger_suborganization'];
815
	}
816 160
817
	public function setSuborganizationMessenger( Messenger $messenger ): void {
818 160
		$this->pimple['messenger_suborganization'] = $messenger;
819 160
	}
820
821
	private function getOrganizationMessenger(): Messenger {
822 160
		return $this->pimple['messenger_organization'];
823 160
	}
824
825
	public function setOrganizationMessenger( Messenger $messenger ): void {
826 3
		$this->pimple['messenger_organization'] = $messenger;
827 3
	}
828
829
	public function setNullMessenger(): void {
830 3
		$this->setSuborganizationMessenger( new Messenger(
831 3
			Swift_NullTransport::newInstance(),
832
			$this->getSubOrganizationEmailAddress()
833
		) );
834 116
		$this->setOrganizationMessenger( new Messenger(
835 116
			Swift_NullTransport::newInstance(),
836
			$this->getOrganizationEmailAddress()
837
		) );
838 2
	}
839 2
840 2
	public function getSubOrganizationEmailAddress(): EmailAddress {
841
		return new EmailAddress( $this->config['contact-info']['suborganization']['email'] );
842 109
	}
843 109
844
	public function getOrganizationEmailAddress(): EmailAddress {
845
		return new EmailAddress( $this->config['contact-info']['organization']['email'] );
846 41
	}
847 41
848 41
	public function newInternalErrorHtmlPresenter(): InternalErrorHtmlPresenter {
849
		return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'Error_Page.html.twig' ) );
850 41
	}
851 41
852 41
	public function newAccessDeniedHtmlPresenter(): InternalErrorHtmlPresenter {
853
		return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'Access_Denied.twig' ) );
854
	}
855
856 3
	public function getTranslator(): TranslatorInterface {
857 3
		return $this->pimple['translator'];
858
	}
859
860 5
	public function setTranslator( TranslatorInterface $translator ): void {
861 5
		$this->pimple['translator'] = $translator;
862 5
	}
863 5
864 5
	private function newTwigFactory( array $twigConfig ): TwigFactory {
865 5
		return new TwigFactory(
866
			array_merge_recursive(
867
				$twigConfig,
868
				[ 'web-basepath' => $this->config['web-basepath'] ]
869 5
			),
870 5
			$this->getCachePath() . '/twig',
871 5
			$this->config['locale']
872 5
		);
873 5
	}
874 5
875 5
	private function newTextPolicyValidator( string $policyName ): TextPolicyValidator {
876
		$fetcher = new ErrorLoggingFileFetcher(
877 5
			new SimpleFileFetcher(),
878
			$this->getLogger()
879
		);
880
		$textPolicyConfig = $this->config['text-policies'][$policyName];
881 20
		return new TextPolicyValidator(
882 20
			new WordListFileReader(
883 20
				$fetcher,
884 20
				$textPolicyConfig['badwords'] ? $this->getAbsolutePath( $textPolicyConfig['badwords'] ) : ''
885 20
			),
886 20
			new WordListFileReader(
887 20
				$fetcher,
888 20
				$textPolicyConfig['whitewords'] ? $this->getAbsolutePath( $textPolicyConfig['whitewords'] ) : ''
889 20
			)
890
		);
891
	}
892
893 20
	private function newCommentPolicyValidator(): TextPolicyValidator {
894 20
		return $this->newTextPolicyValidator( 'comment' );
895 20
	}
896 20
897
	public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase {
898
		return new CancelDonationUseCase(
899
			$this->getDonationRepository(),
900 20
			$this->newCancelDonationMailer(),
901 20
			$this->newDonationAuthorizer( $updateToken ),
902 20
			$this->newDonationEventLogger()
903 20
		);
904 20
	}
905
906
	private function newCancelDonationMailer(): TemplateMailerInterface {
907
		return $this->newTemplateMailer(
908 2
			$this->getSuborganizationMessenger(),
909 2
			new TwigTemplate(
910 2
				$this->getMailerTwig(),
911 2
				'Donation_Cancellation_Confirmation.txt.twig',
912 2
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
913
			),
914
			'mail_subject_confirm_cancellation'
915
		);
916 28
	}
917 28
918 28
	public function newAddDonationUseCase(): AddDonationUseCase {
919 28
		return new AddDonationUseCase(
920 28
			$this->getDonationRepository(),
921 28
			$this->newDonationValidator(),
922 28
			$this->newDonationPolicyValidator(),
923
			$this->newReferrerGeneralizer(),
924 28
			$this->newDonationConfirmationMailer(),
925 28
			$this->newBankTransferCodeGenerator(),
926
			$this->newDonationTokenFetcher(),
927
			new InitialDonationStatusPicker()
928 28
		);
929
	}
930
931
	private function newBankTransferCodeGenerator(): TransferCodeGenerator {
932
		return new UniqueTransferCodeGenerator(
933 2
			new SimpleTransferCodeGenerator(),
934 2
			$this->getEntityManager()
935
		);
936
	}
937 2
938 2
	private function newDonationValidator(): AddDonationValidator {
939
		return new AddDonationValidator(
940
			$this->newPaymentDataValidator(),
941 2
			$this->newBankDataValidator(),
942 2
			$this->getEmailValidator()
943
		);
944
	}
945 2
946 2
	public function newValidateDonorUseCase(): ValidateDonorUseCase {
947
		return new ValidateDonorUseCase(
948
			$this->getEmailValidator()
949 3
		);
950 3
	}
951
952
	private function newDonationConfirmationMailer(): DonationConfirmationMailer {
953 3
		return new DonationConfirmationMailer(
954 3
			$this->newTemplateMailer(
955
				$this->getSuborganizationMessenger(),
956
				new TwigTemplate(
957 47
					$this->getMailerTwig(),
958 47
					'Donation_Confirmation.txt.twig',
959
					[
960
						'greeting_generator' => $this->getGreetingGenerator()
961 36
					]
962 36
				),
963
				'mail_subject_confirm_donation'
964
			)
965 19
		);
966 19
	}
967
968
	public function newPayPalUrlGeneratorForDonations(): PayPalUrlGenerator {
969 2
		return new PayPalUrlGenerator(
970 2
			$this->getPayPalUrlConfigForDonations(),
971
			$this->getTranslator()->trans( 'item_name_donation' )
972
		);
973 3
	}
974 3
975 3
	public function newPayPalUrlGeneratorForMembershipApplications(): PayPalUrlGenerator {
976 3
		return new PayPalUrlGenerator(
977 3
			$this->getPayPalUrlConfigForMembershipApplications(),
978 3
			$this->getTranslator()->trans( 'item_name_membership' )
979
		);
980
	}
981
982 29
	private function getPayPalUrlConfigForDonations(): PayPalConfig {
983 29
		return PayPalConfig::newFromConfig( $this->config['paypal-donation'] );
984 29
	}
985
986
	private function getPayPalUrlConfigForMembershipApplications(): PayPalConfig {
987
		return PayPalConfig::newFromConfig( $this->config['paypal-membership'] );
988
	}
989
990 90
	public function newSofortUrlGeneratorForDonations(): SofortUrlGenerator {
991 90
		$config = $this->config['sofort'];
992
993
		return new SofortUrlGenerator(
994 10
			new SofortConfig(
995 10
				$this->getTranslator()->trans( 'item_name_donation', [], 'messages' ),
996 10
				$config['return-url'],
997
				$config['cancel-url'],
998
				$config['notification-url']
999
			),
1000 3
			$this->getSofortClient()
1001 3
		);
1002 3
	}
1003 3
1004 3
	public function setSofortClient( SofortClient $client ): void {
1005
		$this->pimple['sofort-client'] = $client;
1006
	}
1007
1008 5
	private function getSofortClient(): SofortClient {
1009 5
		return $this->pimple['sofort-client'];
1010 5
	}
1011
1012
	private function newCreditCardUrlGenerator(): CreditCardUrlGenerator {
1013
		return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() );
1014 11
	}
1015 11
1016 11
	private function newCreditCardUrlConfig(): CreditCardConfig {
1017 11
		return CreditCardConfig::newFromConfig( $this->config['creditcard'] );
1018 11
	}
1019 11
1020 11
	public function getDonationRepository(): DonationRepository {
1021 11
		return $this->pimple['donation_repository'];
1022 11
	}
1023
1024
	public function newPaymentDataValidator(): PaymentDataValidator {
1025
		return new PaymentDataValidator(
1026 11
			$this->config['donation-minimum-amount'],
1027 11
			$this->config['donation-maximum-amount'],
1028 11
			$this->getPaymentTypesSettings()->getEnabledForDonation()
1029 11
		);
1030 11
	}
1031 11
1032 11
	private function newAmountFormatter(): AmountFormatter {
1033
		return new AmountFormatter( $this->config['locale'] );
1034 11
	}
1035
1036
	public function newDecimalNumberFormatter(): NumberFormatter {
1037
		return new NumberFormatter( $this->config['locale'], NumberFormatter::DECIMAL );
1038 11
	}
1039 11
1040 11
	public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase {
1041 11
		return new AddCommentUseCase(
1042 11
			$this->getDonationRepository(),
1043
			$this->newDonationAuthorizer( $updateToken ),
1044
			$this->newCommentPolicyValidator(),
1045
			$this->newAddCommentValidator()
1046 11
		);
1047 11
	}
1048
1049
	private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer {
1050 11
		return new DoctrineDonationAuthorizer(
1051 11
			$this->getEntityManager(),
1052
			$updateToken,
1053
			$accessToken
1054 11
		);
1055 11
	}
1056
1057
	public function getDonationTokenGenerator(): TokenGenerator {
1058 2
		return $this->pimple['donation_token_generator'];
1059 2
	}
1060 2
1061 2
	public function getMembershipTokenGenerator(): MembershipTokenGenerator {
1062 2
		return $this->pimple['membership_token_generator'];
1063
	}
1064
1065
	public function newDonationConfirmationPresenter( string $templateName = 'Donation_Confirmation.html.twig' ): DonationConfirmationHtmlPresenter {
1066 3
		return new DonationConfirmationHtmlPresenter(
1067
			$this->getLayoutTemplate(
1068
				$templateName,
1069 3
				[
1070 3
					'piwikGoals' => [ 3 ],
1071
					'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForMembershipApplication()
1072
				]
1073
			),
1074
			$this->getUrlGenerator()
1075
		);
1076 14
	}
1077 14
1078
	public function newCreditCardPaymentUrlGenerator(): CreditCardPaymentUrlGenerator {
1079
		return new CreditCardPaymentUrlGenerator(
1080 2
			$this->getTranslator(),
1081 2
			$this->newCreditCardUrlGenerator()
1082 2
		);
1083 2
	}
1084 2
1085 2
	public function newCancelDonationHtmlPresenter(): CancelDonationHtmlPresenter {
1086 2
		return new CancelDonationHtmlPresenter(
1087
			$this->getLayoutTemplate( 'Donation_Cancellation_Confirmation.html.twig' )
1088 2
		);
1089
	}
1090
1091
	public function newApplyForMembershipUseCase(): ApplyForMembershipUseCase {
1092 1
		return new ApplyForMembershipUseCase(
1093 1
			$this->getMembershipApplicationRepository(),
1094 1
			$this->newMembershipApplicationTokenFetcher(),
1095 1
			$this->newApplyForMembershipMailer(),
1096
			$this->newMembershipApplicationValidator(),
1097
			$this->newApplyForMembershipPolicyValidator(),
1098
			$this->newMembershipApplicationTracker(),
1099 13
			$this->newMembershipApplicationPiwikTracker(),
1100 13
			$this->getPaymentDelayCalculator()
1101 13
		);
1102 13
	}
1103 13
1104
	private function newApplyForMembershipMailer(): TemplateMailerInterface {
1105
		return $this->newTemplateMailer(
1106
			$this->getOrganizationMessenger(),
1107 7
			new TwigTemplate(
1108 7
				$this->getMailerTwig(),
1109 7
				'Membership_Application_Confirmation.txt.twig',
1110
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
1111 10
			),
1112 10
			'mail_subject_confirm_membership_application'
1113
		);
1114
	}
1115 4
1116
	private function newMembershipApplicationValidator(): MembershipApplicationValidator {
1117
		return new MembershipApplicationValidator(
1118 4
			new MembershipFeeValidator(),
1119 4
			$this->newBankDataValidator(),
1120
			$this->getEmailValidator()
1121
		);
1122 15
	}
1123
1124
	private function newMembershipApplicationTracker(): ApplicationTracker {
1125 15
		return new DoctrineApplicationTracker( $this->getEntityManager() );
1126 15
	}
1127
1128
	private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker {
1129 4
		return new DoctrineApplicationPiwikTracker( $this->getEntityManager() );
1130 4
	}
1131 4
1132 4
	private function getPaymentDelayCalculator(): PaymentDelayCalculator {
1133 4
		return $this->pimple['payment-delay-calculator'];
1134 4
	}
1135
1136
	public function getPaymentDelayInDays(): int {
1137
		return $this->getPayPalUrlConfigForMembershipApplications()->getDelayInDays();
1138 7
	}
1139 7
1140
	public function setPaymentDelayCalculator( PaymentDelayCalculator $paymentDelayCalculator ): void {
1141
		$this->pimple['payment-delay-calculator'] = $paymentDelayCalculator;
1142 7
	}
1143 7
1144 7
	private function newApplyForMembershipPolicyValidator(): ApplyForMembershipPolicyValidator {
1145
		return new ApplyForMembershipPolicyValidator(
1146 2
			$this->newTextPolicyValidator( 'fields' ),
1147 2
			$this->config['email-address-blacklist']
1148 2
		);
1149 2
	}
1150 2
1151 2
	public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase {
1152 2
		return new CancelMembershipApplicationUseCase(
1153 2
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1154
			$this->getMembershipApplicationRepository(),
1155
			$this->newCancelMembershipApplicationMailer()
1156
		);
1157 2
	}
1158 2
1159 2
	private function newMembershipApplicationAuthorizer(
1160
		string $updateToken = null, string $accessToken = null ): ApplicationAuthorizer {
1161
1162
		return new DoctrineApplicationAuthorizer(
1163 1
			$this->getEntityManager(),
1164 1
			$updateToken,
1165 1
			$accessToken
1166
		);
1167
	}
1168
1169 2
	public function getMembershipApplicationRepository(): ApplicationRepository {
1170 2
		return $this->pimple['membership_application_repository'];
1171 2
	}
1172
1173
	private function newCancelMembershipApplicationMailer(): TemplateMailerInterface {
1174
		return $this->newTemplateMailer(
1175 2
			$this->getOrganizationMessenger(),
1176 2
			new TwigTemplate(
1177 2
				$this->getMailerTwig(),
1178
				'Membership_Application_Cancellation_Confirmation.txt.twig',
1179 2
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
1180 2
			),
1181
			'mail_subject_confirm_membership_application_cancellation'
1182
		);
1183 2
	}
1184 2
1185 2
	public function newMembershipApplicationConfirmationUseCase( string $accessToken ): ShowMembershipApplicationConfirmationUseCase {
1186 2
		return new ShowMembershipApplicationConfirmationUseCase(
1187 2
			$this->newMembershipApplicationAuthorizer( null, $accessToken ), $this->getMembershipApplicationRepository(),
1188 2
			$this->newMembershipApplicationTokenFetcher()
1189
		);
1190
	}
1191
1192
	public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase {
1193 90
		return new ShowDonationConfirmationUseCase(
1194 90
			$this->newDonationAuthorizer( null, $accessToken ),
1195 90
			$this->newDonationTokenFetcher(),
1196
			$this->getDonationRepository()
1197
		);
1198
	}
1199
1200
	public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ): void {
1201 90
		$this->pimple['confirmation-page-selector'] = $selector;
1202 90
	}
1203 90
1204
	public function getDonationConfirmationPageSelector(): DonationConfirmationPageSelector {
1205
		return $this->pimple['confirmation-page-selector'];
1206
	}
1207
1208
	public function newDonationFormViolationPresenter(): DonationFormViolationPresenter {
1209 21
		return new DonationFormViolationPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() );
1210 21
	}
1211 21
1212
	public function newDonationFormPresenter(): DonationFormPresenter {
1213
		return new DonationFormPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() );
1214
	}
1215
1216
	private function getDonationFormTemplate(): TwigTemplate {
1217 30
		// TODO make the template name dependent on the 'form' value from the HTTP POST request
1218 30
		// (we need different form pages for A/B testing)
1219 30
		return $this->getLayoutTemplate( 'Donation_Form.html.twig', [
1220
			'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForDonation()
1221
		] );
1222
	}
1223 12
1224 12
	public function getMembershipApplicationFormTemplate(): TwigTemplate {
1225 12
		return $this->getLayoutTemplate( 'Membership_Application.html.twig', [
1226
			'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForMembershipApplication()
1227
		] );
1228
	}
1229 20
1230 20
	public function newHandleSofortPaymentNotificationUseCase( string $updateToken ): SofortPaymentNotificationUseCase {
1231 20
		return new SofortPaymentNotificationUseCase(
1232 20
			$this->getDonationRepository(),
1233
			$this->newDonationAuthorizer( $updateToken ),
1234
			$this->newDonationConfirmationMailer()
1235
		);
1236 20
	}
1237
1238 20
	public function newHandlePayPalPaymentCompletionNotificationUseCase( string $updateToken ): HandlePayPalPaymentCompletionNotificationUseCase {
1239
		return new HandlePayPalPaymentCompletionNotificationUseCase(
1240
			$this->getDonationRepository(),
1241 2
			$this->newDonationAuthorizer( $updateToken ),
1242 2
			$this->newDonationConfirmationMailer(),
1243
			$this->newDonationEventLogger()
1244
		);
1245 2
	}
1246 2
1247 2
	public function newMembershipApplicationSubscriptionSignupNotificationUseCase( string $updateToken ): HandleSubscriptionSignupNotificationUseCase {
1248
		return new HandleSubscriptionSignupNotificationUseCase(
1249
			$this->getMembershipApplicationRepository(),
1250 2
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1251 2
			$this->newApplyForMembershipMailer(),
1252
			$this->getLogger()
1253
		);
1254 3
	}
1255 3
1256
	public function newMembershipApplicationSubscriptionPaymentNotificationUseCase( string $updateToken ): HandleSubscriptionPaymentNotificationUseCase {
1257
		return new HandleSubscriptionPaymentNotificationUseCase(
1258 112
			$this->getMembershipApplicationRepository(),
1259 112
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1260
			$this->newApplyForMembershipMailer(),
1261
			$this->getLogger()
1262 109
		);
1263 109
	}
1264
1265
	public function getPayPalPaymentNotificationVerifier(): PaymentNotificationVerifier {
1266
		return $this->pimple['paypal-payment-notification-verifier'];
1267
	}
1268
1269
	public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ): void {
1270
		$this->pimple['paypal-payment-notification-verifier'] = $verifier;
1271
	}
1272
1273
	public function getPayPalMembershipFeeNotificationVerifier(): PaymentNotificationVerifier {
1274
		return $this->pimple['paypal-membership-fee-notification-verifier'];
1275
	}
1276 118
1277 118
	public function setPayPalMembershipFeeNotificationVerifier( PaymentNotificationVerifier $verifier ): void {
1278 118
		$this->pimple['paypal-membership-fee-notification-verifier'] = $verifier;
1279
	}
1280
1281
	public function newCreditCardNotificationUseCase( string $updateToken ): CreditCardNotificationUseCase {
1282
		return new CreditCardNotificationUseCase(
1283
			$this->getDonationRepository(),
1284
			$this->newDonationAuthorizer( $updateToken ),
1285
			$this->getCreditCardService(),
1286
			$this->newDonationConfirmationMailer(),
1287
			$this->getLogger(),
1288
			$this->newDonationEventLogger()
1289
		);
1290 2
	}
1291 2
1292 2
	public function newCancelMembershipApplicationHtmlPresenter(): CancelMembershipApplicationHtmlPresenter {
1293
		return new CancelMembershipApplicationHtmlPresenter(
1294
			$this->getLayoutTemplate( 'Membership_Application_Cancellation_Confirmation.html.twig' )
1295
		);
1296
	}
1297
1298 2
	public function newMembershipApplicationConfirmationHtmlPresenter(): MembershipApplicationConfirmationHtmlPresenter {
1299 2
		return new MembershipApplicationConfirmationHtmlPresenter(
1300 2
			$this->getLayoutTemplate( 'Membership_Application_Confirmation.html.twig' )
1301
		);
1302
	}
1303
1304
	public function newMembershipFormViolationPresenter(): MembershipFormViolationPresenter {
1305
		return new MembershipFormViolationPresenter(
1306 31
			$this->getMembershipApplicationFormTemplate()
1307 31
		);
1308
	}
1309
1310 109
	public function setCreditCardService( CreditCardService $ccService ): void {
1311 109
		$this->pimple['credit-card-api-service'] = $ccService;
1312
	}
1313
1314 109
	public function getCreditCardService(): CreditCardService {
1315 109
		return $this->pimple['credit-card-api-service'];
1316 109
	}
1317 109
1318
	public function newCreditCardNotificationPresenter(): CreditCardNotificationPresenter {
1319
		return new CreditCardNotificationPresenter(
1320
			new TwigTemplate(
1321
				$this->getSkinTwig(),
1322 2
				'Credit_Card_Payment_Notification.txt.twig',
1323 2
				[ 'returnUrl' => $this->config['creditcard']['return-url'] ]
1324 2
			)
1325 2
		);
1326 2
	}
1327
1328
	private function newDoctrineDonationPrePersistSubscriber(): DoctrineDonationPrePersistSubscriber {
1329
		return new DoctrineDonationPrePersistSubscriber(
1330 11
			$this->getDonationTokenGenerator(),
1331 11
			$this->getDonationTokenGenerator()
1332
		);
1333
	}
1334
1335 1
	private function newDoctrineMembershipApplicationPrePersistSubscriber(): DoctrineMembershipApplicationPrePersistSubscriber {
1336 1
		return new DoctrineMembershipApplicationPrePersistSubscriber(
1337
			$this->getMembershipTokenGenerator(),
1338 2
			$this->getMembershipTokenGenerator()
1339
		);
1340 1
	}
1341 1
1342
	public function setDonationTokenGenerator( TokenGenerator $tokenGenerator ): void {
1343
		$this->pimple['donation_token_generator'] = $tokenGenerator;
1344
	}
1345
1346
	public function setMembershipTokenGenerator( MembershipTokenGenerator $tokenGenerator ): void {
1347
		$this->pimple['membership_token_generator'] = $tokenGenerator;
1348
	}
1349
1350
	public function disableDoctrineSubscribers(): void {
1351
		$this->addDoctrineSubscribers = false;
1352
	}
1353
1354
	private function newDonationTokenFetcher(): DonationTokenFetcher {
1355
		return new DoctrineDonationTokenFetcher(
1356
			$this->getEntityManager()
1357
		);
1358
	}
1359
1360
	private function newMembershipApplicationTokenFetcher(): ApplicationTokenFetcher {
1361
		return new DoctrineApplicationTokenFetcher(
1362
			$this->getEntityManager()
1363
		);
1364
	}
1365
1366
	private function newDonationPolicyValidator(): AddDonationPolicyValidator {
1367
		return new AddDonationPolicyValidator(
1368
			$this->newDonationAmountPolicyValidator(),
1369
			$this->newTextPolicyValidator( 'fields' ),
1370
			$this->config['email-address-blacklist']
1371
		);
1372
	}
1373
1374
	private function newDonationAmountPolicyValidator(): AmountPolicyValidator {
1375
		// in the future, this might come from the configuration
1376
		return new AmountPolicyValidator( 1000, 1000 );
1377
	}
1378
1379
	public function getDonationTimeframeLimit(): string {
1380
		return $this->config['donation-timeframe-limit'];
1381
	}
1382
1383
	public function newSystemMessageResponse( string $message ): string {
1384
		return $this->getLayoutTemplate( 'System_Message.html.twig' )
1385
			->render( [ 'message' => $message ] );
1386
	}
1387
1388
	public function getMembershipApplicationTimeframeLimit(): string {
1389
		return $this->config['membership-application-timeframe-limit'];
1390
	}
1391
1392
	private function newAddCommentValidator(): AddCommentValidator {
1393
		return new AddCommentValidator();
1394
	}
1395
1396
	private function getPageCache(): Cache {
1397
		return $this->pimple['page_cache'];
1398
	}
1399
1400
	private function getRenderedPageCache(): Cache {
1401
		return $this->pimple['rendered_page_cache'];
1402
	}
1403
1404
	public function enablePageCache(): void {
1405
		$this->pimple['page_cache'] = function() {
1406
			return new FilesystemCache( $this->getCachePath() . '/pages/raw' );
1407
		};
1408
1409
		$this->pimple['rendered_page_cache'] = function() {
1410
			return new FilesystemCache( $this->getCachePath() . '/pages/rendered' );
1411
		};
1412
	}
1413
1414
	private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) {	// @codingStandardsIgnoreLine
1415
		if ( $this->profiler === null ) {
1416
			return $objectToDecorate;
1417
		}
1418
1419
		$builder = new ProfilingDecoratorBuilder( $this->profiler, $this->getProfilerDataCollector() );
1420
1421
		return $builder->decorate( $objectToDecorate, $profilingLabel );
1422
	}
1423
1424
	public function setProfiler( Stopwatch $profiler ): void {
1425
		$this->profiler = $profiler;
1426
	}
1427
1428
	public function setEmailValidator( EmailValidator $validator ): void {
1429
		$this->pimple['mail_validator'] = $validator;
1430
	}
1431
1432
	public function setLogger( LoggerInterface $logger ): void {
1433
		$this->pimple['logger'] = $logger;
1434
	}
1435
1436
	public function setPaypalLogger( LoggerInterface $logger ): void {
1437
		$this->pimple['paypal_logger'] = $logger;
1438
	}
1439
1440
	public function setSofortLogger( LoggerInterface $logger ): void {
1441
		$this->pimple['sofort_logger'] = $logger;
1442
	}
1443
1444
	public function getProfilerDataCollector(): ProfilerDataCollector {
1445
		return $this->pimple['profiler_data_collector'];
1446
	}
1447
1448
	private function newIbanValidator(): KontoCheckIbanValidator {
1449
		return new KontoCheckIbanValidator( $this->newBankDataConverter(), $this->config['banned-ibans'] );
1450
	}
1451
1452
	public function setFilePrefixer( FilePrefixer $prefixer ): void {
1453
		$this->pimple['cachebusting_fileprefixer'] = $prefixer;
1454
	}
1455
1456
	private function getFilePrefixer(): FilePrefixer {
1457
		return $this->pimple['cachebusting_fileprefixer'];
1458
	}
1459
1460
	private function getFilePrefix(): string {
1461
		$prefixContentFile = $this->getVarPath() . '/file_prefix.txt';
1462
		if ( !file_exists( $prefixContentFile ) ) {
1463
			return '';
1464
		}
1465
		return $prefix = preg_replace( '/[^0-9a-f]/', '', file_get_contents( $prefixContentFile ) );
0 ignored issues
show
Unused Code introduced by
$prefix is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1466
	}
1467
1468
	public function newDonationAcceptedEventHandler( string $updateToken ): DonationAcceptedEventHandler {
1469
		return new DonationAcceptedEventHandler(
1470
			$this->newDonationAuthorizer( $updateToken ),
1471
			$this->getDonationRepository(),
1472
			$this->newDonationConfirmationMailer()
1473
		);
1474
	}
1475
1476
	public function newPageNotFoundHtmlPresenter(): PageNotFoundPresenter {
1477
		return new PageNotFoundPresenter( $this->getLayoutTemplate( 'Page_not_found.html.twig' ) );
1478
	}
1479
1480
	public function setPageViewTracker( PageViewTracker $tracker ): void {
1481
		$this->pimple['page_view_tracker'] = function () use ( $tracker )  {
1482
			return $tracker;
1483
		};
1484
	}
1485
1486
	public function getPageViewTracker(): PageViewTracker {
1487
		return $this->pimple['page_view_tracker'];
1488
	}
1489
1490
	public function newServerSideTracker(): ServerSideTracker {
1491
		// the "https:" prefix does NOT get any slashes because baseURL is stored in a protocol-agnostic way
1492
		// (e.g. "//tracking.wikimedia.de" )
1493
		return new PiwikServerSideTracker(
1494
			new \PiwikTracker( $this->config['piwik']['siteId'], 'https:' . $this->config['piwik']['baseUrl'] )
1495
		);
1496
	}
1497
1498
	public function getI18nDirectory(): string {
1499
		return $this->getAbsolutePath( $this->config['i18n-base-path'] ) . '/' . $this->config['locale'];
1500
	}
1501
1502
	/**
1503
	 * If the pathname does not start with a slash, make the path absolute to root dir of application
1504
	 */
1505
	private function getAbsolutePath( string $path ): string {
1506
		if ( $path[0] === '/' ) {
1507
			return $path;
1508
		}
1509
		return __DIR__ . '/../../' . $path;
1510
	}
1511
1512
	public function setContentPagePageSelector( PageSelector $pageSelector ): void {
1513
		$this->pimple['content_page_selector'] = $pageSelector;
1514
	}
1515
1516
	public function getContentPagePageSelector(): PageSelector {
1517
		return $this->pimple['content_page_selector'];
1518
	}
1519
1520
	public function setContentProvider( ContentProvider $contentProvider ): void {
1521
		$this->pimple['content_provider'] = $contentProvider;
1522
	}
1523
1524
	private function getContentProvider(): ContentProvider {
1525
		return $this->pimple['content_provider'];
1526
	}
1527
1528
	public function newMailTemplateFilenameTraversable(): MailTemplateFilenameTraversable {
1529
		return new MailTemplateFilenameTraversable(
1530
			$this->config['mailer-twig']['loaders']['filesystem']['template-dir']
1531
		);
1532
	}
1533
1534
	public function getUrlGenerator(): UrlGenerator {
1535
		return $this->pimple['url_generator'];
1536
	}
1537
1538
	public function setUrlGenerator( UrlGenerator $urlGenerator ): void {
1539
		$this->pimple['url_generator'] = $urlGenerator;
1540
	}
1541
1542
	public function getCookieBuilder(): CookieBuilder {
1543
		return $this->pimple['cookie-builder'];
1544
	}
1545
1546
	public function getSkinSettings(): SkinSettings {
1547
		return $this->pimple['skin-settings'];
1548
	}
1549
1550
	public function getPaymentTypesSettings(): PaymentTypesSettings {
1551
		return $this->pimple['payment-types-settings'];
1552
	}
1553
1554
	public function newDonationAmountConstraint(): ValidatorConstraint {
1555
		return new RequiredConstraint( [
1556
			new TypeConstraint( [ 'type' => 'digit' ] ),
1557
			new RangeConstraint( [
1558
				'min' => Euro::newFromInt( $this->config['donation-minimum-amount'] )->getEuroCents(),
1559
				'max' => Euro::newFromInt( $this->config['donation-maximum-amount'] )->getEuroCents()
1560
			] )
1561
		] );
1562
	}
1563
}
1564