Completed
Pull Request — master (#1169)
by wiese
212:02 queued 146:54
created

setPayPalPaymentNotificationVerifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 1
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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\Required as RequiredConstraint;
27
use Symfony\Component\Validator\Constraints\Type as TypeConstraint;
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\GetDonation\GetDonationUseCase;
63
use WMDE\Fundraising\Frontend\DonationContext\UseCases\HandlePayPalPaymentNotification\HandlePayPalPaymentCompletionNotificationUseCase;
64
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ListComments\ListCommentsUseCase;
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\ShowApplicationConfirmation\ShowApplicationConfirmationPresenter;
108
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ShowApplicationConfirmation\ShowApplicationConfirmationUseCase;
109
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\McpCreditCardService;
110
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\Sofort\Transfer\Client as SofortClient;
111
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\UniqueTransferCodeGenerator;
112
use WMDE\Fundraising\Frontend\PaymentContext\Domain\BankDataConverter;
113
use WMDE\Fundraising\Frontend\PaymentContext\Domain\BankDataValidator;
114
use WMDE\Fundraising\Frontend\PaymentContext\Domain\DefaultPaymentDelayCalculator;
115
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentDataValidator;
116
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentDelayCalculator;
117
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\CreditCard as CreditCardUrlGenerator;
118
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\CreditCardConfig;
119
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\PayPal as PayPalUrlGenerator;
120
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\PayPalConfig;
121
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\Sofort as SofortUrlGenerator;
122
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\SofortConfig;
123
use WMDE\Fundraising\Frontend\PaymentContext\Domain\SimpleTransferCodeGenerator;
124
use WMDE\Fundraising\Frontend\PaymentContext\Domain\TransferCodeGenerator;
125
use WMDE\Fundraising\Frontend\PaymentContext\Infrastructure\CreditCardService;
126
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\CheckIban\CheckIbanUseCase;
127
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\GenerateIban\GenerateIbanUseCase;
128
use WMDE\Fundraising\Frontend\Presentation\AmountFormatter;
129
use WMDE\Fundraising\Frontend\Presentation\ContentPage\PageSelector;
130
use WMDE\Fundraising\Frontend\Presentation\DonationConfirmationPageSelector;
131
use WMDE\Fundraising\Frontend\Presentation\FilePrefixer;
132
use WMDE\Fundraising\Frontend\Presentation\GreetingGenerator;
133
use WMDE\Fundraising\Frontend\Presentation\Honorifics;
134
use WMDE\Fundraising\Frontend\Presentation\PaymentTypesSettings;
135
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionHtmlPresenter;
136
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionJsonPresenter;
137
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelDonationHtmlPresenter;
138
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelMembershipApplicationHtmlPresenter;
139
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListHtmlPresenter;
140
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListJsonPresenter;
141
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListRssPresenter;
142
use WMDE\Fundraising\Frontend\Presentation\Presenters\ConfirmSubscriptionHtmlPresenter;
143
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardNotificationPresenter;
144
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardPaymentUrlGenerator;
145
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationConfirmationHtmlPresenter;
146
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormPresenter;
147
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormViolationPresenter;
148
use WMDE\Fundraising\Frontend\Presentation\Presenters\GetInTouchHtmlPresenter;
149
use WMDE\Fundraising\Frontend\Presentation\Presenters\IbanPresenter;
150
use WMDE\Fundraising\Frontend\Presentation\Presenters\InternalErrorHtmlPresenter;
151
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipApplicationConfirmationHtmlPresenter;
152
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipFormViolationPresenter;
153
use WMDE\Fundraising\Frontend\Presentation\Presenters\PageNotFoundPresenter;
154
use WMDE\Fundraising\Frontend\Presentation\SkinSettings;
155
use WMDE\Fundraising\Frontend\Presentation\TwigTemplate;
156
use WMDE\Fundraising\Frontend\SubscriptionContext\DataAccess\DoctrineSubscriptionRepository;
157
use WMDE\Fundraising\Frontend\SubscriptionContext\Domain\Repositories\SubscriptionRepository;
158
use WMDE\Fundraising\Frontend\SubscriptionContext\Infrastructure\LoggingSubscriptionRepository;
159
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\AddSubscription\AddSubscriptionUseCase;
160
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\ConfirmSubscription\ConfirmSubscriptionUseCase;
161
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionDuplicateValidator;
162
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionValidator;
163
use WMDE\Fundraising\Frontend\UseCases\GetInTouch\GetInTouchUseCase;
164
use WMDE\Fundraising\Frontend\Validation\GetInTouchValidator;
165
use WMDE\Fundraising\Frontend\Validation\KontoCheckIbanValidator;
166
use WMDE\Fundraising\Frontend\Validation\MembershipFeeValidator;
167
use WMDE\Fundraising\Frontend\Validation\TemplateNameValidator;
168
use WMDE\Fundraising\Store\Factory as StoreFactory;
169
use WMDE\Fundraising\Store\Installer;
170
use WMDE\FunValidators\Validators\AllowedValuesValidator;
171
use WMDE\FunValidators\Validators\AmountPolicyValidator;
172
use WMDE\FunValidators\Validators\EmailValidator;
173
use WMDE\FunValidators\Validators\TextPolicyValidator;
174
175
/**
176
 * @licence GNU GPL v2+
177 160
 */
178 160
class FunFunFactory {
179 160
180 160
	private $config;
181
182 160
	/**
183 160
	 * @var Container
184
	 */
185
	private $pimple;
186 119
187
	private $addDoctrineSubscribers = true;
188
189
	/**
190 4
	 * @var Stopwatch|null
191
	 */
192
	private $profiler = null;
193
194
	public function __construct( array $config ) {
195
		$this->config = $config;
196
		$this->pimple = $this->newPimple();
197
	}
198 160
199
	private function newPimple(): Container {
200
		$pimple = new Container();
201
202 90
		$pimple['logger'] = function() {
203 90
			return new NullLogger();
204 90
		};
205 90
206 90
		$pimple['paypal_logger'] = function() {
207
			return new NullLogger();
208
		};
209 90
210
		$pimple['sofort_logger'] = function() {
211
			return new NullLogger();
212
		};
213 9
214 9
		$pimple['profiler_data_collector'] = function() {
215 9
			return new ProfilerDataCollector();
216
		};
217
218
		$pimple['dbal_connection'] = function() {
219
			return DriverManager::getConnection( $this->config['db'] );
220 47
		};
221 47
222 47
		$pimple['entity_manager'] = function() {
223
			$entityManager = ( new StoreFactory( $this->getConnection(), $this->getVarPath() . '/doctrine_proxies' ) )
224
				->getEntityManager();
225
			if ( $this->addDoctrineSubscribers ) {
226
				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() );
227 14
				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() );
228 14
			}
229 14
230
			return $entityManager;
231
		};
232
233
		$pimple['subscription_repository'] = function() {
234 12
			return new LoggingSubscriptionRepository(
235 12
				new DoctrineSubscriptionRepository( $this->getEntityManager() ),
236 12
				$this->getLogger()
237
			);
238
		};
239 12
240
		$pimple['donation_repository'] = function() {
241
			return new LoggingDonationRepository(
242
				new DoctrineDonationRepository( $this->getEntityManager() ),
243 44
				$this->getLogger()
244
			);
245
		};
246
247 7
		$pimple['membership_application_repository'] = function() {
248 7
			return new LoggingApplicationRepository(
249 7
				new DoctrineApplicationRepository( $this->getEntityManager() ),
250 7
				$this->getLogger()
251 7
			);
252
		};
253
254
		$pimple['comment_repository'] = function() {
255
			$finder = new LoggingCommentFinder(
256 8
				new DoctrineCommentFinder( $this->getEntityManager() ),
257
				$this->getLogger()
258
			);
259
260 3
			return $this->addProfilingDecorator( $finder, 'CommentFinder' );
261
		};
262
263
		$pimple['mail_validator'] = function() {
264 56
			return new EmailValidator( new InternetDomainNameValidator() );
265
		};
266
267
		$pimple['subscription_validator'] = function() {
268 102
			return new SubscriptionValidator(
269 102
				$this->getEmailValidator(),
270 102
				$this->newTextPolicyValidator( 'fields' ),
271
				$this->newSubscriptionDuplicateValidator(),
272
				$this->newHonorificValidator()
273
			);
274
		};
275 102
276 102
		$pimple['template_name_validator'] = function() {
277
			return new TemplateNameValidator( $this->getSkinTwig() );
278 102
		};
279 102
280
		$pimple['contact_validator'] = function() {
281 102
			return new GetInTouchValidator( $this->getEmailValidator() );
282 102
		};
283 102
284
		$pimple['greeting_generator'] = function() {
285
			return new GreetingGenerator();
286
		};
287 102
288
		$pimple['translator'] = function() {
289
			$translationFactory = new TranslationFactory();
290
			$loaders = [
291 114
				'json' => $translationFactory->newJsonLoader()
292
			];
293 114
			$locale = $this->config['locale'];
294
			$messagesPath = $this->getI18nDirectory() . $this->config['translation']['message-dir'];
295 114
			$translator = $translationFactory->create( $loaders, $locale );
296 114
			foreach ($this->config['translation']['files'] as $domain => $file) {
297 114
				$translator->addResource( 'json', $messagesPath . '/' . $file, $locale, $domain );
298 114
			}
299 114
300
			return $translator;
301
		};
302
303 114
		// In the future, this could be locale-specific or filled from a DB table
304 114
		$pimple['honorifics'] = function() {
305 114
			return new Honorifics( [
306
				'' => 'Kein Titel',
307 114
				'Dr.' => 'Dr.',
308
				'Prof.' => 'Prof.',
309
				'Prof. Dr.' => 'Prof. Dr.'
310 114
			] );
311 114
		};
312 114
313
		$pimple['twig'] = function() {
314 114
			$config = $this->config['twig'];
315
			$config['loaders']['filesystem']['template-dir'] = 'skins/' . $this->getSkinSettings()->getSkin() . '/templates';
316
317 114
			$twigFactory = $this->newTwigFactory( $config );
318 114
			$configurator = $twigFactory->newTwigEnvironmentConfigurator();
319 114
320
			$loaders = array_filter( [
321 114
				$twigFactory->newFileSystemLoader(),
322
				$twigFactory->newArrayLoader(), // This is just a fallback for testing
323
			] );
324 114
			$extensions = [
325 114
				$twigFactory->newTranslationExtension( $this->getTranslator() ),
326 114
				new Twig_Extensions_Extension_Intl()
327
			];
328 114
			$filters = [
329
				$twigFactory->newFilePrefixFilter(
330
					$this->getFilePrefixer()
331 114
				)
332
			];
333
			$functions = [
334
				new Twig_SimpleFunction(
335
					'web_content',
336 78
					function( string $name, array $context = [] ): string {
337 78
						return $this->getContentProvider()->getWeb( $name, $context );
338
					},
339
					[ 'is_safe' => [ 'html' ] ]
340
				),
341
			];
342
343
			return $configurator->getEnvironment( $this->pimple['skin_twig_environment'], $loaders, $extensions, $filters, $functions );
344
		};
345 109
346
		$pimple['mailer_twig'] = function() {
347
			$twigFactory = $this->newTwigFactory( $this->config['mailer-twig'] );
348
			$configurator = $twigFactory->newTwigEnvironmentConfigurator();
349 109
350 109
			$loaders = array_filter( [
351 109
				$twigFactory->newFileSystemLoader(),
352 109
				$twigFactory->newArrayLoader(), // This is just a fallback for testing
353 109
			] );
354 109
			$extensions = [
355 109
				$twigFactory->newTranslationExtension( $this->getTranslator() ),
356
				new Twig_Extensions_Extension_Intl(),
357
			];
358
			$filters = [];
359 109
			$functions = [
360 109
				new Twig_SimpleFunction(
361
					'mail_content',
362
					function( string $name, array $context = [] ): string {
363 109
						return $this->getContentProvider()->getMail( $name, $context );
364 109
					},
365
					[ 'is_safe' => [ 'all' ] ]
366
				),
367
				new Twig_SimpleFunction(
368 109
					'url',
369
					function( string $name, array $parameters = [] ): string {
370
						return $this->getUrlGenerator()->generateUrl( $name, $parameters );
371
					}
372
				)
373
			];
374
375
			$twigEnvironment = new Twig_Environment();
376
377
			return $configurator->getEnvironment( $twigEnvironment, $loaders, $extensions, $filters, $functions );
378
		};
379
380
		$pimple['messenger_suborganization'] = function() {
381
			return new Messenger(
382
				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...
383
				$this->getSubOrganizationEmailAddress(),
384
				$this->config['contact-info']['suborganization']['name']
385
			);
386
		};
387
388 6
		$pimple['messenger_organization'] = function() {
389
			return new Messenger(
390
				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...
391
				$this->getOrganizationEmailAddress(),
392
				$this->config['contact-info']['organization']['name']
393
			);
394
		};
395
396
		$pimple['confirmation-page-selector'] = function() {
397
			return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] );
