Example #1
0
 public function addAction()
 {
     if (!empty($_POST)) {
         // créer de nouveaux objets
         $product = new Product();
         $image = new Image();
         //récuperer les infos du formulaire
         $image->setName(htmlentities($_POST['image']));
         $product->setName(htmlentities($_POST['name']));
         $product->setImage($image);
         // passage des objets à Doctrine
         $this->em->persist($product);
         $this->em->persist($image);
         $this->em->flush();
         // redirection
         header('Location: index.php?controller=product&action=index');
     }
     $this->render('addProduction.php');
 }
Example #2
0
 /**
  * @param mixed $image
  */
 public function setImage(Image $image = null)
 {
     $this->image = $image;
     $image->setProduct($this);
     return $this;
 }