|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Frontend\App\Controllers\AddressChange; |
|
6
|
|
|
|
|
7
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
8
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
9
|
|
|
use WMDE\Fundraising\Frontend\App\AccessDeniedException; |
|
10
|
|
|
use WMDE\Fundraising\Frontend\App\Routes; |
|
11
|
|
|
use WMDE\Fundraising\Frontend\Factories\FunFunFactory; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @license GPL-2.0-or-later |
|
15
|
|
|
*/ |
|
16
|
|
|
class ShowUpdateAddressController { |
|
17
|
|
|
|
|
18
|
|
|
public const ADDRESS_CHANGE_SESSION_KEY = 'address_changed'; |
|
19
|
|
|
|
|
20
|
|
|
public function index( Request $request, FunFunFactory $ffFactory ): Response { |
|
21
|
|
|
$addressToken = $request->get( 'addressToken', '' ); |
|
22
|
|
|
if ( $addressToken === '' ) { |
|
23
|
|
|
throw new AccessDeniedException(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
$addressChangeRepository = $ffFactory->newAddressChangeRepository(); |
|
27
|
|
|
$addressChange = $addressChangeRepository->getAddressChangeByUuid( $addressToken ); |
|
28
|
|
|
if ( $addressChange === null ) { |
|
29
|
|
|
throw new AccessDeniedException(); |
|
30
|
|
|
} |
|
31
|
|
|
return new Response( |
|
32
|
|
|
$ffFactory->getLayoutTemplate( 'Update_Address.html.twig' )->render( |
|
33
|
|
|
[ |
|
34
|
|
|
'addressToken' => $addressToken, |
|
35
|
|
|
'isCompany' => $addressChange->isCompanyAddress(), |
|
36
|
|
|
'countries' => $ffFactory->getCountries(), |
|
37
|
|
|
'addressValidationPatterns' => $ffFactory->getValidationRules()->address, |
|
38
|
|
|
'urls' => array_merge( |
|
39
|
|
|
Routes::getNamedRouteUrls( $ffFactory->getUrlGenerator() ), |
|
40
|
|
|
[ |
|
41
|
|
|
'updateAddress' => $ffFactory->getUrlGenerator()->generateAbsoluteUrl( Routes::UPDATE_ADDRESS, [ 'addressToken' => $addressToken ] ) |
|
42
|
|
|
] |
|
43
|
|
|
) |
|
44
|
|
|
] |
|
45
|
|
|
) |
|
46
|
|
|
); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|