public function indexAction(Request $request) { if (false === $this->get('security.context')->isGranted('ROLE_MANAGER')) { throw new AccessDeniedException(); } $em = $this->getDoctrine()->getManager(); $offre = new Offre(); $ligne = new LigneOffre(); $entreprise = $em->getRepository("UtilisateurBundle:Entreprise")->findOneByUtilisateur($this->getUser()); $ligne->setLidOffre($offre); $offre->getLigneOffre()->add($ligne); $offre->setIdEntreprise($entreprise); $em->persist($offre); $form = $this->createForm(new OffreType2(), $offre); $form->handleRequest($request); if ($form->isValid()) { try { $add = $form->getData(); $em->persist($add); $em->flush(); $this->get('session')->getFlashBag()->add('succes', 'enregistré'); } catch (\Exception $e) { $this->get('session')->getFlashBag()->add('erreur', 'enregistré'); } } return $this->render('EntrepriseBundle:Pages:addoffres.html.twig', array('addoffre' => $form->createView())); }
public function addoffreAction(Request $request) { if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException(); } $em = $this->getDoctrine()->getManager(); $offre = new Offre(); $ligne = new LigneOffre(); $ligne->setLidOffre($offre); $offre->getLigneOffre()->add($ligne); $offre->setActivation(false); $em->persist($offre); $form = $this->createForm(new OffreType(), $offre); $form->handleRequest($request); if ($form->isValid()) { try { $add = $form->getData(); $em->persist($add); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'enregistré'); } catch (\Exception $e) { $this->get('session')->getFlashBag()->add('error', $e); } } return $this->render('AdminBundle:Pages:addoffre.html.twig', array('addoffre' => $form->createView())); }
public function addLigneOffre(\Utilisateur\UtilisateurBundle\Entity\LigneOffre $ligneoffre) { $ligneoffre->setLidOffre($this); $this->ligneOffre[] = $ligneoffre; return $this; }
/** * {@inheritDoc} */ public function setLidOffre(\Utilisateur\UtilisateurBundle\Entity\Offre $lidOffre = NULL) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setLidOffre', array($lidOffre)); return parent::setLidOffre($lidOffre); }