398
		};
399
400
		$pimple['paypal-payment-notification-verifier'] = function() {
401
			return new LoggingPaymentNotificationVerifier(
402
				new PayPalPaymentNotificationVerifier(
403
					new Client(),
404
					$this->config['paypal-donation']['base-url'],
405
					$this->config['paypal-donation']['account-address']
406
				),
407
				$this->getLogger()
408
			);
409
		};
410
411
		$pimple['paypal-membership-fee-notification-verifier'] = function() {
412
			return new LoggingPaymentNotificationVerifier(
413
				new PayPalPaymentNotificationVerifier(
414 69
					new Client(),
415 69
					$this->config['paypal-membership']['base-url'],
416 69
					$this->config['paypal-membership']['account-address']
417
				),
418
				$this->getLogger()
419
			);
420
		};
421 112
422
		$pimple['credit-card-api-service'] = function() {
423
			return new McpCreditCardService(
424
				new TNvpServiceDispatcher(
425 109
					'IMcpCreditcardService_v1_5',
426
					'https://sipg.micropayment.de/public/creditcard/v1.5/nvp/'
427
				),
428
				$this->config['creditcard']['access-key'],
429
				$this->config['creditcard']['testmode']
430
			);
431
		};
432 160
433
		$pimple['donation_token_generator'] = function() {
434
			return new RandomTokenGenerator(
435 160
				$this->config['token-length'],
436 160
				new \DateInterval( $this->config['token-validity-timestamp'] )
437
			);
438
		};
439 90
440 90
		$pimple['membership_token_generator'] = function() {
441
			return new RandomMembershipTokenGenerator(
442
				$this->config['token-length'],
443 11
				new \DateInterval( $this->config['token-validity-timestamp'] )
444 11
			);
445 11
		};
446 11
447
		$pimple['page_cache'] = function() {
448
			return new VoidCache();
449
		};
450 160
451 160
		$pimple['rendered_page_cache'] = function() {
452
			return new VoidCache();
453
		};
454 12
455 12
		$pimple['page_view_tracker'] = function () {
456
			return new PageViewTracker( $this->newServerSideTracker(), $this->config['piwik']['siteUrlBase'] );
457
		};
