コード例 #1
0
 public function deleteAction(Category $category, Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $title = $category->getTitle();
     $em->remove($category);
     $em->flush();
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(array('success' => true));
     }
     $session = $request->getSession();
     $session->getFlashBag()->add('info', $title . ' supprimé');
     return $this->redirectToRoute('ticme_back_category_list');
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $cat = new Category();
     $cat->setTitle('Catégorie de test');
     $cat->setDescription('Description Catégorie de test');
     $manager->persist($cat);
     for ($i = 1; $i <= 5; $i++) {
         $category = new Category();
         $category->setTitle('Catégorie ' . $i);
         $category->setDescription('Description Catégorie ' . $i);
         $category->setCreatedAt(new \DateTime('NOW'));
         $category->setUpdatedAt(new \DateTime('NOW'));
         $manager->persist($category);
     }
     $manager->flush();
     $this->addReference('cat', $cat);
 }