Completed
Push — master ( 87af87...4349fb )
by Jeroen De
237:55 queued 172:52
created

newShowDonationConfirmationUseCase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.216

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 2
cts 5
cp 0.4
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1.216
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 TNvpServiceDispatcher;
25
use Twig_Environment;
26
use Twig_Extensions_Extension_Intl;
27
use Twig_SimpleFunction;
28
use WMDE\EmailAddress\EmailAddress;
29
use WMDE\Fundraising\ContentProvider\ContentProvider;
30
use WMDE\Fundraising\Frontend\DonationContext\Authorization\DonationAuthorizer;
31
use WMDE\Fundraising\Frontend\DonationContext\Authorization\DonationTokenFetcher;
32
use WMDE\Fundraising\Frontend\DonationContext\Authorization\RandomTokenGenerator;
33
use WMDE\Fundraising\Frontend\DonationContext\Authorization\TokenGenerator;
34
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineCommentFinder;
35
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationAuthorizer;
36
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationEventLogger;
37
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationPrePersistSubscriber;
38
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationRepository;
39
use WMDE\Fundraising\Frontend\DonationContext\DataAccess\DoctrineDonationTokenFetcher;
40
use WMDE\Fundraising\Frontend\DonationContext\Domain\Repositories\CommentFinder;
41
use WMDE\Fundraising\Frontend\DonationContext\Domain\Repositories\DonationRepository;
42
use WMDE\Fundraising\Frontend\DonationContext\DonationAcceptedEventHandler;
43
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\BestEffortDonationEventLogger;
44
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\DonationConfirmationMailer;
45
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\DonationEventLogger;
46
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\LoggingCommentFinder;
47
use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\LoggingDonationRepository;
48
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddComment\AddCommentUseCase;
49
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddComment\AddCommentValidator;
50
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationPolicyValidator;
51
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationUseCase;
52
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\AddDonationValidator;
53
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\InitialDonationStatusPicker;
54
use WMDE\Fundraising\Frontend\DonationContext\UseCases\AddDonation\ReferrerGeneralizer;
55
use WMDE\Fundraising\Frontend\DonationContext\UseCases\CancelDonation\CancelDonationUseCase;
56
use WMDE\Fundraising\Frontend\DonationContext\UseCases\CreditCardPaymentNotification\CreditCardNotificationUseCase;
57
use WMDE\Fundraising\Frontend\DonationContext\UseCases\HandlePayPalPaymentNotification\HandlePayPalPaymentNotificationUseCase;
58
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ListComments\ListCommentsUseCase;
59
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ShowDonationConfirmation\ShowDonationConfirmationUseCase;
60
use WMDE\Fundraising\Frontend\DonationContext\UseCases\SofortPaymentNotification\SofortPaymentNotificationUseCase;
61
use WMDE\Fundraising\Frontend\DonationContext\UseCases\ValidateDonor\ValidateDonorUseCase;
62
use WMDE\Fundraising\Frontend\Infrastructure\Cache\AllOfTheCachePurger;
63
use WMDE\Fundraising\Frontend\Infrastructure\Cache\AuthorizedCachePurger;
64
use WMDE\Fundraising\Frontend\Infrastructure\CookieBuilder;
65
use WMDE\Fundraising\Frontend\Infrastructure\InternetDomainNameValidator;
66
use WMDE\Fundraising\Frontend\Infrastructure\LoggingMailer;
67
use WMDE\Fundraising\Frontend\Infrastructure\LoggingPaymentNotificationVerifier;
68
use WMDE\Fundraising\Frontend\Infrastructure\MailTemplateFilenameTraversable;
69
use WMDE\Fundraising\Frontend\Infrastructure\Messenger;
70
use WMDE\Fundraising\Frontend\Infrastructure\OperatorMailer;
71
use WMDE\Fundraising\Frontend\Infrastructure\PageViewTracker;
72
use WMDE\Fundraising\Frontend\Infrastructure\PaymentNotificationVerifier;
73
use WMDE\Fundraising\Frontend\Infrastructure\PayPalPaymentNotificationVerifier;
74
use WMDE\Fundraising\Frontend\Infrastructure\PiwikServerSideTracker;
75
use WMDE\Fundraising\Frontend\Infrastructure\ProfilerDataCollector;
76
use WMDE\Fundraising\Frontend\Infrastructure\ProfilingDecoratorBuilder;
77
use WMDE\Fundraising\Frontend\Infrastructure\ServerSideTracker;
78
use WMDE\Fundraising\Frontend\Infrastructure\TemplateBasedMailer;
79
use WMDE\Fundraising\Frontend\Infrastructure\TemplateMailerInterface;
80
use WMDE\Fundraising\Frontend\Infrastructure\UrlGenerator;
81
use WMDE\Fundraising\Frontend\Infrastructure\WordListFileReader;
82
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\ApplicationAuthorizer;
83
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\ApplicationTokenFetcher;
84
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\MembershipTokenGenerator;
85
use WMDE\Fundraising\Frontend\MembershipContext\Authorization\RandomMembershipTokenGenerator;
86
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationAuthorizer;
87
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationPiwikTracker;
88
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationRepository;
89
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationTokenFetcher;
90
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationTracker;
91
use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineMembershipApplicationPrePersistSubscriber;
92
use WMDE\Fundraising\Frontend\MembershipContext\Domain\Repositories\ApplicationRepository;
93
use WMDE\Fundraising\Frontend\MembershipContext\Infrastructure\LoggingApplicationRepository;
94
use WMDE\Fundraising\Frontend\MembershipContext\Tracking\ApplicationPiwikTracker;
95
use WMDE\Fundraising\Frontend\MembershipContext\Tracking\ApplicationTracker;
96
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\ApplyForMembershipPolicyValidator;
97
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\ApplyForMembershipUseCase;
98
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ApplyForMembership\MembershipApplicationValidator;
99
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\CancelMembershipApplication\CancelMembershipApplicationUseCase;
100
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\HandleSubscriptionPaymentNotification\HandleSubscriptionPaymentNotificationUseCase;
101
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\HandleSubscriptionSignupNotification\HandleSubscriptionSignupNotificationUseCase;
102
use WMDE\Fundraising\Frontend\MembershipContext\UseCases\ShowMembershipApplicationConfirmation\ShowMembershipApplicationConfirmationUseCase;
103
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\McpCreditCardService;
104
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\Sofort\Transfer\Client as SofortClient;
105
use WMDE\Fundraising\Frontend\PaymentContext\DataAccess\UniqueTransferCodeGenerator;
106
use WMDE\Fundraising\Frontend\PaymentContext\Domain\BankDataConverter;
107
use WMDE\Fundraising\Frontend\PaymentContext\Domain\DefaultPaymentDelayCalculator;
108
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentDelayCalculator;
109
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\CreditCard as CreditCardUrlGenerator;
110
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\CreditCardConfig;
111
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\PayPal as PayPalUrlGenerator;
112
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\PayPalConfig;
113
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\Sofort as SofortUrlGenerator;
114
use WMDE\Fundraising\Frontend\PaymentContext\Domain\PaymentUrlGenerator\SofortConfig;
115
use WMDE\Fundraising\Frontend\PaymentContext\Domain\SimpleTransferCodeGenerator;
116
use WMDE\Fundraising\Frontend\PaymentContext\Domain\TransferCodeGenerator;
117
use WMDE\Fundraising\Frontend\PaymentContext\Infrastructure\CreditCardService;
118
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\CheckIban\CheckIbanUseCase;
119
use WMDE\Fundraising\Frontend\PaymentContext\UseCases\GenerateIban\GenerateIbanUseCase;
120
use WMDE\Fundraising\Frontend\Presentation\AmountFormatter;
121
use WMDE\Fundraising\Frontend\Presentation\ContentPage\PageSelector;
122
use WMDE\Fundraising\Frontend\Presentation\DonationConfirmationPageSelector;
123
use WMDE\Fundraising\Frontend\Presentation\FilePrefixer;
124
use WMDE\Fundraising\Frontend\Presentation\GreetingGenerator;
125
use WMDE\Fundraising\Frontend\Presentation\Honorifics;
126
use WMDE\Fundraising\Frontend\Presentation\PaymentTypesSettings;
127
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionHtmlPresenter;
128
use WMDE\Fundraising\Frontend\Presentation\Presenters\AddSubscriptionJsonPresenter;
129
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelDonationHtmlPresenter;
130
use WMDE\Fundraising\Frontend\Presentation\Presenters\CancelMembershipApplicationHtmlPresenter;
131
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListHtmlPresenter;
132
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListJsonPresenter;
133
use WMDE\Fundraising\Frontend\Presentation\Presenters\CommentListRssPresenter;
134
use WMDE\Fundraising\Frontend\Presentation\Presenters\ConfirmSubscriptionHtmlPresenter;
135
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardNotificationPresenter;
136
use WMDE\Fundraising\Frontend\Presentation\Presenters\CreditCardPaymentUrlGenerator;
137
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationConfirmationHtmlPresenter;
138
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormPresenter;
139
use WMDE\Fundraising\Frontend\Presentation\Presenters\DonationFormViolationPresenter;
140
use WMDE\Fundraising\Frontend\Presentation\Presenters\GetInTouchHtmlPresenter;
141
use WMDE\Fundraising\Frontend\Presentation\Presenters\IbanPresenter;
142
use WMDE\Fundraising\Frontend\Presentation\Presenters\InternalErrorHtmlPresenter;
143
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipApplicationConfirmationHtmlPresenter;
144
use WMDE\Fundraising\Frontend\Presentation\Presenters\MembershipFormViolationPresenter;
145
use WMDE\Fundraising\Frontend\Presentation\Presenters\PageNotFoundPresenter;
146
use WMDE\Fundraising\Frontend\Presentation\SkinSettings;
147
use WMDE\Fundraising\Frontend\Presentation\TwigTemplate;
148
use WMDE\Fundraising\Frontend\SubscriptionContext\DataAccess\DoctrineSubscriptionRepository;
149
use WMDE\Fundraising\Frontend\SubscriptionContext\Domain\Repositories\SubscriptionRepository;
150
use WMDE\Fundraising\Frontend\SubscriptionContext\Infrastructure\LoggingSubscriptionRepository;
151
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\AddSubscription\AddSubscriptionUseCase;
152
use WMDE\Fundraising\Frontend\SubscriptionContext\UseCases\ConfirmSubscription\ConfirmSubscriptionUseCase;
153
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionDuplicateValidator;
154
use WMDE\Fundraising\Frontend\SubscriptionContext\Validation\SubscriptionValidator;
155
use WMDE\Fundraising\Frontend\UseCases\GetInTouch\GetInTouchUseCase;
156
use WMDE\FunValidators\Validators\AllowedValuesValidator;
157
use WMDE\FunValidators\Validators\AmountPolicyValidator;
158
use WMDE\Fundraising\Frontend\Validation\BankDataValidator;
159
use WMDE\FunValidators\Validators\EmailValidator;
160
use WMDE\Fundraising\Frontend\Validation\GetInTouchValidator;
161
use WMDE\Fundraising\Frontend\Validation\KontoCheckIbanValidator;
162
use WMDE\Fundraising\Frontend\Validation\MembershipFeeValidator;
163
use WMDE\Fundraising\Frontend\Validation\PaymentDataValidator;
164
use WMDE\Fundraising\Frontend\Validation\TemplateNameValidator;
165
use WMDE\FunValidators\Validators\TextPolicyValidator;
166
use WMDE\Fundraising\Store\Factory as StoreFactory;
167
use WMDE\Fundraising\Store\Installer;
168
169
/**
170
 * @licence GNU GPL v2+
171
 */
