Completed
Push — master ( 906179...917cbb )
by Jeroen De
149:06 queued 84:07
created

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