Пример #1
0
 public function load(ObjectManager $manager)
 {
     $data = $this->container->get('ilioscore.dataloader.offering')->getAll();
     foreach ($data as $arr) {
         $entity = new Offering();
         $entity->setId($arr['id']);
         $entity->setRoom($arr['room']);
         $entity->setSite($arr['site']);
         $entity->setStartDate(new \DateTime($arr['startDate']));
         $entity->setEndDate(new \DateTime($arr['endDate']));
         $entity->setSession($this->getReference('sessions' . $arr['session']));
         foreach ($arr['learnerGroups'] as $id) {
             $entity->addLearnerGroup($this->getReference('learnerGroups' . $id));
         }
         foreach ($arr['instructorGroups'] as $id) {
             $entity->addInstructorGroup($this->getReference('instructorGroups' . $id));
         }
         foreach ($arr['learners'] as $id) {
             $entity->addLearner($this->getReference('users' . $id));
         }
         foreach ($arr['instructors'] as $id) {
             $entity->addInstructor($this->getReference('users' . $id));
         }
         $manager->persist($entity);
         $this->addReference('offerings' . $arr['id'], $entity);
     }
     $manager->flush();
 }
 /**
  * @return array
  */
 public function testExecuteDeletedOfferingProvider()
 {
     $course = new Course();
     $session = new Session();
     $session->setCourse($course);
     $offeringA = new Offering();
     $offeringA->setId(1);
     $offeringA->setSession($session);
     $alertA = new Alert();
     $alertA->setTableName('offering');
     $alertA->setTableRowId($offeringA->getId());
     $session = new Session();
     $offeringB = new Offering();
     $offeringB->setId(1);
     $offeringB->setSession($session);
     $alertB = new Alert();
     $alertB->setTableName('offering');
     $alertB->setTableRowId($offeringB->getId());
     $offeringC = new Offering();
     $offeringC->setId(1);
     $alertC = new Alert();
     $alertC->setTableName('offering');
     $alertC->setTableRowId($offeringC->getId());
     return [[$alertA, $offeringA], [$alertB, $offeringB], [$alertC, $offeringC]];
 }
 /**
  * @return OfferingInterface
  *
  * @todo This is truly in bad form. Refactor fixture loading out. [ST 2015/09/25]
  */
 protected function createOffering()
 {
     $school = new School();
     $school->setId(1);
     $school->setIliosAdministratorEmail('*****@*****.**');
     $school->setTemplatePrefix('TEST');
     $school->setTitle('Testing');
     $course = new Course();
     $course->setId(1);
     $course->setTitle('Test Course 1');
     $course->setSchool($school);
     $i = 0;
     foreach (['A', 'B', 'C'] as $letter) {
         $courseObjective = new Objective();
         $courseObjective->setId(++$i);
         $courseObjective->setTitle("Course Objective {$letter}");
         $course->addObjective($courseObjective);
     }
     $session = new Session();
     $session->setId(1);
     $session->setTitle('Test Session 1');
     $session->setCourse($course);
     $sessionType = new SessionType();
     $sessionType->setId(1);
     $sessionType->setTitle('Session Type A');
     $session->setSessionType($sessionType);
     $i = 0;
     foreach (['A', 'B', 'C'] as $letter) {
         $sessionObjective = new Objective();
         $sessionObjective->setId(++$i);
         $sessionObjective->setTitle("Session Objective {$letter}");
         $session->addObjective($sessionObjective);
     }
     $instructor1 = new User();
     $instructor1->setId(1);
     $instructor1->setFirstName('Jane');
     $instructor1->setLastName('Doe');
     $instructor1->setEmail('*****@*****.**');
     $instructor2 = new User();
     $instructor2->setId(2);
     $instructor2->setFirstName('Mike');
     $instructor2->setLastName('Smith');
     $instructor2->setEmail('*****@*****.**');
     $instructorGroup = new InstructorGroup();
     $instructorGroup->setId(1);
     $instructorGroup->addUser($instructor2);
     $learnerGroup = new LearnerGroup();
     $learnerGroup->setId(1);
     $learnerGroup->setTitle('Learner Group A');
     $learner = new User();
     $learner->setId(2);
     $learner->setFirstName('Jimmy');
     $learner->setLastName('Dumas');
     $offering = new Offering();
     $offering->setId(1);
     $offering->setStartDate(new \DateTime('2015-09-28 03:45:00', new \DateTimeZone('UTC')));
     $offering->setEndDate(new \DateTime('2015-09-28 05:45:00', new \DateTimeZone('UTC')));
     $offering->setSession($session);
     $offering->addInstructor($instructor1);
     $offering->addInstructorGroup($instructorGroup);
     $offering->addLearner($learner);
     $offering->addLearnerGroup($learnerGroup);
     $offering->setRoom('Library - Room 119');
     return $offering;
 }