Code Duplication    Length = 7-8 lines in 3 locations

src/system/GroupsModule/Controller/MembershipController.php 3 locations

@@ 120-127 (lines=8) @@
117
118
        if ($userEntity->getGroups()->contains($group)) {
119
            $this->addFlash('warning', $this->__('The selected user is already a member of this group.'));
120
        } else {
121
            $userEntity->addGroup($group);
122
            $this->get('doctrine')->getManager()->flush();
123
            $this->addFlash('status', $this->__('Done! The user was added to the group.'));
124
            // Let other modules know that we have updated a group.
125
            $addUserEvent = new GenericEvent(['gid' => $group->getGid(), 'uid' => $userEntity->getUid()]);
126
            $this->get('event_dispatcher')->dispatch(GroupEvents::GROUP_ADD_USER, $addUserEvent);
127
        }
128
129
        return $this->redirectToRoute('zikulagroupsmodule_membership_adminlist', ['gid' => $group->getGid()]);
130
    }
@@ 156-163 (lines=8) @@
153
        $alreadyGroupMember = $group->getUsers()->contains($userEntity);
154
        if ($groupTypeIsPrivate || $groupTypeIsCore || $groupStateIsClosed || $groupCountIsLimit || $alreadyGroupMember) {
155
            $this->addFlash('error', $this->getSpecificGroupMessage($groupTypeIsPrivate, $groupTypeIsCore, $groupStateIsClosed, $groupCountIsLimit, $alreadyGroupMember));
156
        } else {
157
            $userEntity->addGroup($group);
158
            $this->get('doctrine')->getManager()->flush();
159
            $this->addFlash('success', $this->__f('Joined the "%group" group', ['%group' => $group->getName()]));
160
            // Let other modules know that we have updated a group.
161
            $addUserEvent = new GenericEvent(['gid' => $group->getGid(), 'uid' => $userEntity->getUid()]);
162
            $this->get('event_dispatcher')->dispatch(GroupEvents::GROUP_ADD_USER, $addUserEvent);
163
        }
164
165
        return $this->redirectToRoute('zikulagroupsmodule_group_list');
166
    }
@@ 210-216 (lines=7) @@
207
        ]);
208
209
        if ($form->handleRequest($request)->isValid()) {
210
            if ($form->get('remove')->isClicked()) {
211
                $user->removeGroup($group);
212
                $this->get('doctrine')->getManager()->flush();
213
                $this->addFlash('status', $this->__('Done! The user was removed from the group.'));
214
                $removeUserEvent = new GenericEvent(null, ['gid' => $gid, 'uid' => $uid]);
215
                $this->get('event_dispatcher')->dispatch(GroupEvents::GROUP_REMOVE_USER, $removeUserEvent);
216
            }
217
            if ($form->get('cancel')->isClicked()) {
218
                $this->addFlash('status', $this->__('Operation cancelled.'));
219
            }