458 6
459 6
		$pimple['cachebusting_fileprefixer'] = function () {
460
			return new FilePrefixer( $this->getFilePrefix() );
461
		};
462 2
463 2
		$pimple['content_page_selector'] = function () {
464 2
			$json = (new SimpleFileFetcher())->fetchFile( $this->getI18nDirectory() . '/data/pages.json' );
465 2
			$config = json_decode( $json, true ) ?? [];
466
467
			return new PageSelector( $config );
468
		};
469 4
470 4
		$pimple['content_provider'] = function () {
471
			return new ContentProvider( [
472
				'content_path' => $this->getI18nDirectory(),
473 12
				'cache' => $this->config['twig']['enable-cache'] ? $this->getCachePath() . '/content' : false,
474 12
				'globals' => [
475
					'basepath' => $this->config['web-basepath']
476
				]
477 10
			] );
478 10
		};
479
480
		$pimple['payment-delay-calculator'] = function() {
481 1
			return new DefaultPaymentDelayCalculator( $this->getPaymentDelayInDays() );
482 1
		};
483 1
484
		$pimple['sofort-client'] = function () {
485 7
			$config = $this->config['sofort'];
486 7
			return new SofortClient( $config['config-key'] );
487
		};
488
489 46
		$pimple['cookie-builder'] = function (): CookieBuilder {
490 46
			return new CookieBuilder(
491
				$this->config['cookie']['expiration'],
492
				$this->config['cookie']['path'],
493 8
				$this->config['cookie']['domain'],
494 8
				$this->config['cookie']['secure'],
495
				$this->config['cookie']['httpOnly'],
496
				$this->config['cookie']['raw'],
497 1
				$this->config['cookie']['sameSite']
498 1
			);
499
		};
500
501 3
		$pimple['skin-settings'] = function (): SkinSettings {
502 3
			$config = $this->config['skin'];
503 3
			return new SkinSettings( $config['options'], $config['default'], $config['cookie-lifetime'] );
504 3
		};
505
506
		$pimple['payment-types-settings'] = function (): PaymentTypesSettings {
507
			return new PaymentTypesSettings( $this->config['payment-types'] );
508 3
		};
509 3
510
		return $pimple;
511
	}
512 1
513 1
	public function getConnection(): Connection {
514
		return $this->pimple['dbal_connection'];
515
	}
516 160
517 160
	public function getEntityManager(): EntityManager {
518 160
		return $this->pimple['entity_manager'];
519
	}
520 109
521 109
	private function newDonationEventLogger(): DonationEventLogger {
522
		return new BestEffortDonationEventLogger(
523
			new DoctrineDonationEventLogger( $this->getEntityManager() ),
524
			$this->getLogger()
525
		);
526
	}
527
528
	public function newInstaller(): Installer {
529
		return ( new StoreFactory( $this->getConnection() ) )->newInstaller();
530
	}
531 43
532 43
	public function newListCommentsUseCase(): ListCommentsUseCase {
533 43
		return new ListCommentsUseCase( $this->getCommentFinder() );
534
	}
535 43
536
	public function newCommentListJsonPresenter(): CommentListJsonPresenter {
537
		return new CommentListJsonPresenter();
538
	}
539
540
	public function newCommentListRssPresenter(): CommentListRssPresenter {
541
		return new CommentListRssPresenter( new TwigTemplate(
542
			$this->getSkinTwig(),
543
			'Comment_List.rss.twig'
544
		) );
545 30
	}
546 30
547 30
	public function newCommentListHtmlPresenter(): CommentListHtmlPresenter {
548 30
		return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'Comment_List.html.twig', [ 'piwikGoals' => [ 1 ] ] ) );
549
	}
550 30
551 30
	private function getCommentFinder(): CommentFinder {
552
		return $this->pimple['comment_repository'];
553
	}
554
555
	public function getSubscriptionRepository(): SubscriptionRepository {
556
		return $this->pimple['subscription_repository'];
557 72
	}
558
559 72
	public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ): void {
560 72
		$this->pimple['subscription_repository'] = $subscriptionRepository;
561 72
	}
562 72
563 72
	private function getSubscriptionValidator(): SubscriptionValidator {
564 72
		return $this->pimple['subscription_validator'];
565
	}
566
567
	public function getEmailValidator(): EmailValidator {
568 20
		return $this->pimple['mail_validator'];
569 20
	}
570 20
571 20
	public function getTemplateNameValidator(): TemplateNameValidator {
572
		return $this->pimple['template_name_validator'];
573
	}
574
575 112
	public function newAddSubscriptionHtmlPresenter(): AddSubscriptionHtmlPresenter {
576 112
		return new AddSubscriptionHtmlPresenter( $this->getLayoutTemplate( 'Subscription_Form.html.twig' ), $this->getTranslator() );
577
	}
578
579 10
	public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter {
580 10
		return new ConfirmSubscriptionHtmlPresenter(
581 10
			$this->getLayoutTemplate( 'Confirm_Subscription.twig' ),
582
			$this->getTranslator()
583 102
		);
584 102
	}
585
586
	public function newAddSubscriptionJsonPresenter(): AddSubscriptionJsonPresenter {
587 112
		return new AddSubscriptionJsonPresenter( $this->getTranslator() );
588 112
	}
589 112
590 112
	public function newGetInTouchHtmlPresenter(): GetInTouchHtmlPresenter {
591
		return new GetInTouchHtmlPresenter( $this->getLayoutTemplate( 'contact_form.html.twig' ), $this->getTranslator() );
592
	}
593 112
594
	public function setSkinTwigEnvironment( Twig_Environment $twig ): void {
595
		$this->pimple['skin_twig_environment'] = $twig;
596 109
	}
597 109
598 109
	public function getSkinTwig(): Twig_Environment {
599 109
		return $this->pimple['twig'];
600
	}
601
602 109
	public function getMailerTwig(): Twig_Environment {
603
		return $this->pimple['mailer_twig'];
604
	}
605 112
606 112
	/**
607 112
	 * Get a template, with the content for the layout areas filled in.
608 112
	 *
609 112
	 * @param string $templateName
610 112
	 * @param array $context Additional variables for the template
611 112
	 * @return TwigTemplate
612
	 */
613
	public function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate {
614
		 return new TwigTemplate(
615 109
			$this->getSkinTwig(),
616 109
			$templateName,
617 109
			array_merge( $this->getDefaultTwigVariables(), $context )
618 109
		);
619 109
	}
620 109
621 109
	public function getMailerTemplate( string $templateName, array $context = [] ): TwigTemplate {
622
		return new TwigTemplate(
623
			$this->getMailerTwig(),
624
			$templateName,
625 119
			array_merge( $this->getDefaultTwigVariables(), $context )
626 119
		);
627
	}
628
629 6
	private function getDefaultTwigVariables(): array {
630 6
		return [
631
			'honorifics' => $this->getHonorifics()->getList(),
632
			'header_template' => $this->config['default-layout-templates']['header'],
633 127
			'footer_template' => $this->config['default-layout-templates']['footer'],
634 127
			'no_js_notice_template' => $this->config['default-layout-templates']['no-js-notice'],
635
			'piwik' => $this->config['piwik'],
636
			'locale' => $this->config['locale'],
637 109
		];
638 109
	}
639
640
	private function newReferrerGeneralizer(): ReferrerGeneralizer {
641
		return new ReferrerGeneralizer(
642
			$this->config['referrer-generalization']['default'],
643
			$this->config['referrer-generalization']['domain-map']
644
		);
645
	}
646
647
	public function getLogger(): LoggerInterface {
648
		return $this->pimple['logger'];
649 7
	}
650 7
651 7
	public function getPaypalLogger(): LoggerInterface {
652 7
		return $this->pimple['paypal_logger'];
653 7
	}
654
655
	public function getSofortLogger(): LoggerInterface {
656
		return $this->pimple['sofort_logger'];
657 3
	}
658 3
659 3
	private function getVarPath(): string {
660 3
		return __DIR__ . '/../../var';
661
	}
662
663
	public function getCachePath(): string {
664 7
		return $this->getVarPath() . '/cache';
665 7
	}
666 7
667 7
	public function getLoggingPath(): string {
668 7
		return $this->getVarPath() . '/log';
669 7
	}
670
671 7
	public function newAddSubscriptionUseCase(): AddSubscriptionUseCase {
672 7
		return new AddSubscriptionUseCase(
673
			$this->getSubscriptionRepository(),
674
			$this->getSubscriptionValidator(),
675 7
			$this->newAddSubscriptionMailer()
676
		);
677
	}
678
679 3
	public function newConfirmSubscriptionUseCase(): ConfirmSubscriptionUseCase {
680 3
		return new ConfirmSubscriptionUseCase(
681 3
			$this->getSubscriptionRepository(),
682 3
			$this->newConfirmSubscriptionMailer()
683 3
		);
684 3
	}
685 3
686
	private function newAddSubscriptionMailer(): TemplateMailerInterface {
687 3
		return $this->newTemplateMailer(
688
			$this->getSuborganizationMessenger(),
689
			new TwigTemplate(
690
				$this->getMailerTwig(),
691 59
				'Subscription_Request.txt.twig',
692 59
				[
693
					'greeting_generator' => $this->getGreetingGenerator()
694
				]
695 59
			),
696
			'mail_subject_subscription'
697
		);
698 59
	}
699
700 59
	private function newConfirmSubscriptionMailer(): TemplateMailerInterface {
701
		return $this->newTemplateMailer(
702
			$this->getSuborganizationMessenger(),
703 56
			new TwigTemplate(
704 56
					$this->getMailerTwig(),
705
					'Subscription_Confirmation.txt.twig',
706
					[ 'greeting_generator' => $this->getGreetingGenerator() ]
707
			),
708
			'mail_subject_subscription_confirmed'
709
		);
710
	}
711
712
	/**
713
	 * Create a new TemplateMailer instance
714
	 *
715
	 * So much decoration going on that explicitly hinting what we return (Robustness principle) would be confusing
716
	 * (you'd expect a TemplateBasedMailer, not a LoggingMailer), so we hint the interface instead.
717
	 */
718
	private function newTemplateMailer( Messenger $messenger, TwigTemplate $template, string $messageKey ): TemplateMailerInterface {
719 31
		$mailer = new TemplateBasedMailer(
720 31
			$messenger,
721
			$template,
722
			$this->getTranslator()->trans( $messageKey )
723
		);
724
725
		$mailer = new LoggingMailer( $mailer, $this->getLogger() );
726
727
		return $this->addProfilingDecorator( $mailer, 'Mailer' );
728
	}
729
730
	public function getGreetingGenerator(): GreetingGenerator {
731 3
		return $this->pimple['greeting_generator'];
732 3
	}
733 3
734 3
	public function newCheckIbanUseCase(): CheckIbanUseCase {
735 3
		return new CheckIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
736
	}
737
738
	public function newGenerateIbanUseCase(): GenerateIbanUseCase {
739 3
		return new GenerateIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
740 3
	}
741 3
742 3
	public function newIbanPresenter(): IbanPresenter {
743 3
		return new IbanPresenter();
744
	}
745
746
	public function newBankDataConverter(): BankDataConverter {
747 3
		return new BankDataConverter( $this->config['bank-data-file'] );
748 3
	}
749 3
750 3
	public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ): void {
751 3
		$this->pimple['subscription_validator'] = $subscriptionValidator;
752
	}
753
754
	public function newGetInTouchUseCase(): GetInTouchUseCase {
755 3
		return new GetInTouchUseCase(
756 3
			$this->getContactValidator(),
757
			$this->newContactOperatorMailer(),
758
			$this->newContactUserMailer()
759 7
		);
760 7
	}
761 7
762 7
	private function newContactUserMailer(): TemplateMailerInterface {
763
		return $this->newTemplateMailer(
764
			$this->getSuborganizationMessenger(),
765
			new TwigTemplate( $this->getMailerTwig(), 'Contact_Confirm_to_User.txt.twig' ),
766 7
			'mail_subject_getintouch'
767 7
		);
768 7
	}
769 7
770
	private function newContactOperatorMailer(): OperatorMailer {
771
		return new OperatorMailer(
772 7
			$this->getSuborganizationMessenger(),
773 7
			new TwigTemplate( $this->getMailerTwig(), 'Contact_Forward_to_Operator.txt.twig' ),
774
			$this->getTranslator()->trans( 'mail_subject_getintouch_forward' )
775
		);
776 78
	}
777 78
778
	private function getContactValidator(): GetInTouchValidator {
779
		return $this->pimple['contact_validator'];
780 1
	}
781 1
782 1
	private function newSubscriptionDuplicateValidator(): SubscriptionDuplicateValidator {
783 1
		return new SubscriptionDuplicateValidator(
784
				$this->getSubscriptionRepository(),
785
				$this->newSubscriptionDuplicateCutoffDate()
786
		);
787 31
	}
788 31
789
	private function newSubscriptionDuplicateCutoffDate(): \DateTime {
790
		$cutoffDateTime = new \DateTime();
791 46
		$cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) );
792 46
		return $cutoffDateTime;
793
	}
794
795 160
	private function newHonorificValidator(): AllowedValuesValidator {
796 160
		return new AllowedValuesValidator( $this->getHonorifics()->getKeys() );
797 160
	}
798
799 13
	private function getHonorifics(): Honorifics {
800 13
		return $this->pimple['honorifics'];
801
	}
802
803 160
	public function newAuthorizedCachePurger(): AuthorizedCachePurger {
804 160
		return new AuthorizedCachePurger(
805 160
			new AllOfTheCachePurger( $this->getSkinTwig(), $this->getPageCache(), $this->getRenderedPageCache() ),
806
			$this->config['purging-secret']
807 160
		);
808 160
	}
809 160
810 160
	private function newBankDataValidator(): BankDataValidator {
811
		return new BankDataValidator( $this->newIbanValidator() );
812 160
	}
813 160
814 160
	private function getSuborganizationMessenger(): Messenger {
815
		return $this->pimple['messenger_suborganization'];
816 160
	}
817
818 160
	public function setSuborganizationMessenger( Messenger $messenger ): void {
819 160
		$this->pimple['messenger_suborganization'] = $messenger;
820
	}
821
822 160
	private function getOrganizationMessenger(): Messenger {
823 160
		return $this->pimple['messenger_organization'];
824
	}
825
826 3
	public function setOrganizationMessenger( Messenger $messenger ): void {
827 3
		$this->pimple['messenger_organization'] = $messenger;
828
	}
829
830 3
	public function setNullMessenger(): void {
831 3
		$this->setSuborganizationMessenger( new Messenger(
832
			Swift_NullTransport::newInstance(),
833
			$this->getSubOrganizationEmailAddress()
834 116
		) );
835 116
		$this->setOrganizationMessenger( new Messenger(
836
			Swift_NullTransport::newInstance(),
837
			$this->getOrganizationEmailAddress()
838 2
		) );
839 2
	}
840 2
841
	public function getSubOrganizationEmailAddress(): EmailAddress {
842 109
		return new EmailAddress( $this->config['contact-info']['suborganization']['email'] );
843 109
	}
