Code Duplication    Length = 22-25 lines in 2 locations

src/AppBundle/Controller/GroupController.php 1 location

@@ 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.

src/AppBundle/Controller/UserController.php 1 location

@@ 151-172 (lines=22) @@
148
     * @Method("PUT")
149
     * @Template("AppBundle:User:edit.html.twig")
150
     */
151
    public function updateAction(User $user, Request $request)
152
    {
153
        $editForm = $this->createForm(new UserType(), $user, array(
154
            'action' => $this->generateUrl('admin_users_update', array('id' => $user->getId())),
155
            'method' => 'PUT',
156
            'passwordRequired' => false,
157
            'lockedRequired' => true
158
        ));
159
        if ($editForm->handleRequest($request)->isValid()) {
160
            $userManager = $this->get('fos_user.user_manager');
161
            $userManager->updateUser($user);
162
163
            return $this->redirectToRoute('admin_users_edit', array('id' => $user->getId()));
164
        }
165
        $deleteForm = $this->createDeleteForm($user->getId(), 'admin_users_delete');
166
167
        return array(
168
            'user' => $user,
169
            'edit_form'   => $editForm->createView(),
170
            'delete_form' => $deleteForm->createView(),
171
        );
172
    }
173
174
175
    /**