1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ribs\RibsAdminBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Ribs\RibsAdminBundle\Entity\AccessRight; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7
|
|
|
use Symfony\Component\Form\Form; |
8
|
|
|
use Symfony\Component\HttpFoundation\Request; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
11
|
|
|
|
12
|
|
|
class AccessRightsController extends Controller |
13
|
|
|
{ |
14
|
|
|
//---------------------------------------------- VIEWS METHODS ---------------------------------------------------------// |
15
|
|
|
/** |
16
|
|
|
* @Route("/access-rights-management/", name="ribsadmin_access_rights") |
17
|
|
|
* @return Response |
18
|
|
|
*/ |
19
|
|
|
public function listAction(): Response |
20
|
|
|
{ |
21
|
|
|
$em = $this->getDoctrine()->getManager(); |
22
|
|
|
$acces_right = $em->getRepository("RibsAdminBundle:AccessRight")->findAll(); |
23
|
|
|
|
24
|
|
|
return $this->render("@RibsAdmin/access-rights/list-all-list.html.twig", [ |
25
|
|
|
"access_right" => $acces_right |
26
|
|
|
]); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @Route("/access-rights-management/create/", name="ribsadmin_access_rights_create") |
31
|
|
|
* @Route("/access-rights-management/edit/{guid}", name="ribsadmin_access_rights_edit") |
32
|
|
|
* @param Request $request |
33
|
|
|
* @param string|null $guid |
34
|
|
|
* @return Response |
35
|
|
|
*/ |
36
|
|
|
public function editAction(Request $request, string $guid = null): Response |
37
|
|
|
{ |
38
|
|
|
$em = $this->getDoctrine()->getManager(); |
39
|
|
|
$list_rights_user = []; |
40
|
|
|
|
41
|
|
|
if ($guid === null) { |
42
|
|
|
$access_right = new AccessRight(); |
43
|
|
|
} else { |
44
|
|
|
$access_right = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]); |
45
|
|
|
$list_rights_user = explode(",", $access_right->getAccessRights()); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$form = $this->createForm("Ribs\RibsAdminBundle\Form\AccessRight", $access_right); |
49
|
|
|
$form->handleRequest($request); |
50
|
|
|
|
51
|
|
|
if ($form->isValid() && $form->isSubmitted()) { |
52
|
|
|
return $this->handleEditForm($request, $form, $access_right); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $this->render("@RibsAdmin/access-rights/edit-list.html.twig", [ |
56
|
|
|
"access_right" => $access_right, |
57
|
|
|
"form" => $form->createView(), |
58
|
|
|
"list_rights_user" => $list_rights_user, |
59
|
|
|
"ribs_admin_rights" => json_decode(file_get_contents($this->get("ribs_admin.globals")->getBaseBundlePath() . "/Resources/json/ribsadmin_rights.json")) |
60
|
|
|
]); |
61
|
|
|
} |
62
|
|
|
//---------------------------------------------- END VIEWS METHODS ---------------------------------------------------------// |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param Request $request |
66
|
|
|
* @param Form $form |
67
|
|
|
* @param AccessRight $access_right |
68
|
|
|
* in dev |
69
|
|
|
*/ |
70
|
|
|
private function handleEditForm(Request $request, Form $form, AccessRight $access_right) { |
71
|
|
|
dump($request); |
|
|
|
|
72
|
|
|
dump($form); |
73
|
|
|
dump($access_right); |
74
|
|
|
die(); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
} |