Ejemplo n.º 1
0
 public function load(ObjectManager $manager)
 {
     $nbr = 20;
     for ($i = 1; $i < $nbr; $i++) {
         $article = new Article();
         $article->setAuteur("Greg Berger");
         $article->setTitre("Article " . $i);
         $article->setContenu($i . " - Lorem ipsum etc.");
         $image = new ISL\BlogBundle\Entity\Image();
         $image->setUrl('https://placekitten.com/g/200/300');
         $image->setAlt('placeholder');
         $article->setImage($image);
         $article->addCategorie($this->getReference('cat-' . rand(0, 3)));
         $article->addCategorie($this->getReference('cat-' . rand(0, 3)));
         $manager->persist($article);
     }
     $manager->flush();
 }
Ejemplo n.º 2
0
 public function supprimerAction(Article $article)
 {
     $form = $this->createDeleteForm($article->getId());
     $form->handleRequest($this->get('request'));
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->remove($article);
         $em->flush();
         $this->get('session')->getFlashBag()->add('success', 'Article a été supprimé');
     }
     return $this->redirect($this->generateUrl('isl_blog_index'));
 }