/**
  * @Route("/group/new")
  *
  * @Method("GET")
  */
 public function newAction(Request $request, $format)
 {
     $name = filter_var($request->query->get('name'), FILTER_SANITIZE_STRING);
     if (!$name) {
         return new Response('Group name not found.', 500);
     }
     $userGroup = new UserGroup();
     $userGroup->setName($name);
     $em = $this->getDoctrine()->getManager();
     $em->persist($userGroup);
     $em->flush();
     return $this->getResponse($userGroup, $format);
 }
 /**
  * Creates a form to delete a UserGroup entity.
  *
  * @param UserGroup $userGroup The UserGroup entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(UserGroup $userGroup)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('usergroup_delete', array('id' => $userGroup->getId())))->setMethod('DELETE')->getForm();
 }