示例#1
0
 public function saveCategorie($name)
 {
     $categorieToSave = new Categorie();
     try {
         $categorieToSave->setNom($name);
         $categorieToSave->setUrl("/" . $name);
     } catch (\Exception $e) {
         throw $e;
     }
     $this->em->persist($categorieToSave);
     $this->em->flush();
 }
 public function addAction()
 {
     $form = new CategorieForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $categorie = new Categorie();
         $form->setInputFilter($categorie->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $categorie->exchangeArray($form->getData());
             $this->getEntityManager()->persist($categorie);
             $this->getEntityManager()->flush();
             // Redirect to list of categories
             return $this->redirect()->toRoute('categorie');
         }
     }
     return array('form' => $form);
 }
 /**
  * {@inheritDoc}
  */
 public function setUrl($url)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUrl', array($url));
     return parent::setUrl($url);
 }