Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. public function updateDocumentAction(Request $requette, $id){
  2.  
  3. //identifiant du document
  4. if (!$id) {
  5. throw $this->createNotFoundException(
  6. "Aucun identifiant n'a été fourni"
  7. );
  8. }
  9.  
  10. // Manager
  11. $em = $this -> getDoctrine() -> getManager();
  12.  
  13. /*
  14. * Document dans la base
  15. */
  16. $document = $em -> getRepository("AdminBundle:Document") -> find($id);
  17.  
  18. if (!$document) {
  19. throw $this->createNotFoundException(
  20. 'Ce Document n\'existe pas'
  21. );
  22. }
  23.  
  24. $formulaire = $this->createForm(new DocumentType(), $document);
  25.  
  26. //si un formulaire est transmis
  27. $formulaire -> handleRequest($requette);
  28.  
  29. if ($formulaire->isValid()) {
  30. $em->flush();
  31. //var_dump("echo expression");
  32. // return $this->redirect($this->generateUrl('admin_documents'));
  33. }
  34.  
  35. // Formulaire avec données
  36. return $this -> render(
  37. 'AdminBundle:Documents:update-document.html.twig' ,
  38. array('formulaire' => $formulaire -> createView())
  39. );
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement