@@ 68-83 (lines=16) @@ | ||
65 | * @param User $user |
|
66 | * @return RedirectResponse |
|
67 | */ |
|
68 | public function activationAction(Request $request, User $user) |
|
69 | { |
|
70 | $em = $this->getDoctrine()->getManager(); |
|
71 | $form = $this->createForm(ActivationType::class, $user, [ |
|
72 | 'method' => "PUT", |
|
73 | 'action' => $this->generateUrl('activate_user', array('id' => $user->getId())), |
|
74 | 'validation_groups' => array('edit'), |
|
75 | ]); |
|
76 | $form->handleRequest($request); |
|
77 | if ($form->isValid()) { |
|
78 | $em->persist($user); |
|
79 | $em->flush(); |
|
80 | } |
|
81 | ||
82 | return $this->redirect($this->generateUrl("users_list")); |
|
83 | } |
|
84 | ||
85 | /** |
|
86 | * @Route("/user/add", name="add_user") |
|
@@ 92-109 (lines=18) @@ | ||
89 | * @param Request $request |
|
90 | * @return array|RedirectResponse |
|
91 | */ |
|
92 | public function addAction(Request $request) |
|
93 | { |
|
94 | $em = $this->getDoctrine()->getManager(); |
|
95 | $user = new User(); |
|
96 | $form = $this->createForm(RegistrationType::class, $user, [ |
|
97 | 'action' => $this->generateUrl('add_user'), |
|
98 | 'validation_groups' => array('registration'), |
|
99 | ]); |
|
100 | $form->handleRequest($request); |
|
101 | if ($form->isValid()) { |
|
102 | $em->persist($user); |
|
103 | $em->flush(); |
|
104 | ||
105 | return $this->redirect($this->generateUrl("users_list")); |
|
106 | } |
|
107 | ||
108 | return ['form' => $form->createView()]; |
|
109 | } |
|
110 | ||
111 | /** |
|
112 | * @Route("/user/edit/{id}", name="edit_user") |
|
@@ 119-136 (lines=18) @@ | ||
116 | * @param User $user |
|
117 | * @return array|RedirectResponse |
|
118 | */ |
|
119 | public function editAction(Request $request, User $user) |
|
120 | { |
|
121 | $em = $this->getDoctrine()->getManager(); |
|
122 | $form = $this->createForm(EditType::class, $user, [ |
|
123 | 'action' => $this->generateUrl('edit_user', array('id' => $user->getId())), |
|
124 | 'method' => 'POST', |
|
125 | 'validation_groups' => array('edit'), |
|
126 | ]); |
|
127 | $form->handleRequest($request); |
|
128 | if ($form->isValid()) { |
|
129 | $em->persist($user); |
|
130 | $em->flush(); |
|
131 | ||
132 | return $this->redirect($this->generateUrl("users_list")); |
|
133 | } |
|
134 | ||
135 | return ['form' => $form->createView()]; |
|
136 | } |
|
137 | } |
|
138 |