@@ 221-259 (lines=39) @@ | ||
218 | * @param $identityId |
|
219 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
|
220 | */ |
|
221 | public function amendRaInformationAction(Request $request, $identityId) |
|
222 | { |
|
223 | $this->denyAccessUnlessGranted(['ROLE_RAA', 'ROLE_SRAA']); |
|
224 | ||
225 | $logger = $this->get('logger'); |
|
226 | $logger->notice(sprintf("Loading information amendment form for RA(A) '%s'", $identityId)); |
|
227 | ||
228 | $raListing = $this->getRaListingService()->get($identityId, $this->getUser()->institution); |
|
229 | ||
230 | if (!$raListing) { |
|
231 | $logger->warning(sprintf("RA listing for identity ID '%s' not found", $identityId)); |
|
232 | throw new NotFoundHttpException(sprintf("RA listing for identity ID '%s' not found", $identityId)); |
|
233 | } |
|
234 | ||
235 | $command = new AmendRegistrationAuthorityInformationCommand(); |
|
236 | $command->identityId = $raListing->identityId; |
|
237 | $command->location = $this->getUser()->institution; |
|
238 | $command->contactInformation = $raListing->contactInformation; |
|
239 | ||
240 | $form = $this->createForm(AmendRegistrationAuthorityInformationType::class, $command)->handleRequest($request); |
|
241 | if ($form->isSubmitted() && $form->isValid()) { |
|
242 | $logger->notice(sprintf("RA(A) '%s' information amendment form submitted, processing", $identityId)); |
|
243 | ||
244 | if ($this->get('ra.service.ra')->amendRegistrationAuthorityInformation($command)) { |
|
245 | $this->addFlash('success', $this->get('translator')->trans('ra.management.amend_ra_info.info_amended')); |
|
246 | ||
247 | $logger->notice(sprintf("RA(A) '%s' information successfully amended", $identityId)); |
|
248 | return $this->redirectToRoute('ra_management_manage'); |
|
249 | } |
|
250 | ||
251 | $logger->notice(sprintf("Information of RA(A) '%s' failed to be amended, informing user", $identityId)); |
|
252 | $this->addFlash('error', 'ra.management.amend_ra_info.error.middleware_command_failed'); |
|
253 | } |
|
254 | ||
255 | return $this->render('SurfnetStepupRaRaBundle:RaManagement:amendRaInformation.html.twig', [ |
|
256 | 'raListing' => $raListing, |
|
257 | 'form' => $form->createView(), |
|
258 | ]); |
|
259 | } |
|
260 | ||
261 | /** |
|
262 | * @param Request $request |
|
@@ 266-303 (lines=38) @@ | ||
263 | * @param $identityId |
|
264 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
|
265 | */ |
|
266 | public function changeRaRoleAction(Request $request, $identityId) |
|
267 | { |
|
268 | $this->denyAccessUnlessGranted(['ROLE_RAA', 'ROLE_SRAA']); |
|
269 | $logger = $this->get('logger'); |
|
270 | ||
271 | $logger->notice(sprintf("Loading change Ra Role form for RA(A) '%s'", $identityId)); |
|
272 | ||
273 | $raListing = $this->getRaListingService()->get($identityId, $this->getUser()->institution); |
|
274 | if (!$raListing) { |
|
275 | $logger->warning(sprintf("RA listing for identity ID '%s' not found", $identityId)); |
|
276 | throw new NotFoundHttpException(sprintf("RA listing for identity ID '%s' not found", $identityId)); |
|
277 | } |
|
278 | ||
279 | $command = new ChangeRaRoleCommand(); |
|
280 | $command->identityId = $raListing->identityId; |
|
281 | $command->institution = $this->getUser()->institution; |
|
282 | $command->role = $raListing->role; |
|
283 | ||
284 | $form = $this->createForm(ChangeRaRoleType::class, $command)->handleRequest($request); |
|
285 | if ($form->isSubmitted() && $form->isValid()) { |
|
286 | $logger->notice(sprintf('RA(A) "%s" Change Role form submitted, processing', $identityId)); |
|
287 | ||
288 | if ($this->get('ra.service.ra')->changeRegistrationAuthorityRole($command)) { |
|
289 | $logger->notice('Role successfully changed'); |
|
290 | ||
291 | $this->addFlash('success', $this->get('translator')->trans('ra.management.change_ra_role_changed')); |
|
292 | return $this->redirectToRoute('ra_management_manage'); |
|
293 | } |
|
294 | ||
295 | $logger->notice(sprintf('Role of RA(A) "%s" could not be changed, informing user', $identityId)); |
|
296 | $this->addFlash('error', 'ra.management.change_ra_role.middleware_command_failed'); |
|
297 | } |
|
298 | ||
299 | return $this->render('SurfnetStepupRaRaBundle:RaManagement:changeRaRole.html.twig', [ |
|
300 | 'raListing' => $raListing, |
|
301 | 'form' => $form->createView() |
|
302 | ]); |
|
303 | } |
|
304 | ||
305 | /** |
|
306 | * @param Request $request |