| @@ 101-125 (lines=25) @@ | ||
| 98 | * @Method("POST") |
|
| 99 | * @Template("AppBundle:Group:new.html.twig") |
|
| 100 | */ |
|
| 101 | public function createAction(Request $request) |
|
| 102 | { |
|
| 103 | $group = new Group(); |
|
| 104 | $form = $this->createForm(new GroupType(), $group); |
|
| 105 | $form->add('roles', 'choice', array( |
|
| 106 | 'choices' => $this->getExistingRoles(), |
|
| 107 | 'data' => $group->getRoles(), |
|
| 108 | 'label' => 'Roles', |
|
| 109 | 'expanded' => true, |
|
| 110 | 'multiple' => true, |
|
| 111 | 'mapped' => true, |
|
| 112 | )); |
|
| 113 | if ($form->handleRequest($request)->isValid()) { |
|
| 114 | $em = $this->getDoctrine()->getManager(); |
|
| 115 | $em->persist($group); |
|
| 116 | $em->flush(); |
|
| 117 | ||
| 118 | return $this->redirectToRoute('admin_groups_show', array('id', $group->getId())); |
|
| 119 | } |
|
| 120 | ||
| 121 | return array( |
|
| 122 | 'group' => $group, |
|
| 123 | 'form' => $form->createView(), |
|
| 124 | ); |
|
| 125 | } |
|
| 126 | ||
| 127 | /** |
|
| 128 | * Displays a form to edit an existing Group entity. |
|
| @@ 152-173 (lines=22) @@ | ||
| 149 | * @Method("PUT") |
|
| 150 | * @Template("AppBundle:User:edit.html.twig") |
|
| 151 | */ |
|
| 152 | public function updateAction(User $user, Request $request) |
|
| 153 | { |
|
| 154 | $editForm = $this->createForm(new UserType(), $user, array( |
|
| 155 | 'action' => $this->generateUrl('admin_users_update', array('id' => $user->getId())), |
|
| 156 | 'method' => 'PUT', |
|
| 157 | 'passwordRequired' => false, |
|
| 158 | 'lockedRequired' => true |
|
| 159 | )); |
|
| 160 | if ($editForm->handleRequest($request)->isValid()) { |
|
| 161 | $userManager = $this->get('fos_user.user_manager'); |
|
| 162 | $userManager->updateUser($user); |
|
| 163 | ||
| 164 | return $this->redirectToRoute('admin_users_edit', array('id' => $user->getId())); |
|
| 165 | } |
|
| 166 | $deleteForm = $this->createDeleteForm($user->getId(), 'admin_users_delete'); |
|
| 167 | ||
| 168 | return array( |
|
| 169 | 'user' => $user, |
|
| 170 | 'edit_form' => $editForm->createView(), |
|
| 171 | 'delete_form' => $deleteForm->createView(), |
|
| 172 | ); |
|
| 173 | } |
|
| 174 | ||
| 175 | ||
| 176 | /** |
|