1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
class PersonneWSController extends Controller
{
public function newPersonne_wsAction()
{
//la route get /personne_ws/new sera automatiquement générée
$entity = new Personne();
$form = $this->createForm(new PersonneType(), $entity);
$view = $this->render('dav2TestBundle:Personne:new.xml.twig', array(
'entity' => $entity,
'form' => $form->createView()
));
return $view;
}
public function postPersonne_wsAction()
{
//la route [post] /personne_ws sera automatiquement générée
$entity = new Personne();
$request = $this->getRequest();
$form = $this->createForm(new PersonneType(), $entity);
$form->bindRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('personne_show', array('id' => $entity->getId())));
}
else
{
die('ko');
}
}
} |
Partager