Esempio n. 1
0
 protected function processFamily($row)
 {
     if ($row) {
         $studentRepo = $this->manager->getRepository('TSK\\StudentBundle\\Entity\\Student');
         $primaryStudent = $studentRepo->findOneBy(array('legacyStudentId' => $row[0]));
         $student = $studentRepo->findOneBy(array('legacyStudentId' => $row[1]));
         if (!$primaryStudent) {
             print "Can't find primary student " . $row[0] . "\n";
             exit;
         }
         if (!$student) {
             print "Can't find student " . $row[1] . "\n";
             exit;
         }
         $tfmRepo = $this->manager->getRepository('TSK\\StudentBundle\\Entity\\TrainingFamilyMembers');
         $oldTfm = $tfmRepo->findOneBy(array('primaryStudent' => $primaryStudent, 'student' => $student));
         if (!$oldTfm) {
             $tfm = new TrainingFamilyMembers();
             $tfm->setPrimaryStudent($primaryStudent);
             $tfm->setStudent($student);
             $tfm->setDateAdded(new \DateTime($row[2]));
             $tfm->setOrdinalPosition($row[3]);
             try {
                 $this->manager->persist($tfm);
                 $this->manager->flush();
             } catch (DBALException $e) {
             } catch (\Exception $e) {
                 ld($e);
                 print $e->getMessage();
                 exit;
             }
         }
     }
 }