Created
November 16, 2013 14:40
-
-
Save glynrob/7500851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @Route("/users/delete/{id}", requirements={"id" = "\d+"}, defaults={"id" = 0}) | |
* @Template() | |
*/ | |
public function deleteAction($id) | |
{ | |
if ($id == 0){ // no user id entered | |
return $this->redirect($this->generateUrl('users_list_users_index'), 301); | |
} | |
$em = $this->getDoctrine()->getManager(); | |
$user = $em->getRepository('UsersListBundle:Users')->find($id); | |
if (!$user) { // no user in the system | |
throw $this->createNotFoundException( | |
'No user found for id '.$id | |
); | |
} else { | |
$em->remove($user); | |
$em->flush(); | |
return $this->redirect($this->generateUrl('users_list_users_index'), 301); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment