예제 #1
0
 public function load(ObjectManager $manager)
 {
     /*     //get user
             $em = $this->container->get('doctrine')->getEntityManager();
             $user = $em->getRepository('ClarolineCoreBundle:User')->findOneById(1);
     */
     $user = $manager->getRepository('ClarolineCoreBundle:User')->findOneById(1);
     $category = new Category();
     $category->setLocker(0);
     $category->setUser($user);
     $category->setValue('CatFIX value1');
     $manager->persist($category);
     $manager->flush();
     $this->addReference('category1', $category);
 }
예제 #2
0
 /**
  * Record a new Category entity to the AJAX form.
  *
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createPopAction()
 {
     $request = $this->container->get('request');
     if ($request->isXmlHttpRequest()) {
         $val = $request->request->get('value');
         $lock = $request->request->get('locker');
         $entity = new Category();
         $entity->setValue($val);
         $entity->setLocker($lock);
         $entity->setUser($this->container->get('security.token_storage')->getToken()->getUser());
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         return new Response($entity->getId());
     } else {
         return 0;
     }
 }
예제 #3
0
 /**
  * Create the default category for the user.
  *
  * @param string $default name of default's category
  *
  * @return \UJM\ExoBundle\Entity\Category
  */
 private function createCategoryDefault($default)
 {
     $newCategory = new Category();
     $newCategory->setValue($default);
     $newCategory->setLocker(1);
     $newCategory->setUser($this->user);
     $this->em->persist($newCategory);
     $this->em->flush();
     return $newCategory;
 }
예제 #4
0
 /**
  * @param string $name
  *
  * @return Category
  */
 public function category($name)
 {
     $category = new Category();
     $category->setValue($name);
     $this->om->persist($category);
     return $category;
 }
예제 #5
0
 /**
  * Creates or uses the default category
  * @param type $default
  * @param type $ListeCategroy
  * @param type $data
  */
 protected function categoryDefault($default, $ListeCategroy, $data)
 {
     $checkCategory = False;
     foreach ($ListeCategroy as $category) {
         if ($category->getlocker() == '1') {
             $data->setCategory($category);
             $checkCategory = true;
         }
     }
     if ($checkCategory == false) {
         $newCategory = new Category();
         $newCategory->setValue($default);
         $newCategory->setLocker(1);
         $newCategory->setUser($this->user);
         $this->em->persist($newCategory);
         $this->em->flush();
         $data->setCategory($newCategory);
     }
 }
예제 #6
0
 /**
  * Create the default category for the user.
  *
  * @param string $default name of default's category
  * @param User   $user
  *
  * @return \UJM\ExoBundle\Entity\Category
  */
 private function createCategoryDefault($default, User $user)
 {
     $newCategory = new Category();
     $newCategory->setValue($default);
     $newCategory->setLocker(1);
     $newCategory->setUser($user);
     $this->doctrine->getManager()->persist($newCategory);
     $this->doctrine->getManager()->flush();
     return $newCategory;
 }