|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use App\Entity\ActiveDirectoryGradeSyncOption; |
|
6
|
|
|
use App\Form\ActiveDirectoryGradeSyncOptionType; |
|
7
|
|
|
use App\Repository\ActiveDirectoryGradeSyncOptionRepositoryInterface; |
|
8
|
|
|
use SchulIT\CommonBundle\Form\ConfirmType; |
|
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
10
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
11
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
12
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
|
13
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
14
|
|
|
|
|
15
|
|
|
#[Route(path: '/admin/ad_sync/grades')] |
|
16
|
|
|
class ActiveDirectoryGradeSyncOptionController extends AbstractController { |
|
17
|
|
|
|
|
18
|
|
|
public function __construct(private ActiveDirectoryGradeSyncOptionRepositoryInterface $repository) |
|
19
|
|
|
{ |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
#[Route(path: '', name: 'ad_grades_sync_options')] |
|
23
|
|
|
public function index(): Response { |
|
24
|
|
|
$options = $this->repository->findAll(); |
|
25
|
|
|
|
|
26
|
|
|
return $this->render('ad_sync_options/grades/index.html.twig', [ |
|
27
|
|
|
'sync_options' => $options |
|
28
|
|
|
]); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
#[Route(path: '/add', name: 'add_ad_grades_sync_options')] |
|
32
|
|
|
public function add(Request $request): Response { |
|
33
|
|
|
$option = new ActiveDirectoryGradeSyncOption(); |
|
34
|
|
|
|
|
35
|
|
|
$form = $this->createForm(ActiveDirectoryGradeSyncOptionType::class, $option); |
|
36
|
|
|
$form->handleRequest($request); |
|
37
|
|
|
|
|
38
|
|
|
if($form->isSubmitted() && $form->isValid()) { |
|
39
|
|
|
$this->repository->persist($option); |
|
40
|
|
|
|
|
41
|
|
|
$this->addFlash('success', 'ad_sync_options.grades.add.success'); |
|
42
|
|
|
return $this->redirectToRoute('ad_grades_sync_options'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
return $this->render('ad_sync_options/grades/add.html.twig', [ |
|
46
|
|
|
'form' => $form->createView() |
|
47
|
|
|
]); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
#[Route(path: '/{uuid}/edit', name: 'edit_ad_grades_sync_options')] |
|
51
|
|
|
public function edit(Request $request, ActiveDirectoryGradeSyncOption $option): Response { |
|
52
|
|
|
$form = $this->createForm(ActiveDirectoryGradeSyncOptionType::class, $option); |
|
53
|
|
|
$form->handleRequest($request); |
|
54
|
|
|
|
|
55
|
|
|
if($form->isSubmitted() && $form->isValid()) { |
|
56
|
|
|
$this->repository->persist($option); |
|
57
|
|
|
|
|
58
|
|
|
$this->addFlash('success', 'ad_sync_options.grades.add.success'); |
|
59
|
|
|
return $this->redirectToRoute('ad_grades_sync_options'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return $this->render('ad_sync_options/grades/edit.html.twig', [ |
|
63
|
|
|
'form' => $form->createView(), |
|
64
|
|
|
'option' => $option |
|
65
|
|
|
]); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
#[Route(path: '/{uuid}/remove', name: 'remove_ad_grades_sync_options')] |
|
69
|
|
|
public function remove(ActiveDirectoryGradeSyncOption $option, Request $request, TranslatorInterface $translator): Response { |
|
70
|
|
|
$form = $this->createForm(ConfirmType::class, [], [ |
|
71
|
|
|
'message' => $translator->trans('ad_sync_options.grades.remove.confirm', [ |
|
72
|
|
|
'%grade%' => $option->getGrade() |
|
73
|
|
|
]), |
|
74
|
|
|
'label' => 'ad_sync_options.grades.remove.label' |
|
75
|
|
|
]); |
|
76
|
|
|
$form->handleRequest($request); |
|
77
|
|
|
|
|
78
|
|
|
if($form->isSubmitted() && $form->isValid()) { |
|
79
|
|
|
$this->repository->remove($option); |
|
80
|
|
|
|
|
81
|
|
|
$this->addFlash('success', 'ad_sync_options.grades.remove.success'); |
|
82
|
|
|
return $this->redirectToRoute('ad_grades_sync_options'); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
return $this->render('ad_sync_options/grades/remove.html.twig', [ |
|
86
|
|
|
'form' => $form->createView(), |
|
87
|
|
|
'option' => $option |
|
88
|
|
|
]); |
|
89
|
|
|
} |
|
90
|
|
|
} |