Esempio n. 1
0
 public function load(ObjectManager $manager)
 {
     // Liste des noms de catégorie à ajouter
     $names_playlist_cat = array('Default');
     $names_audio_cat = array('Racine');
     foreach ($names_playlist_cat as $name) {
         // On crée la catégorie
         $category = new PlaylistCategory();
         $category->setName($name);
         $category->setRemovable(false);
         // On la persiste
         $manager->persist($category);
     }
     foreach ($names_audio_cat as $name) {
         // On crée la catégorie
         $manager->getRepository("LCVPlaylistBundle:AudioCategory");
         $category = new AudioCategory();
         $category->setName($name);
         $category->setRemovable(false);
         // On la persiste
         $manager->persistAsFirstChild($category);
     }
     // On déclenche l'enregistrement de toutes les catégories
     $manager->flush();
 }
 public function createAudioCategoryAction(Request $request)
 {
     $data = array();
     $audio_cat = new AudioCategory();
     $em = $this->getDoctrine()->getManager();
     $repo = $em->getRepository('LCVPlaylistBundle:AudioCategory');
     $data = $request->request->get("form");
     $audio_cat->setName($data['name']);
     $parent = $repo->findOneById($data['parent']);
     $repo->persistAsLastChildOf($audio_cat, $parent);
     $em->flush();
     $request->getSession()->getFlashBag()->add('success', 'Catégorie bien enregistrée !');
     return $this->redirect($this->generateUrl('lcv_platlist_audio_index'));
 }