1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the TheAlternativeZurich/events project. |
5
|
|
|
* |
6
|
|
|
* (c) Florian Moser <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace App\Controller; |
13
|
|
|
|
14
|
|
|
use App\Controller\Base\BaseDoctrineController; |
15
|
|
|
use App\Entity\Registration; |
16
|
|
|
use App\Form\Registration\EditType; |
17
|
|
|
use App\Security\Voter\RegistrationVoter; |
18
|
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
19
|
|
|
use Symfony\Component\HttpFoundation\Request; |
20
|
|
|
use Symfony\Component\HttpFoundation\Response; |
21
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
22
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @Route("/registration") |
26
|
|
|
*/ |
27
|
|
|
class RegistrationController extends BaseDoctrineController |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @Route("/{registration}/update", name="registration_update") |
31
|
|
|
* |
32
|
|
|
* @return Response |
33
|
|
|
*/ |
34
|
|
|
public function updateAction(Request $request, Registration $registration, TranslatorInterface $translator) |
35
|
|
|
{ |
36
|
|
|
$this->denyAccessUnlessGranted(RegistrationVoter::REGISTRATION_UPDATE, $registration); |
37
|
|
|
|
38
|
|
|
$form = $this->createForm(EditType::class, $registration) |
39
|
|
|
->add('submit', SubmitType::class, ['translation_domain' => 'registration', 'label' => 'update.submit']); |
40
|
|
|
$form->handleRequest($request); |
41
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
42
|
|
|
$this->fastSave($registration); |
43
|
|
|
|
44
|
|
|
$message = $translator->trans('update.success.updated', [], 'registration'); |
45
|
|
|
$this->displaySuccess($message); |
46
|
|
|
|
47
|
|
|
return $this->redirectToRoute('register', ['identifier' => $registration->getEvent()->getIdentifier()]); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $this->render('registration/update.html.twig', ['form' => $form->createView()]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @Route("/{registration}/delete", name="registration_delete") |
55
|
|
|
* |
56
|
|
|
* @return Response |
57
|
|
|
*/ |
58
|
|
|
public function deleteAction(Request $request, Registration $registration, TranslatorInterface $translator) |
59
|
|
|
{ |
60
|
|
|
$this->denyAccessUnlessGranted(RegistrationVoter::REGISTRATION_DELETE, $registration); |
61
|
|
|
|
62
|
|
|
if ($request->query->has('confirm')) { |
63
|
|
|
$this->fastRemove($registration); |
64
|
|
|
|
65
|
|
|
$message = $translator->trans('delete.success.deleted', [], 'registration'); |
66
|
|
|
$this->displaySuccess($message); |
67
|
|
|
|
68
|
|
|
return $this->redirectToRoute('register', ['identifier' => $registration->getEvent()->getIdentifier()]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $this->render('registration/delete.html.twig', ['registration' => $registration]); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|