Skip to content

Instantly share code, notes, and snippets.

@andrechavesg
Created March 12, 2018 16:40
Show Gist options
  • Save andrechavesg/9bd824b9d1271d26b8421c4254aa7ee0 to your computer and use it in GitHub Desktop.
Save andrechavesg/9bd824b9d1271d26b8421c4254aa7ee0 to your computer and use it in GitHub Desktop.
/**
* @Route("/projeto/mostra/{id}")
*/
public function mostraAction(Projeto $projeto)
{
return $this->render('Projeto/mostra.html.twig',["projeto" => $projeto]);
}
/**
* @Route("/projeto/novo",methods="GET")
*/
public function formulario()
{
return $this->render("Projeto/novo.html.twig");
}
/**
* @Route("/projeto/novo",methods="POST")
*/
public function cria(Request $request)
{
$nome = $request->get("nome");
$projeto = new Projeto();
$projeto->setNome($nome);
$em = $this->getDoctrine()->getManager();
$em->persist($projeto);
$em->flush();
return $this->redirect("/projeto/mostra/".$projeto->getNome());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment