Example #1
0
 protected function processRow($row)
 {
     $manager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $statesRepo = $manager->getRepository('TSKUserBundle:States');
     $schoolRepo = $manager->getRepository('TSKSchoolBundle:School');
     $studStatusRepo = $manager->getRepository('TSKStudentBundle:StudentStatus');
     $studStatus = $studStatusRepo->find(1);
     $contact = new Contact();
     $contact->setId($row[0]);
     $contact->setFirstName($row[2]);
     $contact->setLastName($row[3]);
     $contact->setOrganization($this->org);
     $contact->setEmail($row[4]);
     $contact->setAddress1($row[6]);
     $contact->setAddress2($row[7]);
     $contact->setCity($row[8]);
     $contact->setState($statesRepo->find($row[9]));
     $contact->setPostalCode($row[10]);
     $contact->setPhone($row[11]);
     $contact->setMobile($row[12]);
     $contact->setFax($row[13]);
     $contact->setWebsite($row[14]);
     $contact->setGeocode($row[15]);
     $contact->setImgPath($row[16]);
     $contact->setDateOfBirth(new \DateTime($row[17]));
     $contact->addSchool($this->school);
     $student = new Student();
     $student->setContact($contact);
     $student->setStudentStatus($studStatus);
     $metadata = $manager->getClassMetaData(get_class($contact));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     // $manager->persist($contact);
     $manager->persist($student);
     $manager->flush();
 }