/**
  * Add formations
  *
  * @param User\Bundle\Entity\User $user
  * @return Formation
  */
 public function setUsers(\User\Bundle\Entity\User $users)
 {
     foreach ($users as $u) {
         $fo = new \Formation\Bundle\Entity\FormationUser();
         $fo->setUser($u);
         $fo->setFormation($this);
         $this->addFo($fo);
     }
 }
 /**
  * formation user add action
  * 
  * @param integer $id formation id
  * @param integer $user user_id
  */
 public function userAddAction($id, $user)
 {
     $em = $this->getDoctrine()->getManager();
     $formation = $em->getRepository('FormationBundle:Formation')->find($id);
     if (!$formation) {
         throw $this->createNotFoundException('Unable to find Formation entity.');
     }
     $user = $em->getRepository('UserBundle:User')->find($user);
     if (!$user) {
         throw $this->createNotFoundException('Unable to find User entity.');
     }
     // create FormationUser
     $fo = new FormationUser();
     $fo->setFormation($formation);
     $fo->setUser($user);
     $fo->setCreationDate(new \DateTime('NOW'));
     $fo->setUpdateDate(new \DateTime('NOW'));
     //exit(\Doctrine\Common\Util\Debug::dump($formation_user));
     $user->addFo($fo);
     $em->flush();
     return $this->redirect($this->generateUrl('administration_formation_user', array('id' => $id)));
 }