172
class FunFunFactory {
173
174
	private $config;
175
176
	/**
177 160
	 * @var Container
178 160
	 */
179 160
	private $pimple;
180 160
181
	private $addDoctrineSubscribers = true;
182 160
183 160
	/**
184
	 * @var Stopwatch|null
185
	 */
186 119
	private $profiler = null;
187
188
	public function __construct( array $config ) {
189
		$this->config = $config;
190 4
		$this->pimple = $this->newPimple();
191
	}
192
193
	private function newPimple(): Container {
194
		$pimple = new Container();
195
196
		$pimple['logger'] = function() {
197
			return new NullLogger();
198 160
		};
199
200
		$pimple['paypal_logger'] = function() {
201
			return new NullLogger();
202 90
		};
203 90
204 90
		$pimple['sofort_logger'] = function() {
205 90
			return new NullLogger();
206 90
		};
207
208
		$pimple['profiler_data_collector'] = function() {
209 90
			return new ProfilerDataCollector();
210
		};
211
212
		$pimple['dbal_connection'] = function() {
213 9
			return DriverManager::getConnection( $this->config['db'] );
214 9
		};
215 9
216
		$pimple['entity_manager'] = function() {
217
			$entityManager = ( new StoreFactory( $this->getConnection(), $this->getVarPath() . '/doctrine_proxies' ) )
218
				->getEntityManager();
219
			if ( $this->addDoctrineSubscribers ) {
220 47
				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() );
221 47
				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() );
222 47
			}
223
224
			return $entityManager;
225
		};
226
227 14
		$pimple['subscription_repository'] = function() {
228 14
			return new LoggingSubscriptionRepository(
229 14
				new DoctrineSubscriptionRepository( $this->getEntityManager() ),
230
				$this->getLogger()
231
			);
232
		};
233
234 12
		$pimple['donation_repository'] = function() {
235 12
			return new LoggingDonationRepository(
236 12
				new DoctrineDonationRepository( $this->getEntityManager() ),
237
				$this->getLogger()
238
			);
239 12
		};
240
241
		$pimple['membership_application_repository'] = function() {
242
			return new LoggingApplicationRepository(
243 44
				new DoctrineApplicationRepository( $this->getEntityManager() ),
244
				$this->getLogger()
245
			);
246
		};
247 7
248 7
		$pimple['comment_repository'] = function() {
249 7
			$finder = new LoggingCommentFinder(
250 7
				new DoctrineCommentFinder( $this->getEntityManager() ),
251 7
				$this->getLogger()
252
			);
253
254
			return $this->addProfilingDecorator( $finder, 'CommentFinder' );
255
		};
256 8
257
		$pimple['mail_validator'] = function() {
258
			return new EmailValidator( new InternetDomainNameValidator() );
259
		};
260 3
261
		$pimple['subscription_validator'] = function() {
262
			return new SubscriptionValidator(
263
				$this->getEmailValidator(),
264 56
				$this->newTextPolicyValidator( 'fields' ),
265
				$this->newSubscriptionDuplicateValidator(),
266
				$this->newHonorificValidator()
267
			);
268 102
		};
269 102
270 102
		$pimple['template_name_validator'] = function() {
271
			return new TemplateNameValidator( $this->getSkinTwig() );
272
		};
273
274
		$pimple['contact_validator'] = function() {
275 102
			return new GetInTouchValidator( $this->getEmailValidator() );
276 102
		};
277
278 102
		$pimple['greeting_generator'] = function() {
279 102
			return new GreetingGenerator();
280
		};
281 102
282 102
		$pimple['translator'] = function() {
283 102
			$translationFactory = new TranslationFactory();
284
			$loaders = [
285
				'json' => $translationFactory->newJsonLoader()
286
			];
287 102
			$locale = $this->config['locale'];
288
			$messagesPath = $this->getI18nDirectory() . $this->config['translation']['message-dir'];
289
			$translator = $translationFactory->create( $loaders, $locale );
290
			foreach ($this->config['translation']['files'] as $domain => $file) {
291 114
				$translator->addResource( 'json', $messagesPath . '/' . $file, $locale, $domain );
292
			}
293 114
294
			return $translator;
295 114
		};
296 114
297 114
		// In the future, this could be locale-specific or filled from a DB table
298 114
		$pimple['honorifics'] = function() {
299 114
			return new Honorifics( [
300
				'' => 'Kein Titel',
301
				'Dr.' => 'Dr.',
302
				'Prof.' => 'Prof.',
303 114
				'Prof. Dr.' => 'Prof. Dr.'
304 114
			] );
305 114
		};
306
307 114
		$pimple['twig'] = function() {
308
			$config = $this->config['twig'];
309
			$config['loaders']['filesystem']['template-dir'] = 'skins/' . $this->getSkinSettings()->getSkin() . '/templates';
310 114
311 114
			$twigFactory = $this->newTwigFactory( $config );
312 114
			$configurator = $twigFactory->newTwigEnvironmentConfigurator();
313
314 114
			$loaders = array_filter( [
315
				$twigFactory->newFileSystemLoader(),
316
				$twigFactory->newArrayLoader(), // This is just a fallback for testing
317 114
			] );
318 114
			$extensions = [
319 114
				$twigFactory->newTranslationExtension( $this->getTranslator() ),
320
				new Twig_Extensions_Extension_Intl()
321 114
			];
322
			$filters = [
323
				$twigFactory->newFilePrefixFilter(
324 114
					$this->getFilePrefixer()
325 114
				)
326 114
			];
327
			$functions = [
328 114
				new Twig_SimpleFunction(
329
					'web_content',
330
					function( string $name, array $context = [] ): string {
331 114
						return $this->getContentProvider()->getWeb( $name, $context );
332
					},
333
					[ 'is_safe' => [ 'html' ] ]
334
				),
335
			];
336 78
337 78
			return $configurator->getEnvironment( $this->pimple['skin_twig_environment'], $loaders, $extensions, $filters, $functions );
338
		};
