Code Duplication    Length = 24-24 lines in 3 locations

Controller/GroupController.php 1 location

@@ 105-128 (lines=24) @@
102
			'form' => array_merge($formtpl, array('parent' => $request->query->get('parent', $request->request->get('parent', $request->headers->get('referer')))))));
103
	}
104
105
	public function deleteAction(Request $request) {
106
		################################################  SETTINGS  ################################################
107
		$name         = 'group';
108
		$repo         = 'VivaitAuthBundle:Group';
109
		$id           = $request->query->get('id', 0);
110
		$msg_notfound = "The $name could not be found";
111
		$msg_success  = "The $name has been removed";
112
		############################################################################################################
113
114
		$obj = $this->getDoctrine()
115
			->getRepository($repo)
116
			->find($id);
117
118
		if(!$obj) {
119
			$this->get('session')->getFlashBag()->add('error', $msg_notfound);
120
		} else {
121
			$em = $this->getDoctrine()->getManager();
122
			$em->remove($obj);
123
			$em->flush();
124
			$this->get('session')->getFlashBag()->add('success', $msg_success);
125
		}
126
127
		return $this->redirect($request->headers->get('referer'));
128
    }
129
130
}
131

Controller/TenantController.php 1 location

@@ 105-128 (lines=24) @@
102
				'form' => array_merge($formtpl, array('parent' => $request->query->get('parent', $request->request->get('parent', $request->headers->get('referer')))))));
103
		}
104
105
		public function deleteAction(Request $request) {
106
			################################################  SETTINGS  ################################################
107
			$name         = 'tenant';
108
			$repo         = 'VivaitAuthBundle:Tenant';
109
			$id           = $request->query->get('id', 0);
110
			$msg_notfound = "The $name could not be found";
111
			$msg_success  = "The $name has been removed";
112
			############################################################################################################
113
114
			$obj = $this->getDoctrine()
115
				->getRepository($repo)
116
				->find($id);
117
118
			if(!$obj) {
119
				$this->get('session')->getFlashBag()->add('error', $msg_notfound);
120
			} else {
121
				$em = $this->getDoctrine()->getManager();
122
				$em->remove($obj);
123
				$em->flush();
124
				$this->get('session')->getFlashBag()->add('success', $msg_success);
125
			}
126
127
			return $this->redirect($request->headers->get('referer'));
128
		}
129
	}
130

Controller/UserController.php 1 location

@@ 144-167 (lines=24) @@
141
		}
142
143
144
		public function deleteAction(Request $request) {
145
			################################################  SETTINGS  ################################################
146
			$name         = 'user';
147
			$repo         = 'VivaitAuthBundle:User';
148
			$id           = $request->query->get('id', 0);
149
			$msg_notfound = "The $name could not be found";
150
			$msg_success  = "The $name has been removed";
151
			############################################################################################################
152
153
			$obj = $this->getDoctrine()
154
			            ->getRepository($repo)
155
			            ->find($id);
156
157
			if(!$obj) {
158
				$this->get('session')->getFlashBag()->add('error', $msg_notfound);
159
			} else {
160
				$em = $this->getDoctrine()->getManager();
161
				$em->remove($obj);
162
				$em->flush();
163
				$this->get('session')->getFlashBag()->add('success', $msg_success);
164
			}
165
166
			return $this->redirect($request->headers->get('referer'));
167
		}
168
169
		public function impersonateAction(Request $request) {
170
			################################################  SETTINGS  ################################################