public function banUser(\Club\UserBundle\Entity\User $user) { $ban = new \Club\UserBundle\Entity\Ban(); $ban->setUser($this->security_context->getToken()->getUser()); $ban->setType('user'); $ban->setValue($user->getId()); $ban->setExpireDate(new \DateTime(date('Y-m-d H:i:s', strtotime("+1 month")))); $user->setLocked(1); $this->em->persist($user); $this->em->persist($ban); $this->em->flush(); }
/** * @Route("/ban/user/{id}") */ public function banUserAction($id) { $em = $this->getDoctrine()->getEntityManager(); $user = $em->find('ClubUserBundle:User', $id); $ban = new \Club\UserBundle\Entity\Ban(); $ban->setUser($user); $ban->setType('user'); $ban->setValue($user->getId()); $em->persist($ban); $em->flush(); return $this->renderJSon($user->toArray()); }