339
340
		$pimple['mailer_twig'] = function() {
341
			$twigFactory = $this->newTwigFactory( $this->config['mailer-twig'] );
342
			$configurator = $twigFactory->newTwigEnvironmentConfigurator();
343
344
			$loaders = array_filter( [
345 109
				$twigFactory->newFileSystemLoader(),
346
				$twigFactory->newArrayLoader(), // This is just a fallback for testing
347
			] );
348
			$extensions = [
349 109
				$twigFactory->newTranslationExtension( $this->getTranslator() ),
350 109
				new Twig_Extensions_Extension_Intl(),
351 109
			];
352 109
			$filters = [];
353 109
			$functions = [
354 109
				new Twig_SimpleFunction(
355 109
					'mail_content',
356
					function( string $name, array $context = [] ): string {
357
						return $this->getContentProvider()->getMail( $name, $context );
358
					},
359 109
					[ 'is_safe' => [ 'all' ] ]
360 109
				),
361
				new Twig_SimpleFunction(
362
					'url',
363 109
					function( string $name, array $parameters = [] ): string {
364 109
						return $this->getUrlGenerator()->generateUrl( $name, $parameters );
365
					}
366
				)
367
			];
368 109
369
			$twigEnvironment = new Twig_Environment();
370
371
			return $configurator->getEnvironment( $twigEnvironment, $loaders, $extensions, $filters, $functions );
372
		};
373
374
		$pimple['messenger_suborganization'] = function() {
375
			return new Messenger(
376
				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...
377
				$this->getSubOrganizationEmailAddress(),
378
				$this->config['contact-info']['suborganization']['name']
379
			);
380
		};
381
382
		$pimple['messenger_organization'] = function() {
383
			return new Messenger(
384
				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...
385
				$this->getOrganizationEmailAddress(),
386
				$this->config['contact-info']['organization']['name']
387
			);
388 6
		};
389
390
		$pimple['confirmation-page-selector'] = function() {
391
			return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] );
392
		};
393
394
		$pimple['paypal-payment-notification-verifier'] = function() {
395
			return new LoggingPaymentNotificationVerifier(
396
				new PayPalPaymentNotificationVerifier(
397
					new Client(),
398
					$this->config['paypal-donation']['base-url'],
399
					$this->config['paypal-donation']['account-address']
400
				),
401
				$this->getLogger()
402
			);
403
		};
404
405
		$pimple['paypal-membership-fee-notification-verifier'] = function() {
406
			return new LoggingPaymentNotificationVerifier(
407
				new PayPalPaymentNotificationVerifier(
408
					new Client(),
409
					$this->config['paypal-membership']['base-url'],
410
					$this->config['paypal-membership']['account-address']
411
				),
412
				$this->getLogger()
413
			);
414 69
		};
415 69
416 69
		$pimple['credit-card-api-service'] = function() {
417
			return new McpCreditCardService(
418
				new TNvpServiceDispatcher(
419
					'IMcpCreditcardService_v1_5',
420
					'https://sipg.micropayment.de/public/creditcard/v1.5/nvp/'
421 112
				),
422
				$this->config['creditcard']['access-key'],
423
				$this->config['creditcard']['testmode']
424
			);
425 109
		};
426
427
		$pimple['donation_token_generator'] = function() {
428
			return new RandomTokenGenerator(
429
				$this->config['token-length'],
430
				new \DateInterval( $this->config['token-validity-timestamp'] )
431
			);
432 160
		};
433
434
		$pimple['membership_token_generator'] = function() {
435 160
			return new RandomMembershipTokenGenerator(
436 160
				$this->config['token-length'],
437
				new \DateInterval( $this->config['token-validity-timestamp'] )
438
			);
439 90
		};
440 90
441
		$pimple['page_cache'] = function() {
442
			return new VoidCache();
443 11
		};
444 11
445 11
		$pimple['rendered_page_cache'] = function() {
446 11
			return new VoidCache();
447
		};
448
449
		$pimple['page_view_tracker'] = function () {
450 160
			return new PageViewTracker( $this->newServerSideTracker(), $this->config['piwik']['siteUrlBase'] );
451 160
		};
452
453
		$pimple['cachebusting_fileprefixer'] = function () {
454 12
			return new FilePrefixer( $this->getFilePrefix() );
455 12
		};
456
457
		$pimple['content_page_selector'] = function () {
458 6
			$json = (new SimpleFileFetcher())->fetchFile( $this->getI18nDirectory() . '/data/pages.json' );
459 6
			$config = json_decode( $json, true ) ?? [];
460
461
			return new PageSelector( $config );
462 2
		};
463 2
464 2
		$pimple['content_provider'] = function () {
465 2
			return new ContentProvider( [
466
				'content_path' => $this->getI18nDirectory(),
467
				'cache' => $this->config['twig']['enable-cache'] ? $this->getCachePath() . '/content' : false,
468
				'globals' => [
469 4
					'basepath' => $this->config['web-basepath']
470 4
				]
471
			] );
472
		};
473 12
474 12
		$pimple['payment-delay-calculator'] = function() {
475
			return new DefaultPaymentDelayCalculator( $this->getPaymentDelayInDays() );
476
		};
477 10
478 10
		$pimple['sofort-client'] = function () {
479
			$config = $this->config['sofort'];
480
			return new SofortClient( $config['config-key'] );
481 1
		};
482 1
483 1
		$pimple['cookie-builder'] = function (): CookieBuilder {
484
			return new CookieBuilder(
485 7
				$this->config['cookie']['expiration'],
486 7
				$this->config['cookie']['path'],
487
				$this->config['cookie']['domain'],
488
				$this->config['cookie']['secure'],
489 46
				$this->config['cookie']['httpOnly'],
490 46
				$this->config['cookie']['raw'],
491
				$this->config['cookie']['sameSite']
492
			);
493 8
		};
494 8
495
		$pimple['skin-settings'] = function (): SkinSettings {
496
			$config = $this->config['skin'];
497 1
			return new SkinSettings( $config['options'], $config['default'], $config['cookie-lifetime'] );
498 1
		};
499
500
		$pimple['payment-types-settings'] = function (): PaymentTypesSettings {
501 3
			return new PaymentTypesSettings( $this->config['payment-types'] );
502 3
		};
503 3
504 3
		return $pimple;
505
	}
506
507
	public function getConnection(): Connection {
508 3
		return $this->pimple['dbal_connection'];
509 3
	}
510
511
	public function getEntityManager(): EntityManager {
512 1
		return $this->pimple['entity_manager'];
513 1
	}
514
515
	private function newDonationEventLogger(): DonationEventLogger {
516 160
		return new BestEffortDonationEventLogger(
517 160
			new DoctrineDonationEventLogger( $this->getEntityManager() ),
518 160
			$this->getLogger()
519
		);
520 109
	}
521 109
522
	public function newInstaller(): Installer {
523
		return ( new StoreFactory( $this->getConnection() ) )->newInstaller();
524
	}
525
526
	public function newListCommentsUseCase(): ListCommentsUseCase {
527
		return new ListCommentsUseCase( $this->getCommentFinder() );
528
	}
529
530
	public function newCommentListJsonPresenter(): CommentListJsonPresenter {
531 43
		return new CommentListJsonPresenter();
532 43
	}
533 43
534
	public function newCommentListRssPresenter(): CommentListRssPresenter {
535 43
		return new CommentListRssPresenter( new TwigTemplate(
536
			$this->getSkinTwig(),
537
			'Comment_List.rss.twig'
538
		) );
539
	}
540
541
	public function newCommentListHtmlPresenter(): CommentListHtmlPresenter {
542
		return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'Comment_List.html.twig', [ 'piwikGoals' => [ 1 ] ] ) );
543
	}
544
545 30
	private function getCommentFinder(): CommentFinder {
546 30
		return $this->pimple['comment_repository'];
547 30
	}
548 30
549
	public function getSubscriptionRepository(): SubscriptionRepository {
550 30
		return $this->pimple['subscription_repository'];
551 30
	}
552
553
	public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ): void {
554
		$this->pimple['subscription_repository'] = $subscriptionRepository;
555
	}
556
557 72
	private function getSubscriptionValidator(): SubscriptionValidator {
558
		return $this->pimple['subscription_validator'];
559 72
	}
560 72
561 72
	public function getEmailValidator(): EmailValidator {
562 72
		return $this->pimple['mail_validator'];
563 72
	}
564 72
565
	public function getTemplateNameValidator(): TemplateNameValidator {
566
		return $this->pimple['template_name_validator'];
567
	}
568 20
569 20
	public function newAddSubscriptionHtmlPresenter(): AddSubscriptionHtmlPresenter {
570 20
		return new AddSubscriptionHtmlPresenter( $this->getLayoutTemplate( 'Subscription_Form.html.twig' ), $this->getTranslator() );
571 20
	}
572
573
	public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter {
574
		return new ConfirmSubscriptionHtmlPresenter(
575 112
			$this->getLayoutTemplate( 'Confirm_Subscription.twig' ),
576 112
			$this->getTranslator()
577
		);
578
	}
579 10
580 10
	public function newAddSubscriptionJsonPresenter(): AddSubscriptionJsonPresenter {
581 10
		return new AddSubscriptionJsonPresenter( $this->getTranslator() );
582
	}
583 102
584 102
	public function newGetInTouchHtmlPresenter(): GetInTouchHtmlPresenter {
585
		return new GetInTouchHtmlPresenter( $this->getLayoutTemplate( 'contact_form.html.twig' ), $this->getTranslator() );
586
	}
587 112
588 112
	public function setSkinTwigEnvironment( Twig_Environment $twig ): void {
589 112
		$this->pimple['skin_twig_environment'] = $twig;
590 112
	}
591
592
	public function getSkinTwig(): Twig_Environment {
593 112
		return $this->pimple['twig'];
594
	}
595
596 109
	public function getMailerTwig(): Twig_Environment {
597 109
		return $this->pimple['mailer_twig'];
598 109
	}
599 109
600
	/**
601
	 * Get a template, with the content for the layout areas filled in.
602 109
	 *
603
	 * @param string $templateName
604
	 * @param array $context Additional variables for the template
605 112
	 * @return TwigTemplate
606 112
	 */
607 112
	public function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate {
608 112
		 return new TwigTemplate(
609 112
			$this->getSkinTwig(),
610 112
			$templateName,
611 112
			array_merge( $this->getDefaultTwigVariables(), $context )
612
		);
613
	}
614
615 109
	public function getMailerTemplate( string $templateName, array $context = [] ): TwigTemplate {
616 109
		return new TwigTemplate(
617 109
			$this->getMailerTwig(),
618 109
			$templateName,
619 109
			array_merge( $this->getDefaultTwigVariables(), $context )
620 109
		);
621 109
	}
622
623
	/**
624
	 * Get a layouted template that includes another template
625 119
	 *
626 119
	 * @deprecated Change the template to use extend and block and call getLayoutTemplate instead.
627
	 *
628
	 * @param string $templateName Template to include
629 6
	 * @return TwigTemplate
630 6
	 */
631
	private function getIncludeTemplate( string $templateName, array $context = [] ): TwigTemplate {
632
		return new TwigTemplate(
633 127
			$this->getSkinTwig(),
634 127
			'Include_in_Layout.twig',
635
			array_merge(
636
				$this->getDefaultTwigVariables(),
637 109
				[ 'main_template' => $templateName ],
638 109
				$context
639
			)
640
		);
641
	}
642
643
	private function getDefaultTwigVariables(): array {
644
		return [
645
			'honorifics' => $this->getHonorifics()->getList(),
646
			'header_template' => $this->config['default-layout-templates']['header'],
647
			'footer_template' => $this->config['default-layout-templates']['footer'],
648
			'no_js_notice_template' => $this->config['default-layout-templates']['no-js-notice'],
649 7
			'piwik' => $this->config['piwik'],
650 7
			'locale' => $this->config['locale'],
651 7
		];
652 7
	}
653 7
654
	private function newReferrerGeneralizer(): ReferrerGeneralizer {
655
		return new ReferrerGeneralizer(
656
			$this->config['referrer-generalization']['default'],
657 3
			$this->config['referrer-generalization']['domain-map']
658 3
		);
659 3
	}
660 3
661
	public function getLogger(): LoggerInterface {
662
		return $this->pimple['logger'];
663
	}
664 7
665 7
	public function getPaypalLogger(): LoggerInterface {
666 7
		return $this->pimple['paypal_logger'];
667 7
	}
668 7
669 7
	public function getSofortLogger(): LoggerInterface {
670
		return $this->pimple['sofort_logger'];
671 7
	}
672 7
673
	private function getVarPath(): string {
674
		return __DIR__ . '/../../var';
675 7
	}
676
677
	public function getCachePath(): string {
678
		return $this->getVarPath() . '/cache';
679 3
	}
680 3
681 3
	public function getLoggingPath(): string {
682 3
		return $this->getVarPath() . '/log';
683 3
	}
684 3
685 3
	public function getTemplatePath(): string {
686
		return __DIR__ . '/../../app/fundraising-frontend-content/templates';
687 3
	}
688
689
	public function newAddSubscriptionUseCase(): AddSubscriptionUseCase {
690
		return new AddSubscriptionUseCase(
691 59
			$this->getSubscriptionRepository(),
692 59
			$this->getSubscriptionValidator(),
693
			$this->newAddSubscriptionMailer()
694
		);
695 59
	}
696
697
	public function newConfirmSubscriptionUseCase(): ConfirmSubscriptionUseCase {
698 59
		return new ConfirmSubscriptionUseCase(
699
			$this->getSubscriptionRepository(),
700 59
			$this->newConfirmSubscriptionMailer()
701
		);
702
	}
703 56
704 56
	private function newAddSubscriptionMailer(): TemplateMailerInterface {
705
		return $this->newTemplateMailer(
706
			$this->getSuborganizationMessenger(),
707
			new TwigTemplate(
708
				$this->getMailerTwig(),
709
				'Subscription_Request.txt.twig',
710
				[
711
					'greeting_generator' => $this->getGreetingGenerator()
712
				]
713
			),
714
			'mail_subject_subscription'
715
		);
716
	}
717
718
	private function newConfirmSubscriptionMailer(): TemplateMailerInterface {
719 31
		return $this->newTemplateMailer(
720 31
			$this->getSuborganizationMessenger(),
721
			new TwigTemplate(
722
					$this->getMailerTwig(),
723
					'Subscription_Confirmation.txt.twig',
724
					[ 'greeting_generator' => $this->getGreetingGenerator() ]
725
			),
726
			'mail_subject_subscription_confirmed'
727
		);
728
	}
729
730
	/**
731 3
	 * Create a new TemplateMailer instance
732 3
	 *
733 3
	 * So much decoration going on that explicitly hinting what we return (Robustness principle) would be confusing
734 3
	 * (you'd expect a TemplateBasedMailer, not a LoggingMailer), so we hint the interface instead.
735 3
	 */
736
	private function newTemplateMailer( Messenger $messenger, TwigTemplate $template, string $messageKey ): TemplateMailerInterface {
737
		$mailer = new TemplateBasedMailer(
738
			$messenger,
739 3
			$template,
740 3
			$this->getTranslator()->trans( $messageKey )
741 3
		);
742 3
743 3
		$mailer = new LoggingMailer( $mailer, $this->getLogger() );
744
745
		return $this->addProfilingDecorator( $mailer, 'Mailer' );
746
	}
747 3
748 3
	public function getGreetingGenerator(): GreetingGenerator {
749 3
		return $this->pimple['greeting_generator'];
750 3
	}
751 3
752
	public function newCheckIbanUseCase(): CheckIbanUseCase {
753
		return new CheckIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
754
	}
755 3
756 3
	public function newGenerateIbanUseCase(): GenerateIbanUseCase {
757
		return new GenerateIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
758
	}
759 7
760 7
	public function newIbanPresenter(): IbanPresenter {
761 7
		return new IbanPresenter();
762 7
	}
763
764
	public function newBankDataConverter(): BankDataConverter {
765
		return new BankDataConverter( $this->config['bank-data-file'] );
766 7
	}
767 7
768 7
	public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ): void {
769 7
		$this->pimple['subscription_validator'] = $subscriptionValidator;
770
	}
771
772 7
	public function newGetInTouchUseCase(): GetInTouchUseCase {
773 7
		return new GetInTouchUseCase(
774
			$this->getContactValidator(),
775
			$this->newContactOperatorMailer(),
776 78
			$this->newContactUserMailer()
777 78
		);
778
	}
