/**
  * @Route("/members/add/{id}")
  * @Template()
  */
 public function membersAddAction(\Club\UserBundle\Entity\Group $group)
 {
     $form = $this->createForm(new \Club\UserBundle\Form\UserAjax());
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bind($this->getRequest());
         if ($form->isValid()) {
             $user = $form->get('user')->getData();
             $group->addUsers($user);
             $em = $this->getDoctrine()->getManager();
             $em->persist($user);
             $em->flush();
             $this->get('session')->getFlashBag()->add('notice', $this->get('translator')->trans('Your changes are saved.'));
             return $this->redirect($this->generateUrl('club_user_admingroup_members', array('id' => $group->getId())));
         }
     }
     return array('group' => $group, 'form' => $form->createView());
 }
Exemplo n.º 2
0
 public function inGroup(\Club\UserBundle\Entity\Group $group)
 {
     foreach ($this->getGroups() as $g) {
         if ($group->getId() === $g->getId()) {
             return true;
         }
     }
     return false;
 }