コード例 #1
0
 public function migrate()
 {
     $this->output->writeln("Starting data migration version 5");
     $this->output->writeln('Migrating MOOC tracker courses');
     $em = $this->container->get('Doctrine')->getManager();
     $moocTrackerCourses = $em->getRepository('ClassCentralSiteBundle:MoocTrackerCourse')->findAll();
     foreach ($moocTrackerCourses as $mtc) {
         $uc = new UserCourse();
         $uc->setUser($mtc->getUser());
         $uc->setCourse($mtc->getCourse());
         $uc->setCreated($mtc->getCreated());
         $uc->setListId(UserCourse::LIST_TYPE_INTERESTED);
         $em->persist($uc);
     }
     $em->flush();
     $this->output->writeln('Creating MOOC Tracker preferences');
     // Creating user preferences for mooc tracker courses and search terms
     $users = $em->getRepository('ClassCentralSiteBundle:User')->findAll();
     foreach ($users as $user) {
         $upCourses = new UserPreference();
         $upCourses->setUser($user);
         $upCourses->setType(UserPreference::USER_PREFERENCE_MOOC_TRACKER_COURSES);
         $upCourses->setValue("1");
         $upSearchTerms = new UserPreference();
         $upSearchTerms->setUser($user);
         $upSearchTerms->setType(UserPreference::USER_PREFERENCE_MOOC_TRACKER_SEARCH_TERM);
         $upSearchTerms->setValue("1");
         $em->persist($upCourses);
         $em->persist($upSearchTerms);
     }
     $em->flush();
 }
コード例 #2
0
 public function migrate()
 {
     $this->output->writeln("Starting data migration version 9");
     $em = $this->container->get('Doctrine')->getManager();
     $users = $em->getRepository('ClassCentralSiteBundle:User')->findAll();
     foreach ($users as $user) {
         $up = new UserPreference();
         $up->setUser($user);
         $up->setType(UserPreference::USER_PREFERENCE_REVIEW_SOLICITATION);
         $up->setValue("1");
         $em->persist($up);
     }
     $em->flush();
 }
コード例 #3
0
ファイル: User.php プロジェクト: LukasBoersma/class-central
 private function getPreference(\ClassCentral\SiteBundle\Entity\User $user, $type, $prefs)
 {
     $up = new UserPreference();
     $up->setUser($user);
     $up->setType($type);
     $value = 1;
     if (in_array($type, $prefs)) {
         $value = $prefs[$type];
     }
     $up->setValue($value);
     return $up;
 }