bonjour,
j'ai un probleme au niveau du formulaire , je sais pas d'ou viens la deuxieme liste deroulante avec par defaut role : User
securité config :
Controlleur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 # role_hierarchy: # ROLE_USER: ROLE_USER # ROLE_EDITOR: [ROLE_EDITOR, ROLE_USER] # ROLE_SUPERSOL: [ROLE_SUPERSOL, ROLE_EDITOR, ROLE_USER] # ROLE_ADMIN: [ROLE_ADMIN ,ROLE_SUPERSOL, ROLE_EDITOR, ROLE_USER] # ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] security: encoders: FOS\UserBundle\Model\UserInterface: sha512 role_hierarchy: ROLE_USER: ROLE_USER ROLE_EDITOR: [ROLE_EDITOR, ROLE_USER] ROLE_SUPERSOL: [ROLE_SUPERSOL, ROLE_EDITOR, ROLE_USER] ROLE_ADMIN: [ROLE_ADMIN ,ROLE_SUPERSOL, ROLE_EDITOR, ROLE_USER] ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: fos_userbundle: id: fos_user.user_provider.username firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider # default_target_path: my_app_esprit_homepage success_handler: security.authentication.customized_success_handler # default_target_path: fos_user_security_login /*la page a redirect to*/ remember_me: true # On active la possibilité du "Se souvenir de moi" (désactivé par défaut)# remember_me: key: %secret% # On définit la clé pour le remember_me (%secret% est un parametre de parameters.ini) logout: path: fos_user_security_logout target: /index.php anonymous: true access_control: - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/administration/, role: ROLE_ADMIN } ## ajout de sujet permis au user connecté # - { path: ^/sujet/add, role: ROLE_USER }
merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 <?php namespace MyApp\UserBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class UserController extends Controller { public function showAction(Request $request) { $em = $this->getDoctrine()->getManager(); /* $sql = 'TRUNCATE TABLE user;'; $connection = $em->getConnection(); $stmt = $connection->prepare($sql); $stmt->execute(); $stmt->closeCursor(); */ $user = $em->getRepository('MyAppUserBundle:user')->findAll(); return $this->render('MyAppUserBundle:User:show.html.twig', array( 'user' => $user )); } public function deleteAction($id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('MyAppUserBundle:user')->find($id); if (!$user) { throw $this->createNotFoundException('No user found for id ' . $id); } $em->remove($user); $em->flush(); $this->get('session')->getFlashBag()->set('message', 'Ce user disparait !!'); return $this->redirect($this->generateUrl('my_app_user_show')); } public function editAction($id, Request $request) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('MyAppUserBundle:user')->find($id); if (!$user) { throw $this->createNotFoundException( 'no Utilisateur found for id ' . $id ); } $form = $this->createFormBuilder($user) ->add('username', 'text') ->add('enabled', 'checkbox', array('required' => false)) ->add('roles', 'collection', array( 'type' => 'choice', 'options' => array( 'label' => false, /* Ajoutez cette ligne */ 'choices' => array( 'ROLE_ADMIN' => 'Admin', 'ROLE_SUPER_ADMIN' => 'Superadmin', 'ROLE_SUPERSOL' => 'Supersol', 'ROLE_EDITOR' => 'Editor', 'ROLE_USER' => 'User', )))) ->getForm(); $form->handleRequest($request); if ($form->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('my_app_user_show')); } return $this->render('MyAppUserBundle:user:edit.html.twig', array( 'form' => $form->createView(), 'user' => $user, )); } }
Partager