844
845
	public function getOrganizationEmailAddress(): EmailAddress {
846 41
		return new EmailAddress( $this->config['contact-info']['organization']['email'] );
847 41
	}
848 41
849
	public function newInternalErrorHtmlPresenter(): InternalErrorHtmlPresenter {
850 41
		return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'Error_Page.html.twig' ) );
851 41
	}
852 41
853
	public function newAccessDeniedHtmlPresenter(): InternalErrorHtmlPresenter {
854
		return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'Access_Denied.twig' ) );
855
	}
856 3
857 3
	public function getTranslator(): TranslatorInterface {
858
		return $this->pimple['translator'];
859
	}
860 5
861 5
	public function setTranslator( TranslatorInterface $translator ): void {
862 5
		$this->pimple['translator'] = $translator;
863 5
	}
864 5
865 5
	private function newTwigFactory( array $twigConfig ): TwigFactory {
866
		return new TwigFactory(
867
			array_merge_recursive(
868
				$twigConfig,
869 5
				[ 'web-basepath' => $this->config['web-basepath'] ]
870 5
			),
871 5
			$this->getCachePath() . '/twig',
872 5
			$this->config['locale']
873 5
		);
874 5
	}
875 5
876
	private function newTextPolicyValidator( string $policyName ): TextPolicyValidator {
877 5
		$fetcher = new ErrorLoggingFileFetcher(
878
			new SimpleFileFetcher(),
879
			$this->getLogger()
880
		);
881 20
		$textPolicyConfig = $this->config['text-policies'][$policyName];
882 20
		return new TextPolicyValidator(
883 20
			new WordListFileReader(
884 20
				$fetcher,
885 20
				$textPolicyConfig['badwords'] ? $this->getAbsolutePath( $textPolicyConfig['badwords'] ) : ''
886 20
			),
887 20
			new WordListFileReader(
888 20
				$fetcher,
889 20
				$textPolicyConfig['whitewords'] ? $this->getAbsolutePath( $textPolicyConfig['whitewords'] ) : ''
890
			)
891
		);
892
	}
893 20
894 20
	private function newCommentPolicyValidator(): TextPolicyValidator {
895 20
		return $this->newTextPolicyValidator( 'comment' );
896 20
	}
897
898
	public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase {
899
		return new CancelDonationUseCase(
900 20
			$this->getDonationRepository(),
901 20
			$this->newCancelDonationMailer(),
902 20
			$this->newDonationAuthorizer( $updateToken ),
903 20
			$this->newDonationEventLogger()
904 20
		);
905
	}
906
907
	private function newCancelDonationMailer(): TemplateMailerInterface {
908 2
		return $this->newTemplateMailer(
909 2
			$this->getSuborganizationMessenger(),
910 2
			new TwigTemplate(
911 2
				$this->getMailerTwig(),
912 2
				'Donation_Cancellation_Confirmation.txt.twig',
913
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
914
			),
915
			'mail_subject_confirm_cancellation'
916 28
		);
917 28
	}
918 28
919 28
	public function newAddDonationUseCase(): AddDonationUseCase {
920 28
		return new AddDonationUseCase(
921 28
			$this->getDonationRepository(),
922 28
			$this->newDonationValidator(),
923
			$this->newDonationPolicyValidator(),
924 28
			$this->newReferrerGeneralizer(),
925 28
			$this->newDonationConfirmationMailer(),
926
			$this->newBankTransferCodeGenerator(),
927
			$this->newDonationTokenFetcher(),
928 28
			new InitialDonationStatusPicker()
929
		);
930
	}
931
932
	private function newBankTransferCodeGenerator(): TransferCodeGenerator {
933 2
		return new UniqueTransferCodeGenerator(
934 2
			new SimpleTransferCodeGenerator(),
935
			$this->getEntityManager()
936
		);
937 2
	}
938 2
939
	private function newDonationValidator(): AddDonationValidator {
940
		return new AddDonationValidator(
941 2
			$this->newPaymentDataValidator(),
942 2
			$this->newBankDataValidator(),
943
			$this->getEmailValidator()
944
		);
945 2
	}
946 2
947
	public function newValidateDonorUseCase(): ValidateDonorUseCase {
948
		return new ValidateDonorUseCase(
949 3
			$this->getEmailValidator()
950 3
		);
951
	}
952
953 3
	private function newDonationConfirmationMailer(): DonationConfirmationMailer {
954 3
		return new DonationConfirmationMailer(
955
			$this->newTemplateMailer(
956
				$this->getSuborganizationMessenger(),
957 47
				new TwigTemplate(
958 47
					$this->getMailerTwig(),
959
					'Donation_Confirmation.txt.twig',
960
					[
961 36
						'greeting_generator' => $this->getGreetingGenerator()
962 36
					]
963
				),
964
				'mail_subject_confirm_donation'
965 19
			)
966 19
		);
967
	}
968
969 2
	public function newPayPalUrlGeneratorForDonations(): PayPalUrlGenerator {
970 2
		return new PayPalUrlGenerator(
971
			$this->getPayPalUrlConfigForDonations(),
972
			$this->getTranslator()->trans( 'item_name_donation' )
973 3
		);
974 3
	}
975 3
976 3
	public function newPayPalUrlGeneratorForMembershipApplications(): PayPalUrlGenerator {
977 3
		return new PayPalUrlGenerator(
978 3
			$this->getPayPalUrlConfigForMembershipApplications(),
979
			$this->getTranslator()->trans( 'item_name_membership' )
980
		);
981
	}
982 29
983 29
	private function getPayPalUrlConfigForDonations(): PayPalConfig {
984 29
		return PayPalConfig::newFromConfig( $this->config['paypal-donation'] );
985
	}
986
987
	private function getPayPalUrlConfigForMembershipApplications(): PayPalConfig {
988
		return PayPalConfig::newFromConfig( $this->config['paypal-membership'] );
989
	}
990 90
991 90
	public function newSofortUrlGeneratorForDonations(): SofortUrlGenerator {
992
		$config = $this->config['sofort'];
993
994 10
		return new SofortUrlGenerator(
995 10
			new SofortConfig(
996 10
				$this->getTranslator()->trans( 'item_name_donation', [], 'messages' ),
997
				$config['return-url'],
998
				$config['cancel-url'],
999
				$config['notification-url']
1000 3
			),
1001 3
			$this->getSofortClient()
1002 3
		);
1003 3
	}
1004 3
1005
	public function setSofortClient( SofortClient $client ): void {
1006
		$this->pimple['sofort-client'] = $client;
1007
	}
1008 5
1009 5
	private function getSofortClient(): SofortClient {
1010 5
		return $this->pimple['sofort-client'];
1011
	}
1012
1013
	private function newCreditCardUrlGenerator(): CreditCardUrlGenerator {
1014 11
		return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() );
1015 11
	}
1016 11
1017 11
	private function newCreditCardUrlConfig(): CreditCardConfig {
1018 11
		return CreditCardConfig::newFromConfig( $this->config['creditcard'] );
1019 11
	}
1020 11
1021 11
	public function getDonationRepository(): DonationRepository {
1022 11
		return $this->pimple['donation_repository'];
1023
	}
1024
1025
	public function newPaymentDataValidator(): PaymentDataValidator {
1026 11
		return new PaymentDataValidator(
1027 11
			$this->config['donation-minimum-amount'],
1028 11
			$this->config['donation-maximum-amount'],
1029 11
			$this->getPaymentTypesSettings()->getEnabledForDonation()
1030 11
		);
1031 11
	}
1032 11
1033
	private function newAmountFormatter(): AmountFormatter {
1034 11
		return new AmountFormatter( $this->config['locale'] );
1035
	}
