示例#1
0
 /**
  * @Route("/ajout/{id}", name="ajout") 
  */
 public function ajoutAction($id)
 {
     $em = $this->get("doctrine")->getManager();
     //$contactrepo=$this->get("doctrine")->getRepository("AppBundle:Contact");
     $userrepo = $this->get("doctrine")->getRepository("AppBundle:User");
     $new = $userrepo->find($id);
     $user = $this->getUser();
     $contact = new Contact();
     $contact->setDateAjout(new \DateTime());
     $contact->setProprietaire($user);
     $contact->setContact($new);
     $em->persist($contact);
     $em->flush();
     return $this->redirectToRoute('affichage');
 }