| @@ 58-73 (lines=16) @@ | ||
| 55 | * @param User $user |
|
| 56 | * @return RedirectResponse |
|
| 57 | */ |
|
| 58 | public function activationAction(Request $request, User $user) |
|
| 59 | { |
|
| 60 | $em = $this->getDoctrine()->getManager(); |
|
| 61 | $form = $this->createForm(ActivationType::class, $user, [ |
|
| 62 | 'method' => "PUT", |
|
| 63 | 'action' => $this->generateUrl('activate_user', array('id' => $user->getId())), |
|
| 64 | 'validation_groups' => array('edit'), |
|
| 65 | ]); |
|
| 66 | $form->handleRequest($request); |
|
| 67 | if ($form->isValid()) { |
|
| 68 | $em->persist($user); |
|
| 69 | $em->flush(); |
|
| 70 | return $this->redirect($this->generateUrl("users_list")); |
|
| 71 | } |
|
| 72 | return $this->redirect($this->generateUrl("users_list")); |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @Route("/user/add", name="add_user") |
|
| @@ 107-122 (lines=16) @@ | ||
| 104 | * @param User $user |
|
| 105 | * @return array|RedirectResponse |
|
| 106 | */ |
|
| 107 | public function userEditAction(Request $request, User $user) |
|
| 108 | { |
|
| 109 | $em = $this->getDoctrine()->getManager(); |
|
| 110 | $form = $this->createForm(EditType::class, $user, [ |
|
| 111 | 'action' => $this->generateUrl('edit_user', array('id' => $user->getId())), |
|
| 112 | 'method' => 'POST', |
|
| 113 | 'validation_groups' => array('edit'), |
|
| 114 | ]); |
|
| 115 | $form->handleRequest($request); |
|
| 116 | if ($form->isValid()) { |
|
| 117 | $em->persist($user); |
|
| 118 | $em->flush(); |
|
| 119 | return $this->redirect($this->generateUrl("users_list")); |
|
| 120 | } |
|
| 121 | return ['form' => $form->createView()]; |
|
| 122 | } |
|
| 123 | } |
|
| 124 | ||