1036
1037
	public function newDecimalNumberFormatter(): NumberFormatter {
1038 11
		return new NumberFormatter( $this->config['locale'], NumberFormatter::DECIMAL );
1039 11
	}
1040 11
1041 11
	public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase {
1042 11
		return new AddCommentUseCase(
1043
			$this->getDonationRepository(),
1044
			$this->newDonationAuthorizer( $updateToken ),
1045
			$this->newCommentPolicyValidator(),
1046 11
			$this->newAddCommentValidator()
1047 11
		);
1048
	}
1049
1050 11
	private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer {
1051 11
		return new DoctrineDonationAuthorizer(
1052
			$this->getEntityManager(),
1053
			$updateToken,
1054 11
			$accessToken
1055 11
		);
1056
	}
1057
1058 2
	public function getDonationTokenGenerator(): TokenGenerator {
1059 2
		return $this->pimple['donation_token_generator'];
1060 2
	}
1061 2
1062 2
	public function getMembershipTokenGenerator(): MembershipTokenGenerator {
1063
		return $this->pimple['membership_token_generator'];
1064
	}
1065
1066 3
	public function newDonationConfirmationPresenter( string $templateName = 'Donation_Confirmation.html.twig' ): DonationConfirmationHtmlPresenter {
1067
		return new DonationConfirmationHtmlPresenter(
1068
			$this->getLayoutTemplate(
1069 3
				$templateName,
1070 3
				[
1071
					'piwikGoals' => [ 3 ],
1072
					'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForMembershipApplication()
1073
				]
1074
			),
1075
			$this->getUrlGenerator()
1076 14
		);
1077 14
	}
1078
1079
	public function newCreditCardPaymentUrlGenerator(): CreditCardPaymentUrlGenerator {
1080 2
		return new CreditCardPaymentUrlGenerator(
1081 2
			$this->getTranslator(),
1082 2
			$this->newCreditCardUrlGenerator()
1083 2
		);
1084 2
	}
1085 2
1086 2
	public function newCancelDonationHtmlPresenter(): CancelDonationHtmlPresenter {
1087
		return new CancelDonationHtmlPresenter(
1088 2
			$this->getLayoutTemplate( 'Donation_Cancellation_Confirmation.html.twig' )
1089
		);
1090
	}
1091
1092 1
	public function newApplyForMembershipUseCase(): ApplyForMembershipUseCase {
1093 1
		return new ApplyForMembershipUseCase(
1094 1
			$this->getMembershipApplicationRepository(),
1095 1
			$this->newMembershipApplicationTokenFetcher(),
1096
			$this->newApplyForMembershipMailer(),
1097
			$this->newMembershipApplicationValidator(),
1098
			$this->newApplyForMembershipPolicyValidator(),
1099 13
			$this->newMembershipApplicationTracker(),
1100 13
			$this->newMembershipApplicationPiwikTracker(),
1101 13
			$this->getPaymentDelayCalculator()
1102 13
		);
1103 13
	}
1104
1105
	private function newApplyForMembershipMailer(): TemplateMailerInterface {
1106
		return $this->newTemplateMailer(
1107 7
			$this->getOrganizationMessenger(),
1108 7
			new TwigTemplate(
1109 7
				$this->getMailerTwig(),
1110
				'Membership_Application_Confirmation.txt.twig',
1111 10
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
1112 10
			),
1113
			'mail_subject_confirm_membership_application'
1114
		);
1115 4
	}
1116
1117
	private function newMembershipApplicationValidator(): MembershipApplicationValidator {
1118 4
		return new MembershipApplicationValidator(
1119 4
			new MembershipFeeValidator(),
1120
			$this->newBankDataValidator(),
1121
			$this->getEmailValidator()
1122 15
		);
1123
	}
1124
1125 15
	private function newMembershipApplicationTracker(): ApplicationTracker {
1126 15
		return new DoctrineApplicationTracker( $this->getEntityManager() );
1127
	}
1128
1129 4
	private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker {
1130 4
		return new DoctrineApplicationPiwikTracker( $this->getEntityManager() );
1131 4
	}
1132 4
1133 4
	private function getPaymentDelayCalculator(): PaymentDelayCalculator {
1134 4
		return $this->pimple['payment-delay-calculator'];
1135
	}
1136
1137
	public function getPaymentDelayInDays(): int {
1138 7
		return $this->getPayPalUrlConfigForMembershipApplications()->getDelayInDays();
1139 7
	}
1140
1141
	public function setPaymentDelayCalculator( PaymentDelayCalculator $paymentDelayCalculator ): void {
1142 7
		$this->pimple['payment-delay-calculator'] = $paymentDelayCalculator;
1143 7
	}
1144 7
1145
	private function newApplyForMembershipPolicyValidator(): ApplyForMembershipPolicyValidator {
1146 2
		return new ApplyForMembershipPolicyValidator(
1147 2
			$this->newTextPolicyValidator( 'fields' ),
1148 2
			$this->config['email-address-blacklist']
1149 2
		);
1150 2
	}
1151 2
1152 2
	public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase {
1153 2
		return new CancelMembershipApplicationUseCase(
1154
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1155
			$this->getMembershipApplicationRepository(),
1156
			$this->newCancelMembershipApplicationMailer()
1157 2
		);
1158 2
	}
1159 2
1160
	private function newMembershipApplicationAuthorizer(
1161
		string $updateToken = null, string $accessToken = null ): ApplicationAuthorizer {
1162
1163 1
		return new DoctrineApplicationAuthorizer(
1164 1
			$this->getEntityManager(),
1165 1
			$updateToken,
1166
			$accessToken
1167
		);
1168
	}
1169 2
1170 2
	public function getMembershipApplicationRepository(): ApplicationRepository {
1171 2
		return $this->pimple['membership_application_repository'];
1172
	}
1173
1174
	private function newCancelMembershipApplicationMailer(): TemplateMailerInterface {
1175 2
		return $this->newTemplateMailer(
1176 2
			$this->getOrganizationMessenger(),
1177 2
			new TwigTemplate(
1178
				$this->getMailerTwig(),
1179 2
				'Membership_Application_Cancellation_Confirmation.txt.twig',
1180 2
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
1181
			),
1182
			'mail_subject_confirm_membership_application_cancellation'
1183 2
		);
1184 2
	}
1185 2
1186 2
	public function newMembershipApplicationConfirmationUseCase( ShowApplicationConfirmationPresenter $presenter, string $accessToken ): ShowApplicationConfirmationUseCase {
1187 2
		return new ShowApplicationConfirmationUseCase(
1188 2
			$presenter,
1189
			$this->newMembershipApplicationAuthorizer( null, $accessToken ),
1190
			$this->getMembershipApplicationRepository(),
1191
			$this->newMembershipApplicationTokenFetcher()
1192
		);
1193 90
	}
1194 90
1195 90
	public function newGetDonationUseCase( string $accessToken ): GetDonationUseCase {
1196
		return new GetDonationUseCase(
1197
			$this->newDonationAuthorizer( null, $accessToken ),
1198
			$this->newDonationTokenFetcher(),
1199
			$this->getDonationRepository()
1200
		);
1201 90
	}
1202 90
1203 90
	public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ): void {
1204
		$this->pimple['confirmation-page-selector'] = $selector;
1205
	}
1206
1207
	public function getDonationConfirmationPageSelector(): DonationConfirmationPageSelector {
1208
		return $this->pimple['confirmation-page-selector'];
1209 21
	}
1210 21
1211 21
	public function newDonationFormViolationPresenter(): DonationFormViolationPresenter {
1212
		return new DonationFormViolationPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() );
1213
	}
1214
1215
	public function newDonationFormPresenter(): DonationFormPresenter {
1216
		return new DonationFormPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() );
1217 30
	}
1218 30
1219 30
	private function getDonationFormTemplate(): TwigTemplate {
1220
		// TODO make the template name dependent on the 'form' value from the HTTP POST request
1221
		// (we need different form pages for A/B testing)
1222
		return $this->getLayoutTemplate( 'Donation_Form.html.twig', [
1223 12
			'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForDonation()
1224 12
		] );
1225 12
	}
1226
1227
	public function getMembershipApplicationFormTemplate(): TwigTemplate {
1228
		return $this->getLayoutTemplate( 'Membership_Application.html.twig', [
1229 20
			'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForMembershipApplication()
1230 20
		] );
1231 20
	}
1232 20
1233
	public function newHandleSofortPaymentNotificationUseCase( string $updateToken ): SofortPaymentNotificationUseCase {
1234
		return new SofortPaymentNotificationUseCase(
1235
			$this->getDonationRepository(),
1236 20
			$this->newDonationAuthorizer( $updateToken ),
1237
			$this->newDonationConfirmationMailer()
1238 20
		);
1239
	}
1240
1241 2
	public function newHandlePayPalPaymentCompletionNotificationUseCase( string $updateToken ): HandlePayPalPaymentCompletionNotificationUseCase {
1242 2
		return new HandlePayPalPaymentCompletionNotificationUseCase(
1243
			$this->getDonationRepository(),
1244
			$this->newDonationAuthorizer( $updateToken ),
1245 2
			$this->newDonationConfirmationMailer(),
1246 2
			$this->newDonationEventLogger()
1247 2
		);
1248
	}
1249
1250 2
	public function newMembershipApplicationSubscriptionSignupNotificationUseCase( string $updateToken ): HandleSubscriptionSignupNotificationUseCase {
1251 2
		return new HandleSubscriptionSignupNotificationUseCase(
1252
			$this->getMembershipApplicationRepository(),
1253
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1254 3
			$this->newApplyForMembershipMailer(),
1255 3
			$this->getLogger()
1256
		);
1257
	}
1258 112
1259 112
	public function newMembershipApplicationSubscriptionPaymentNotificationUseCase( string $updateToken ): HandleSubscriptionPaymentNotificationUseCase {
1260
		return new HandleSubscriptionPaymentNotificationUseCase(
1261
			$this->getMembershipApplicationRepository(),
1262 109
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1263 109
			$this->newApplyForMembershipMailer(),
1264
			$this->getLogger()
1265
		);
1266
	}
1267
1268
	public function getPayPalPaymentNotificationVerifier(): PaymentNotificationVerifier {
1269
		return $this->pimple['paypal-payment-notification-verifier'];
1270
	}
1271
1272
	public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ): void {
1273
		$this->pimple['paypal-payment-notification-verifier'] = $verifier;
1274
	}
1275
1276 118
	public function getPayPalMembershipFeeNotificationVerifier(): PaymentNotificationVerifier {
1277 118
		return $this->pimple['paypal-membership-fee-notification-verifier'];
1278 118
	}
1279
1280
	public function setPayPalMembershipFeeNotificationVerifier( PaymentNotificationVerifier $verifier ): void {
1281
		$this->pimple['paypal-membership-fee-notification-verifier'] = $verifier;
1282
	}
1283
1284
	public function newCreditCardNotificationUseCase( string $updateToken ): CreditCardNotificationUseCase {
1285
		return new CreditCardNotificationUseCase(
1286
			$this->getDonationRepository(),
1287
			$this->newDonationAuthorizer( $updateToken ),
1288
			$this->getCreditCardService(),
1289
			$this->newDonationConfirmationMailer(),
1290 2
			$this->getLogger(),
1291 2
			$this->newDonationEventLogger()
1292 2
		);
1293
	}
1294
1295
	public function newCancelMembershipApplicationHtmlPresenter(): CancelMembershipApplicationHtmlPresenter {
1296
		return new CancelMembershipApplicationHtmlPresenter(
1297
			$this->getLayoutTemplate( 'Membership_Application_Cancellation_Confirmation.html.twig' )
1298 2
		);
1299 2
	}
1300 2
1301
	public function newMembershipApplicationConfirmationHtmlPresenter(): MembershipApplicationConfirmationHtmlPresenter {
1302
		return new MembershipApplicationConfirmationHtmlPresenter(
1303
			$this->getLayoutTemplate( 'Membership_Application_Confirmation.html.twig' )
1304
		);
1305
	}
1306 31
1307 31
	public function newMembershipFormViolationPresenter(): MembershipFormViolationPresenter {
1308
		return new MembershipFormViolationPresenter(
1309
			$this->getMembershipApplicationFormTemplate()
1310 109
		);
1311 109
	}
1312
1313
	public function setCreditCardService( CreditCardService $ccService ): void {
1314 109
		$this->pimple['credit-card-api-service'] = $ccService;
1315 109
	}
1316 109
1317 109
	public function getCreditCardService(): CreditCardService {
1318
		return $this->pimple['credit-card-api-service'];
1319
	}
1320
1321
	public function newCreditCardNotificationPresenter(): CreditCardNotificationPresenter {
1322 2
		return new CreditCardNotificationPresenter(
1323 2
			new TwigTemplate(
1324 2
				$this->getSkinTwig(),
1325 2
				'Credit_Card_Payment_Notification.txt.twig',
1326 2
				[ 'returnUrl' => $this->config['creditcard']['return-url'] ]
1327
			)
1328
		);
1329
	}
1330 11
1331 11
	private function newDoctrineDonationPrePersistSubscriber(): DoctrineDonationPrePersistSubscriber {
1332
		return new DoctrineDonationPrePersistSubscriber(
1333
			$this->getDonationTokenGenerator(),
1334
			$this->getDonationTokenGenerator()
1335 1
		);
1336 1
	}
1337
1338 2
	private function newDoctrineMembershipApplicationPrePersistSubscriber(): DoctrineMembershipApplicationPrePersistSubscriber {
1339
		return new DoctrineMembershipApplicationPrePersistSubscriber(
1340 1
			$this->getMembershipTokenGenerator(),
1341 1
			$this->getMembershipTokenGenerator()
1342
		);
1343
	}
1344
1345
	public function setDonationTokenGenerator( TokenGenerator $tokenGenerator ): void {
1346
		$this->pimple['donation_token_generator'] = $tokenGenerator;
1347
	}
1348
1349
	public function setMembershipTokenGenerator( MembershipTokenGenerator $tokenGenerator ): void {
1350
		$this->pimple['membership_token_generator'] = $tokenGenerator;
1351
	}
1352
1353
	public function disableDoctrineSubscribers(): void {
1354
		$this->addDoctrineSubscribers = false;
1355
	}
1356
1357
	private function newDonationTokenFetcher(): DonationTokenFetcher {
1358
		return new DoctrineDonationTokenFetcher(
1359
			$this->getEntityManager()
1360
		);
1361
	}
1362
1363
	private function newMembershipApplicationTokenFetcher(): ApplicationTokenFetcher {
1364
		return new DoctrineApplicationTokenFetcher(
1365
			$this->getEntityManager()
1366
		);
1367
	}
1368
1369
	private function newDonationPolicyValidator(): AddDonationPolicyValidator {
1370
		return new AddDonationPolicyValidator(
1371
			$this->newDonationAmountPolicyValidator(),
1372
			$this->newTextPolicyValidator( 'fields' ),
1373
			$this->config['email-address-blacklist']
1374
		);
1375
	}
1376
1377
	private function newDonationAmountPolicyValidator(): AmountPolicyValidator {
1378
		// in the future, this might come from the configuration
1379
		return new AmountPolicyValidator( 1000, 1000 );
1380
	}
1381
1382
	public function getDonationTimeframeLimit(): string {
1383
		return $this->config['donation-timeframe-limit'];
1384
	}
1385
1386
	public function newSystemMessageResponse( string $message ): string {
1387
		return $this->getLayoutTemplate( 'System_Message.html.twig' )
1388
			->render( [ 'message' => $message ] );
1389
	}
1390
1391
	public function getMembershipApplicationTimeframeLimit(): string {
1392
		return $this->config['membership-application-timeframe-limit'];
1393
	}
1394
1395
	private function newAddCommentValidator(): AddCommentValidator {
1396
		return new AddCommentValidator();
1397
	}
1398
1399
	private function getPageCache(): Cache {
1400
		return $this->pimple['page_cache'];
1401
	}
1402
1403
	private function getRenderedPageCache(): Cache {
1404
		return $this->pimple['rendered_page_cache'];
1405
	}
1406
1407
	public function enablePageCache(): void {
1408
		$this->pimple['page_cache'] = function() {
1409
			return new FilesystemCache( $this->getCachePath() . '/pages/raw' );
1410
		};
1411
1412
		$this->pimple['rendered_page_cache'] = function() {
1413
			return new FilesystemCache( $this->getCachePath() . '/pages/rendered' );
1414
		};
1415
	}
1416
1417
	private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) {	// @codingStandardsIgnoreLine
1418
		if ( $this->profiler === null ) {
1419
			return $objectToDecorate;
1420
		}
1421
1422
		$builder = new ProfilingDecoratorBuilder( $this->profiler, $this->getProfilerDataCollector() );
1423
1424
		return $builder->decorate( $objectToDecorate, $profilingLabel );
1425
	}
1426
1427
	public function setProfiler( Stopwatch $profiler ): void {
1428
		$this->profiler = $profiler;
1429
	}
1430
1431
	public function setEmailValidator( EmailValidator $validator ): void {
1432
		$this->pimple['mail_validator'] = $validator;
1433
	}
1434
1435
	public function setLogger( LoggerInterface $logger ): void {
1436
		$this->pimple['logger'] = $logger;
1437
	}
1438
1439
	public function setPaypalLogger( LoggerInterface $logger ): void {
1440
		$this->pimple['paypal_logger'] = $logger;
1441
	}
1442
1443
	public function setSofortLogger( LoggerInterface $logger ): void {
1444
		$this->pimple['sofort_logger'] = $logger;
1445
	}
1446
1447
	public function getProfilerDataCollector(): ProfilerDataCollector {
1448
		return $this->pimple['profiler_data_collector'];
1449
	}
1450
1451
	private function newIbanValidator(): KontoCheckIbanValidator {
1452
		return new KontoCheckIbanValidator( $this->newBankDataConverter(), $this->config['banned-ibans'] );
1453
	}
1454
1455
	public function setFilePrefixer( FilePrefixer $prefixer ): void {
1456
		$this->pimple['cachebusting_fileprefixer'] = $prefixer;
1457
	}
1458
1459
	private function getFilePrefixer(): FilePrefixer {
1460
		return $this->pimple['cachebusting_fileprefixer'];
1461
	}
1462
1463
	private function getFilePrefix(): string {
1464
		$prefixContentFile = $this->getVarPath() . '/file_prefix.txt';
1465
		if ( !file_exists( $prefixContentFile ) ) {
1466
			return '';
1467
		}
1468
		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...
1469
	}
1470
1471
	public function newDonationAcceptedEventHandler( string $updateToken ): DonationAcceptedEventHandler {
1472
		return new DonationAcceptedEventHandler(
1473
			$this->newDonationAuthorizer( $updateToken ),
1474
			$this->getDonationRepository(),
1475
			$this->newDonationConfirmationMailer()
1476
		);
1477
	}
1478
1479
	public function newPageNotFoundHtmlPresenter(): PageNotFoundPresenter {
1480
		return new PageNotFoundPresenter( $this->getLayoutTemplate( 'Page_not_found.html.twig' ) );
1481
	}
1482
1483
	public function setPageViewTracker( PageViewTracker $tracker ): void {
1484
		$this->pimple['page_view_tracker'] = function () use ( $tracker )  {
1485
			return $tracker;
1486
		};
1487
	}
1488
1489
	public function getPageViewTracker(): PageViewTracker {
1490
		return $this->pimple['page_view_tracker'];
1491
	}
1492
1493
	public function newServerSideTracker(): ServerSideTracker {
1494
		// the "https:" prefix does NOT get any slashes because baseURL is stored in a protocol-agnostic way
1495
		// (e.g. "//tracking.wikimedia.de" )
1496
		return new PiwikServerSideTracker(
1497
			new \PiwikTracker( $this->config['piwik']['siteId'], 'https:' . $this->config['piwik']['baseUrl'] )
1498
		);
1499
	}
1500
1501
	public function getI18nDirectory(): string {
1502
		return $this->getAbsolutePath( $this->config['i18n-base-path'] ) . '/' . $this->config['locale'];
1503
	}
1504
1505
	/**
1506
	 * If the pathname does not start with a slash, make the path absolute to root dir of application
1507
	 */
1508
	private function getAbsolutePath( string $path ): string {
1509
		if ( $path[0] === '/' ) {
1510
			return $path;
1511
		}
1512
		return __DIR__ . '/../../' . $path;
1513
	}
1514
1515
	public function setContentPagePageSelector( PageSelector $pageSelector ): void {
1516
		$this->pimple['content_page_selector'] = $pageSelector;
1517
	}
1518
1519
	public function getContentPagePageSelector(): PageSelector {
1520
		return $this->pimple['content_page_selector'];
1521
	}
1522
1523
	public function setContentProvider( ContentProvider $contentProvider ): void {
1524
		$this->pimple['content_provider'] = $contentProvider;
1525
	}
1526
1527
	private function getContentProvider(): ContentProvider {
1528
		return $this->pimple['content_provider'];
1529
	}
1530
1531
	public function newMailTemplateFilenameTraversable(): MailTemplateFilenameTraversable {
1532
		return new MailTemplateFilenameTraversable(
1533
			$this->config['mailer-twig']['loaders']['filesystem']['template-dir']
1534
		);
1535
	}
1536
1537
	public function getUrlGenerator(): UrlGenerator {
1538
		return $this->pimple['url_generator'];
1539
	}
1540
1541
	public function setUrlGenerator( UrlGenerator $urlGenerator ): void {
1542
		$this->pimple['url_generator'] = $urlGenerator;
1543
	}
1544
1545
	public function getCookieBuilder(): CookieBuilder {
1546
		return $this->pimple['cookie-builder'];
1547
	}
1548
1549
	public function getSkinSettings(): SkinSettings {
1550
		return $this->pimple['skin-settings'];
1551
	}
1552
1553
	public function getPaymentTypesSettings(): PaymentTypesSettings {
1554
		return $this->pimple['payment-types-settings'];
1555
	}
1556
1557
	public function newDonationAmountConstraint(): ValidatorConstraint {
1558
		return new RequiredConstraint( [
1559
			new TypeConstraint( [ 'type' => 'digit' ] ),
1560
			new RangeConstraint( [
1561
				'min' => Euro::newFromInt( $this->config['donation-minimum-amount'] )->getEuroCents(),
1562
				'max' => Euro::newFromInt( $this->config['donation-maximum-amount'] )->getEuroCents()
1563
			] )
1564
		] );
1565
	}
1566
}
1567