779
780 1
	private function newContactUserMailer(): TemplateMailerInterface {
781 1
		return $this->newTemplateMailer(
782 1
			$this->getSuborganizationMessenger(),
783 1
			new TwigTemplate( $this->getMailerTwig(), 'Contact_Confirm_to_User.txt.twig' ),
784
			'mail_subject_getintouch'
785
		);
786
	}
787 31
788 31
	private function newContactOperatorMailer(): OperatorMailer {
789
		return new OperatorMailer(
790
			$this->getSuborganizationMessenger(),
791 46
			new TwigTemplate( $this->getMailerTwig(), 'Contact_Forward_to_Operator.txt.twig' ),
792 46
			$this->getTranslator()->trans( 'mail_subject_getintouch_forward' )
793
		);
794
	}
795 160
796 160
	private function getContactValidator(): GetInTouchValidator {
797 160
		return $this->pimple['contact_validator'];
798
	}
799 13
800 13
	private function newSubscriptionDuplicateValidator(): SubscriptionDuplicateValidator {
801
		return new SubscriptionDuplicateValidator(
802
				$this->getSubscriptionRepository(),
803 160
				$this->newSubscriptionDuplicateCutoffDate()
804 160
		);
805 160
	}
806
807 160
	private function newSubscriptionDuplicateCutoffDate(): \DateTime {
808 160
		$cutoffDateTime = new \DateTime();
809 160
		$cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) );
810 160
		return $cutoffDateTime;
811
	}
812 160
813 160
	private function newHonorificValidator(): AllowedValuesValidator {
814 160
		return new AllowedValuesValidator( $this->getHonorifics()->getKeys() );
815
	}
816 160
817
	private function getHonorifics(): Honorifics {
818 160
		return $this->pimple['honorifics'];
819 160
	}
820
821
	public function newAuthorizedCachePurger(): AuthorizedCachePurger {
822 160
		return new AuthorizedCachePurger(
823 160
			new AllOfTheCachePurger( $this->getSkinTwig(), $this->getPageCache(), $this->getRenderedPageCache() ),
824
			$this->config['purging-secret']
825
		);
826 3
	}
827 3
828
	private function newBankDataValidator(): BankDataValidator {
829
		return new BankDataValidator( $this->newIbanValidator() );
830 3
	}
831 3
832
	private function getSuborganizationMessenger(): Messenger {
833
		return $this->pimple['messenger_suborganization'];
834 116
	}
835 116
836
	public function setSuborganizationMessenger( Messenger $messenger ): void {
837
		$this->pimple['messenger_suborganization'] = $messenger;
838 2
	}
839 2
840 2
	private function getOrganizationMessenger(): Messenger {
841
		return $this->pimple['messenger_organization'];
842 109
	}
843 109
844
	public function setOrganizationMessenger( Messenger $messenger ): void {
845
		$this->pimple['messenger_organization'] = $messenger;
846 41
	}
847 41
848 41
	public function setNullMessenger(): void {
849
		$this->setSuborganizationMessenger( new Messenger(
850 41
			Swift_NullTransport::newInstance(),
851 41
			$this->getSubOrganizationEmailAddress()
852 41
		) );
853
		$this->setOrganizationMessenger( new Messenger(
854
			Swift_NullTransport::newInstance(),
855
			$this->getOrganizationEmailAddress()
856 3
		) );
857 3
	}
858
859
	public function getSubOrganizationEmailAddress(): EmailAddress {
860 5
		return new EmailAddress( $this->config['contact-info']['suborganization']['email'] );
861 5
	}
862 5
863 5
	public function getOrganizationEmailAddress(): EmailAddress {
864 5
		return new EmailAddress( $this->config['contact-info']['organization']['email'] );
865 5
	}
866
867
	public function newInternalErrorHtmlPresenter(): InternalErrorHtmlPresenter {
868
		return new InternalErrorHtmlPresenter( $this->getIncludeTemplate( 'Error_Page.html.twig' ) );
0 ignored issues
show
Deprecated Code introduced by
The method WMDE\Fundraising\Fronten...y::getIncludeTemplate() has been deprecated with message: Change the template to use extend and block and call getLayoutTemplate instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
869 5
	}
870 5
871 5
	public function newAccessDeniedHtmlPresenter(): InternalErrorHtmlPresenter {
872 5
		return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'Access_Denied.twig' ) );
873 5
	}
874 5
875 5
	public function getTranslator(): TranslatorInterface {
876
		return $this->pimple['translator'];
877 5
	}
878
879
	public function setTranslator( TranslatorInterface $translator ): void {
880
		$this->pimple['translator'] = $translator;
881 20
	}
882 20
883 20
	private function newTwigFactory( array $twigConfig ): TwigFactory {
884 20
		return new TwigFactory(
885 20
			array_merge_recursive(
886 20
				$twigConfig,
887 20
				[ 'web-basepath' => $this->config['web-basepath'] ]
888 20
			),
889 20
			$this->getCachePath() . '/twig',
890
			$this->config['locale']
891
		);
892
	}
893 20
894 20
	private function newTextPolicyValidator( string $policyName ): TextPolicyValidator {
895 20
		$fetcher = new ErrorLoggingFileFetcher(
896 20
			new SimpleFileFetcher(),
897
			$this->getLogger()
898
		);
899
		$textPolicyConfig = $this->config['text-policies'][$policyName];
900 20
		return new TextPolicyValidator(
901 20
			new WordListFileReader(
902 20
				$fetcher,
903 20
				$textPolicyConfig['badwords'] ? $this->getAbsolutePath( $textPolicyConfig['badwords'] ) : ''
904 20
			),
905
			new WordListFileReader(
906
				$fetcher,
907
				$textPolicyConfig['whitewords'] ? $this->getAbsolutePath( $textPolicyConfig['whitewords'] ) : ''
908 2
			)
909 2
		);
910 2
	}
911 2
912 2
	private function newCommentPolicyValidator(): TextPolicyValidator {
913
		return $this->newTextPolicyValidator( 'comment' );
914
	}
915
916 28
	public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase {
917 28
		return new CancelDonationUseCase(
918 28
			$this->getDonationRepository(),
919 28
			$this->newCancelDonationMailer(),
920 28
			$this->newDonationAuthorizer( $updateToken ),
921 28
			$this->newDonationEventLogger()
922 28
		);
923
	}
924 28
925 28
	private function newCancelDonationMailer(): TemplateMailerInterface {
926
		return $this->newTemplateMailer(
927
			$this->getSuborganizationMessenger(),
928 28
			new TwigTemplate(
929
				$this->getMailerTwig(),
930
				'Donation_Cancellation_Confirmation.txt.twig',
931
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
932
			),
933 2
			'mail_subject_confirm_cancellation'
934 2
		);
935
	}
936
937 2
	public function newAddDonationUseCase(): AddDonationUseCase {
938 2
		return new AddDonationUseCase(
939
			$this->getDonationRepository(),
940
			$this->newDonationValidator(),
941 2
			$this->newDonationPolicyValidator(),
942 2
			$this->newReferrerGeneralizer(),
943
			$this->newDonationConfirmationMailer(),
944
			$this->newBankTransferCodeGenerator(),
945 2
			$this->newDonationTokenFetcher(),
946 2
			new InitialDonationStatusPicker()
947
		);
948
	}
949 3
950 3
	private function newBankTransferCodeGenerator(): TransferCodeGenerator {
951
		return new UniqueTransferCodeGenerator(
952
			new SimpleTransferCodeGenerator(),
953 3
			$this->getEntityManager()
954 3
		);
955
	}
956
957 47
	private function newDonationValidator(): AddDonationValidator {
958 47
		return new AddDonationValidator(
959
			$this->newPaymentDataValidator(),
960
			$this->newBankDataValidator(),
961 36
			$this->getEmailValidator()
962 36
		);
963
	}
964
965 19
	public function newValidateDonorUseCase(): ValidateDonorUseCase {
966 19
		return new ValidateDonorUseCase(
967
			$this->getEmailValidator()
968
		);
969 2
	}
970 2
971
	private function newDonationConfirmationMailer(): DonationConfirmationMailer {
972
		return new DonationConfirmationMailer(
973 3
			$this->newTemplateMailer(
974 3
				$this->getSuborganizationMessenger(),
975 3
				new TwigTemplate(
976 3
					$this->getMailerTwig(),
977 3
					'Donation_Confirmation.txt.twig',
978 3
					[
979
						'greeting_generator' => $this->getGreetingGenerator()
980
					]
981
				),
982 29
				'mail_subject_confirm_donation'
983 29
			)
984 29
		);
985
	}
986
987
	public function newPayPalUrlGeneratorForDonations(): PayPalUrlGenerator {
988
		return new PayPalUrlGenerator(
989
			$this->getPayPalUrlConfigForDonations(),
990 90
			$this->getTranslator()->trans( 'item_name_donation' )
991 90
		);
992
	}
993
994 10
	public function newPayPalUrlGeneratorForMembershipApplications(): PayPalUrlGenerator {
995 10
		return new PayPalUrlGenerator(
996 10
			$this->getPayPalUrlConfigForMembershipApplications(),
997
			$this->getTranslator()->trans( 'item_name_membership' )
998
		);
999
	}
1000 3
1001 3
	private function getPayPalUrlConfigForDonations(): PayPalConfig {
1002 3
		return PayPalConfig::newFromConfig( $this->config['paypal-donation'] );
1003 3
	}
1004 3
1005
	private function getPayPalUrlConfigForMembershipApplications(): PayPalConfig {
1006
		return PayPalConfig::newFromConfig( $this->config['paypal-membership'] );
1007
	}
1008 5
1009 5
	public function newSofortUrlGeneratorForDonations(): SofortUrlGenerator {
1010 5
		$config = $this->config['sofort'];
1011
1012
		return new SofortUrlGenerator(
1013
			new SofortConfig(
1014 11
				$this->getTranslator()->trans( 'item_name_donation', [], 'messages' ),
1015 11
				$config['return-url'],
1016 11
				$config['cancel-url'],
1017 11
				$config['notification-url']
1018 11
			),
1019 11
			$this->getSofortClient()
1020 11
		);
1021 11
	}
1022 11
1023
	public function setSofortClient( SofortClient $client ): void {
1024
		$this->pimple['sofort-client'] = $client;
1025
	}
1026 11
1027 11
	private function getSofortClient(): SofortClient {
1028 11
		return $this->pimple['sofort-client'];
1029 11
	}
1030 11
1031 11
	private function newCreditCardUrlGenerator(): CreditCardUrlGenerator {
1032 11
		return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() );
1033
	}
1034 11
1035
	private function newCreditCardUrlConfig(): CreditCardConfig {
1036
		return CreditCardConfig::newFromConfig( $this->config['creditcard'] );
1037
	}
1038 11
1039 11
	public function getDonationRepository(): DonationRepository {
1040 11
		return $this->pimple['donation_repository'];
1041 11
	}
1042 11
1043
	public function newPaymentDataValidator(): PaymentDataValidator {
1044
		return new PaymentDataValidator(
1045
			$this->config['donation-minimum-amount'],
1046 11
			$this->config['donation-maximum-amount'],
1047 11
			$this->getPaymentTypesSettings()->getEnabledForDonation()
1048
		);
1049
	}
1050 11
1051 11
	private function newAmountFormatter(): AmountFormatter {
1052
		return new AmountFormatter( $this->config['locale'] );
1053
	}
1054 11
1055 11
	public function newDecimalNumberFormatter(): NumberFormatter {
1056
		return new NumberFormatter( $this->config['locale'], NumberFormatter::DECIMAL );
1057
	}
1058 2
1059 2
	public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase {
1060 2
		return new AddCommentUseCase(
1061 2
			$this->getDonationRepository(),
1062 2
			$this->newDonationAuthorizer( $updateToken ),
1063
			$this->newCommentPolicyValidator(),
1064
			$this->newAddCommentValidator()
1065
		);
1066 3
	}
1067
1068
	private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer {
1069 3
		return new DoctrineDonationAuthorizer(
1070 3
			$this->getEntityManager(),
1071
			$updateToken,
1072
			$accessToken
1073
		);
1074
	}
1075
1076 14
	public function getDonationTokenGenerator(): TokenGenerator {
1077 14
		return $this->pimple['donation_token_generator'];
1078
	}
1079
1080 2
	public function getMembershipTokenGenerator(): MembershipTokenGenerator {
1081 2
		return $this->pimple['membership_token_generator'];
1082 2
	}
1083 2
1084 2
	public function newDonationConfirmationPresenter( string $templateName = 'Donation_Confirmation.html.twig' ): DonationConfirmationHtmlPresenter {
1085 2
		return new DonationConfirmationHtmlPresenter(
1086 2
			$this->getLayoutTemplate(
1087
				$templateName,
1088 2
				[
1089
					'piwikGoals' => [ 3 ],
1090
					'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForMembershipApplication()
1091
				]
1092 1
			)
1093 1
		);
1094 1
	}
1095 1
1096
	public function newCreditCardPaymentUrlGenerator(): CreditCardPaymentUrlGenerator {
1097
		return new CreditCardPaymentUrlGenerator(
1098
			$this->getTranslator(),
1099 13
			$this->newCreditCardUrlGenerator()
1100 13
		);
1101 13
	}
1102 13
1103 13
	public function newCancelDonationHtmlPresenter(): CancelDonationHtmlPresenter {
1104
		return new CancelDonationHtmlPresenter(
1105
			$this->getIncludeTemplate( 'Donation_Cancellation_Confirmation.html.twig' )
0 ignored issues
show
Deprecated Code introduced by
The method WMDE\Fundraising\Fronten...y::getIncludeTemplate() has been deprecated with message: Change the template to use extend and block and call getLayoutTemplate instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1106
		);
1107 7
	}
1108 7
1109 7
	public function newApplyForMembershipUseCase(): ApplyForMembershipUseCase {
1110
		return new ApplyForMembershipUseCase(
1111 10
			$this->getMembershipApplicationRepository(),
1112 10
			$this->newMembershipApplicationTokenFetcher(),
1113
			$this->newApplyForMembershipMailer(),
1114
			$this->newMembershipApplicationValidator(),
1115 4
			$this->newApplyForMembershipPolicyValidator(),
1116
			$this->newMembershipApplicationTracker(),
1117
			$this->newMembershipApplicationPiwikTracker(),
1118 4
			$this->getPaymentDelayCalculator()
1119 4
		);
1120
	}
1121
1122 15
	private function newApplyForMembershipMailer(): TemplateMailerInterface {
1123
		return $this->newTemplateMailer(
1124
			$this->getOrganizationMessenger(),
1125 15
			new TwigTemplate(
1126 15
				$this->getMailerTwig(),
1127
				'Membership_Application_Confirmation.txt.twig',
1128
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
1129 4
			),
1130 4
			'mail_subject_confirm_membership_application'
1131 4
		);
1132 4
	}
1133 4
1134 4
	private function newMembershipApplicationValidator(): MembershipApplicationValidator {
1135
		return new MembershipApplicationValidator(
1136
			new MembershipFeeValidator(),
1137
			$this->newBankDataValidator(),
1138 7
			$this->getEmailValidator()
1139 7
		);
1140
	}
1141
1142 7
	private function newMembershipApplicationTracker(): ApplicationTracker {
1143 7
		return new DoctrineApplicationTracker( $this->getEntityManager() );
1144 7
	}
1145
1146 2
	private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker {
1147 2
		return new DoctrineApplicationPiwikTracker( $this->getEntityManager() );
1148 2
	}
1149 2
1150 2
	private function getPaymentDelayCalculator(): PaymentDelayCalculator {
1151 2
		return $this->pimple['payment-delay-calculator'];
1152 2
	}
1153 2
1154
	public function getPaymentDelayInDays(): int {
1155
		return $this->getPayPalUrlConfigForMembershipApplications()->getDelayInDays();
1156
	}
1157 2
1158 2
	public function setPaymentDelayCalculator( PaymentDelayCalculator $paymentDelayCalculator ): void {
1159 2
		$this->pimple['payment-delay-calculator'] = $paymentDelayCalculator;
1160
	}
1161
1162
	private function newApplyForMembershipPolicyValidator(): ApplyForMembershipPolicyValidator {
1163 1
		return new ApplyForMembershipPolicyValidator(
1164 1
			$this->newTextPolicyValidator( 'fields' ),
1165 1
			$this->config['email-address-blacklist']
1166
		);
1167
	}
1168
1169 2
	public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase {
1170 2
		return new CancelMembershipApplicationUseCase(
1171 2
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1172
			$this->getMembershipApplicationRepository(),
1173
			$this->newCancelMembershipApplicationMailer()
1174
		);
1175 2
	}
1176 2
1177 2
	private function newMembershipApplicationAuthorizer(
1178
		string $updateToken = null, string $accessToken = null ): ApplicationAuthorizer {
1179 2
1180 2
		return new DoctrineApplicationAuthorizer(
1181
			$this->getEntityManager(),
1182
			$updateToken,
1183 2
			$accessToken
1184 2
		);
1185 2
	}
1186 2
1187 2
	public function getMembershipApplicationRepository(): ApplicationRepository {
1188 2
		return $this->pimple['membership_application_repository'];
1189
	}
1190
1191
	private function newCancelMembershipApplicationMailer(): TemplateMailerInterface {
1192
		return $this->newTemplateMailer(
1193 90
			$this->getOrganizationMessenger(),
1194 90
			new TwigTemplate(
1195 90
				$this->getMailerTwig(),
1196
				'Membership_Application_Cancellation_Confirmation.txt.twig',
1197
				[ 'greeting_generator' => $this->getGreetingGenerator() ]
1198
			),
1199
			'mail_subject_confirm_membership_application_cancellation'
1200
		);
1201 90
	}
1202 90
1203 90
	public function newMembershipApplicationConfirmationUseCase( string $accessToken ): ShowMembershipApplicationConfirmationUseCase {
1204
		return new ShowMembershipApplicationConfirmationUseCase(
1205
			$this->newMembershipApplicationAuthorizer( null, $accessToken ), $this->getMembershipApplicationRepository(),
1206
			$this->newMembershipApplicationTokenFetcher()
1207
		);
1208
	}
1209 21
1210 21
	public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase {
1211 21
		return new ShowDonationConfirmationUseCase(
1212
			$this->newDonationAuthorizer( null, $accessToken ),
1213
			$this->newDonationTokenFetcher(),
1214
			$this->getDonationRepository()
1215
		);
1216
	}
1217 30
1218 30
	public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ): void {
1219 30
		$this->pimple['confirmation-page-selector'] = $selector;
1220
	}
1221
1222
	public function getDonationConfirmationPageSelector(): DonationConfirmationPageSelector {
1223 12
		return $this->pimple['confirmation-page-selector'];
1224 12
	}
1225 12
1226
	public function newDonationFormViolationPresenter(): DonationFormViolationPresenter {
1227
		return new DonationFormViolationPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() );
1228
	}
1229 20
1230 20
	public function newDonationFormPresenter(): DonationFormPresenter {
1231 20
		return new DonationFormPresenter( $this->getDonationFormTemplate(), $this->newAmountFormatter() );
1232 20
	}
1233
1234
	private function getDonationFormTemplate(): TwigTemplate {
1235
		// TODO make the template name dependent on the 'form' value from the HTTP POST request
1236 20
		// (we need different form pages for A/B testing)
1237
		return $this->getLayoutTemplate( 'Donation_Form.html.twig', [
1238 20
			'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForDonation()
1239
		] );
1240
	}
1241 2
1242 2
	public function getMembershipApplicationFormTemplate(): TwigTemplate {
1243
		return $this->getLayoutTemplate( 'Membership_Application.html.twig', [
1244
			'paymentTypes' => $this->getPaymentTypesSettings()->getEnabledForMembershipApplication()
1245 2
		] );
1246 2
	}
1247 2
1248
	public function newHandleSofortPaymentNotificationUseCase( string $updateToken ): SofortPaymentNotificationUseCase {
1249
		return new SofortPaymentNotificationUseCase(
1250 2
			$this->getDonationRepository(),
1251 2
			$this->newDonationAuthorizer( $updateToken ),
1252
			$this->newDonationConfirmationMailer()
1253
		);
1254 3
	}
1255 3
1256
	public function newHandlePayPalPaymentNotificationUseCase( string $updateToken ): HandlePayPalPaymentNotificationUseCase {
1257
		return new HandlePayPalPaymentNotificationUseCase(
1258 112
			$this->getDonationRepository(),
1259 112
			$this->newDonationAuthorizer( $updateToken ),
1260
			$this->newDonationConfirmationMailer(),
1261
			$this->newDonationEventLogger()
1262 109
		);
1263 109
	}
1264
1265
	public function newMembershipApplicationSubscriptionSignupNotificationUseCase( string $updateToken ): HandleSubscriptionSignupNotificationUseCase {
1266
		return new HandleSubscriptionSignupNotificationUseCase(
1267
			$this->getMembershipApplicationRepository(),
1268
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1269
			$this->newApplyForMembershipMailer(),
1270
			$this->getLogger()
1271
		);
1272
	}
1273
1274
	public function newMembershipApplicationSubscriptionPaymentNotificationUseCase( string $updateToken ): HandleSubscriptionPaymentNotificationUseCase {
1275
		return new HandleSubscriptionPaymentNotificationUseCase(
1276 118
			$this->getMembershipApplicationRepository(),
1277 118
			$this->newMembershipApplicationAuthorizer( $updateToken ),
1278 118
			$this->newApplyForMembershipMailer(),
1279
			$this->getLogger()
1280
		);
1281
	}
1282
1283
	public function getPayPalPaymentNotificationVerifier(): PaymentNotificationVerifier {
1284
		return $this->pimple['paypal-payment-notification-verifier'];
1285
	}
1286
1287
	public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ): void {
1288
		$this->pimple['paypal-payment-notification-verifier'] = $verifier;
1289
	}
1290 2
1291 2
	public function getPayPalMembershipFeeNotificationVerifier(): PaymentNotificationVerifier {
1292 2
		return $this->pimple['paypal-membership-fee-notification-verifier'];
1293
	}
1294
1295
	public function setPayPalMembershipFeeNotificationVerifier( PaymentNotificationVerifier $verifier ): void {
1296
		$this->pimple['paypal-membership-fee-notification-verifier'] = $verifier;
1297
	}
1298 2
1299 2
	public function newCreditCardNotificationUseCase( string $updateToken ): CreditCardNotificationUseCase {
1300 2
		return new CreditCardNotificationUseCase(
1301
			$this->getDonationRepository(),
1302
			$this->newDonationAuthorizer( $updateToken ),
1303
			$this->getCreditCardService(),
1304
			$this->newDonationConfirmationMailer(),
1305
			$this->getLogger(),
1306 31
			$this->newDonationEventLogger()
1307 31
		);
1308
	}
1309
1310 109
	public function newCancelMembershipApplicationHtmlPresenter(): CancelMembershipApplicationHtmlPresenter {
1311 109
		return new CancelMembershipApplicationHtmlPresenter(
1312
			$this->getIncludeTemplate( 'Membership_Application_Cancellation_Confirmation.html.twig' )
0 ignored issues
show
Deprecated Code introduced by
The method WMDE\Fundraising\Fronten...y::getIncludeTemplate() has been deprecated with message: Change the template to use extend and block and call getLayoutTemplate instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1313
		);
1314 109
	}
1315 109
1316 109
	public function newMembershipApplicationConfirmationHtmlPresenter(): MembershipApplicationConfirmationHtmlPresenter {
1317 109
		return new MembershipApplicationConfirmationHtmlPresenter(
1318
			$this->getIncludeTemplate( 'Membership_Application_Confirmation.html.twig' )
0 ignored issues
show
Deprecated Code introduced by
The method WMDE\Fundraising\Fronten...y::getIncludeTemplate() has been deprecated with message: Change the template to use extend and block and call getLayoutTemplate instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1319
		);
1320
	}
1321
1322 2
	public function newMembershipFormViolationPresenter(): MembershipFormViolationPresenter {
1323 2
		return new MembershipFormViolationPresenter(
1324 2
			$this->getMembershipApplicationFormTemplate()
1325 2
		);
1326 2
	}
1327
1328
	public function setCreditCardService( CreditCardService $ccService ): void {
1329
		$this->pimple['credit-card-api-service'] = $ccService;
1330 11
	}
1331 11
1332
	public function getCreditCardService(): CreditCardService {
1333
		return $this->pimple['credit-card-api-service'];
1334
	}
1335 1
1336 1
	public function newCreditCardNotificationPresenter(): CreditCardNotificationPresenter {
1337
		return new CreditCardNotificationPresenter(
1338 2
			new TwigTemplate(
1339
				$this->getSkinTwig(),
1340 1
				'Credit_Card_Payment_Notification.txt.twig',
1341 1
				[ 'returnUrl' => $this->config['creditcard']['return-url'] ]
1342
			)
1343
		);
1344
	}
1345
1346
	private function newDoctrineDonationPrePersistSubscriber(): DoctrineDonationPrePersistSubscriber {
1347
		return new DoctrineDonationPrePersistSubscriber(
1348
			$this->getDonationTokenGenerator(),
1349
			$this->getDonationTokenGenerator()
1350
		);
1351
	}
1352
1353
	private function newDoctrineMembershipApplicationPrePersistSubscriber(): DoctrineMembershipApplicationPrePersistSubscriber {
1354
		return new DoctrineMembershipApplicationPrePersistSubscriber(
1355
			$this->getMembershipTokenGenerator(),
1356
			$this->getMembershipTokenGenerator()
1357
		);
1358
	}
