Esempio n. 1
0
 public function ajouter($texte)
 {
     $nouveaute = new entite();
     $nouveaute->setDate(new \DateTime());
     $nouveaute->setDescription($texte);
     $this->em->persist($nouveaute);
     $this->em->flush();
 }
Esempio n. 2
0
 /**
  * @Secure(roles="ROLE_ADMIN")
  */
 public function ajoutNouveautesAction()
 {
     $nouveaute = new Nouveautes();
     $nouveaute->setDate(new \DateTime());
     $form = $this->createForm(new NouveautesType(), $nouveaute);
     $request = $this->get('request');
     if ($request->getMethod() == 'POST') {
         $form->bind($request);
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             $em->persist($nouveaute);
             $em->flush();
             return $this->redirect($this->generateUrl('sdis_admin_nouveautes'));
         }
     }
     return $this->render('SdisDynamiqueBundle:Admin:nouveau.html.twig', array('form' => $form->createView()));
 }