|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2017 SURFnet B.V. |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace OpenConext\ProfileBundle\Controller; |
|
20
|
|
|
|
|
21
|
|
|
use OpenConext\ProfileBundle\Attribute\AttributeFilter; |
|
22
|
|
|
use OpenConext\ProfileBundle\Form\Type\InformationRequestMailType; |
|
23
|
|
|
use OpenConext\ProfileBundle\Security\Guard; |
|
24
|
|
|
use OpenConext\ProfileBundle\Service\InformationRequestMailService; |
|
25
|
|
|
use OpenConext\ProfileBundle\Service\UserService; |
|
26
|
|
|
use Symfony\Component\Form\FormFactoryInterface; |
|
27
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
|
28
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
29
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
30
|
|
|
use Symfony\Component\Templating\EngineInterface; |
|
31
|
|
|
|
|
32
|
|
|
class InformationRequestController |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @var Guard |
|
36
|
|
|
*/ |
|
37
|
|
|
private $guard; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var EngineInterface |
|
41
|
|
|
*/ |
|
42
|
|
|
private $templateEngine; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var FormFactoryInterface |
|
46
|
|
|
*/ |
|
47
|
|
|
private $formFactory; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var UrlGeneratorInterface |
|
51
|
|
|
*/ |
|
52
|
|
|
private $urlGenerator; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var UserService |
|
56
|
|
|
*/ |
|
57
|
|
|
private $userService; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var InformationRequestMailService |
|
61
|
|
|
*/ |
|
62
|
|
|
private $informationRequestMailService; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var AttributeFilter |
|
66
|
|
|
*/ |
|
67
|
|
|
private $attributeFilter; |
|
68
|
|
|
|
|
69
|
|
|
public function __construct( |
|
70
|
|
|
Guard $guard, |
|
71
|
|
|
EngineInterface $templateEngine, |
|
72
|
|
|
FormFactoryInterface $formFactory, |
|
73
|
|
|
UrlGeneratorInterface $urlGenerator, |
|
74
|
|
|
UserService $userService, |
|
75
|
|
|
AttributeFilter $attributeFilter, |
|
76
|
|
|
InformationRequestMailService $informationRequestMailService |
|
77
|
|
|
) { |
|
78
|
|
|
$this->guard = $guard; |
|
79
|
|
|
$this->templateEngine = $templateEngine; |
|
80
|
|
|
$this->formFactory = $formFactory; |
|
81
|
|
|
$this->urlGenerator = $urlGenerator; |
|
82
|
|
|
$this->userService = $userService; |
|
83
|
|
|
$this->attributeFilter = $attributeFilter; |
|
84
|
|
|
$this->informationRequestMailService = $informationRequestMailService; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function overviewAction() |
|
88
|
|
|
{ |
|
89
|
|
|
$this->guard->userIsLoggedIn(); |
|
90
|
|
|
|
|
91
|
|
|
$informationRequestMailForm = $this->formFactory->create( |
|
92
|
|
|
InformationRequestMailType::class, |
|
93
|
|
|
null, |
|
94
|
|
|
['action' => $this->urlGenerator->generate('profile.information_request_send_mail')] |
|
95
|
|
|
); |
|
96
|
|
|
|
|
97
|
|
|
$attributes = $this->attributeFilter->filter($this->userService->getUser()->getAttributes()); |
|
98
|
|
|
|
|
99
|
|
|
return new Response( |
|
100
|
|
|
$this->templateEngine->render( |
|
101
|
|
|
'OpenConextProfileBundle:InformationRequest:overview.html.twig', |
|
102
|
|
|
[ |
|
103
|
|
|
'attributes' => $attributes, |
|
104
|
|
|
'informationRequestMailForm' => $informationRequestMailForm->createView() |
|
105
|
|
|
] |
|
106
|
|
|
) |
|
107
|
|
|
); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function sendMailAction() |
|
111
|
|
|
{ |
|
112
|
|
|
$this->guard->userIsLoggedIn(); |
|
113
|
|
|
|
|
114
|
|
|
$this->informationRequestMailService->sendInformationRequestMail(); |
|
115
|
|
|
|
|
116
|
|
|
return new RedirectResponse($this->urlGenerator->generate('profile.information_request_confirm_mail_sent')); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function confirmMailSentAction() |
|
120
|
|
|
{ |
|
121
|
|
|
$this->guard->userIsLoggedIn(); |
|
122
|
|
|
|
|
123
|
|
|
return new Response( |
|
124
|
|
|
$this->templateEngine->render('OpenConextProfileBundle:InformationRequest:confirmation.html.twig') |
|
125
|
|
|
); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|