1359
1360
	public function setDonationTokenGenerator( TokenGenerator $tokenGenerator ): void {
1361
		$this->pimple['donation_token_generator'] = $tokenGenerator;
1362
	}
1363
1364
	public function setMembershipTokenGenerator( MembershipTokenGenerator $tokenGenerator ): void {
1365
		$this->pimple['membership_token_generator'] = $tokenGenerator;
1366
	}
1367
1368
	public function disableDoctrineSubscribers(): void {
1369
		$this->addDoctrineSubscribers = false;
1370
	}
1371
1372
	private function newDonationTokenFetcher(): DonationTokenFetcher {
1373
		return new DoctrineDonationTokenFetcher(
1374
			$this->getEntityManager()
1375
		);
1376
	}
1377
1378
	private function newMembershipApplicationTokenFetcher(): ApplicationTokenFetcher {
1379
		return new DoctrineApplicationTokenFetcher(
1380
			$this->getEntityManager()
1381
		);
1382
	}
1383
1384
	private function newDonationPolicyValidator(): AddDonationPolicyValidator {
1385
		return new AddDonationPolicyValidator(
1386
			$this->newDonationAmountPolicyValidator(),
1387
			$this->newTextPolicyValidator( 'fields' ),
1388
			$this->config['email-address-blacklist']
1389
		);
1390
	}
1391
1392
	private function newDonationAmountPolicyValidator(): AmountPolicyValidator {
1393
		// in the future, this might come from the configuration
1394
		return new AmountPolicyValidator( 1000, 1000 );
1395
	}
1396
1397
	public function getDonationTimeframeLimit(): string {
1398
		return $this->config['donation-timeframe-limit'];
1399
	}
1400
1401
	public function newSystemMessageResponse( string $message ): string {
1402
		$test = $this->getIncludeTemplate( 'System_Message.html.twig' );
0 ignored issues
show
Deprecated Code introduced by
The method WMDE\Fundraising\Fronten...y::getIncludeTemplate() has been deprecated with message: Change the template to use extend and block and call getLayoutTemplate instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
1403
		return $test->render( [ 'message' => $message ] );
1404
	}
1405
1406
	public function getMembershipApplicationTimeframeLimit(): string {
1407
		return $this->config['membership-application-timeframe-limit'];
1408
	}
1409
1410
	private function newAddCommentValidator(): AddCommentValidator {
1411
		return new AddCommentValidator();
1412
	}
1413
1414
	private function getPageCache(): Cache {
1415
		return $this->pimple['page_cache'];
1416
	}
1417
1418
	private function getRenderedPageCache(): Cache {
1419
		return $this->pimple['rendered_page_cache'];
1420
	}
1421
1422
	public function enablePageCache(): void {
1423
		$this->pimple['page_cache'] = function() {
1424
			return new FilesystemCache( $this->getCachePath() . '/pages/raw' );
1425
		};
1426
1427
		$this->pimple['rendered_page_cache'] = function() {
1428
			return new FilesystemCache( $this->getCachePath() . '/pages/rendered' );
1429
		};
1430
	}
1431
1432
	private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) {	// @codingStandardsIgnoreLine
1433
		if ( $this->profiler === null ) {
1434
			return $objectToDecorate;
1435
		}
1436
1437
		$builder = new ProfilingDecoratorBuilder( $this->profiler, $this->getProfilerDataCollector() );
1438
1439
		return $builder->decorate( $objectToDecorate, $profilingLabel );
1440
	}
1441
1442
	public function setProfiler( Stopwatch $profiler ): void {
1443
		$this->profiler = $profiler;
1444
	}
1445
1446
	public function setEmailValidator( EmailValidator $validator ): void {
1447
		$this->pimple['mail_validator'] = $validator;
1448
	}
1449
1450
	public function setLogger( LoggerInterface $logger ): void {
1451
		$this->pimple['logger'] = $logger;
1452
	}
1453
1454
	public function setPaypalLogger( LoggerInterface $logger ): void {
1455
		$this->pimple['paypal_logger'] = $logger;
1456
	}
1457
1458
	public function setSofortLogger( LoggerInterface $logger ): void {
1459
		$this->pimple['sofort_logger'] = $logger;
1460
	}
1461
1462
	public function getProfilerDataCollector(): ProfilerDataCollector {
1463
		return $this->pimple['profiler_data_collector'];
1464
	}
1465
1466
	private function newIbanValidator(): KontoCheckIbanValidator {
1467
		return new KontoCheckIbanValidator( $this->newBankDataConverter(), $this->config['banned-ibans'] );
1468
	}
1469
1470
	public function setFilePrefixer( FilePrefixer $prefixer ): void {
1471
		$this->pimple['cachebusting_fileprefixer'] = $prefixer;
1472
	}
1473
1474
	private function getFilePrefixer(): FilePrefixer {
1475
		return $this->pimple['cachebusting_fileprefixer'];
1476
	}
1477
1478
	private function getFilePrefix(): string {
1479
		$prefixContentFile = $this->getVarPath() . '/file_prefix.txt';
1480
		if ( !file_exists( $prefixContentFile ) ) {
1481
			return '';
1482
		}
1483
		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...
1484
	}
1485
1486
	public function newDonationAcceptedEventHandler( string $updateToken ): DonationAcceptedEventHandler {
1487
		return new DonationAcceptedEventHandler(
1488
			$this->newDonationAuthorizer( $updateToken ),
1489
			$this->getDonationRepository(),
1490
			$this->newDonationConfirmationMailer()
1491
		);
1492
	}
1493
1494
	public function newPageNotFoundHtmlPresenter(): PageNotFoundPresenter {
1495
		return new PageNotFoundPresenter( $this->getLayoutTemplate( 'Page_not_found.html.twig' ) );
1496
	}
1497
1498
	public function setPageViewTracker( PageViewTracker $tracker ): void {
1499
		$this->pimple['page_view_tracker'] = function () use ( $tracker )  {
1500
			return $tracker;
1501
		};
1502
	}
1503
1504
	public function getPageViewTracker(): PageViewTracker {
1505
		return $this->pimple['page_view_tracker'];
1506
	}
1507
1508
	public function newServerSideTracker(): ServerSideTracker {
1509
		// the "https:" prefix does NOT get any slashes because baseURL is stored in a protocol-agnostic way
1510
		// (e.g. "//tracking.wikimedia.de" )
1511
		return new PiwikServerSideTracker(
1512
			new \PiwikTracker( $this->config['piwik']['siteId'], 'https:' . $this->config['piwik']['baseUrl'] )
1513
		);
1514
	}
1515
1516
	public function getI18nDirectory(): string {
1517
		return $this->getAbsolutePath( $this->config['i18n-base-path'] ) . '/' . $this->config['locale'];
1518
	}
1519
1520
	/**
1521
	 * If the pathname does not start with a slash, make the path absolute to root dir of application
1522
	 */
1523
	private function getAbsolutePath( string $path ): string {
1524
		if ( $path[0] === '/' ) {
1525
			return $path;
1526
		}
1527
		return __DIR__ . '/../../' . $path;
1528
	}
1529
1530
	public function setContentPagePageSelector( PageSelector $pageSelector ): void {
1531
		$this->pimple['content_page_selector'] = $pageSelector;
1532
	}
1533
1534
	public function getContentPagePageSelector(): PageSelector {
1535
		return $this->pimple['content_page_selector'];
1536
	}
1537
1538
	public function setContentProvider( ContentProvider $contentProvider ): void {
1539
		$this->pimple['content_provider'] = $contentProvider;
1540
	}
1541
1542
	private function getContentProvider(): ContentProvider {
1543
		return $this->pimple['content_provider'];
1544
	}
1545
1546
	public function newMailTemplateFilenameTraversable(): MailTemplateFilenameTraversable {
1547
		return new MailTemplateFilenameTraversable(
1548
			$this->config['mailer-twig']['loaders']['filesystem']['template-dir']
1549
		);
1550
	}
1551
1552
	public function getUrlGenerator(): UrlGenerator {
1553
		return $this->pimple['url_generator'];
1554
	}
1555
1556
	public function setUrlGenerator( UrlGenerator $urlGenerator ): void {
1557
		$this->pimple['url_generator'] = $urlGenerator;
1558
	}
1559
1560
	public function getCookieBuilder(): CookieBuilder {
1561
		return $this->pimple['cookie-builder'];
1562
	}
1563
1564
	public function getSkinSettings(): SkinSettings {
1565
		return $this->pimple['skin-settings'];
1566
	}
1567
1568
	public function getPaymentTypesSettings(): PaymentTypesSettings {
1569
		return $this->pimple['payment-types-settings'];
1570
	}
1571
}
1572