コード例 #1
0
 public function load($manager)
 {
     $result = array();
     
     foreach ($this->data as $record) {
         $testHistory = new History;
         $testHistory->setTimestamp(new \DateTime);
         foreach ($record as $key => $val) {
             if ($key == 'job') {
                 $job = new Job;
                 $job->setCreateDate(new \DateTime);
                 foreach ($val as $k => $v) {
                     $job->{'set'.ucwords($k)}($v);
                 }
                 $val = $job;
                 $manager->persist($val);
                 unset($job);
             }
             $testHistory->{'set'.ucwords($key)}($val);
         }
         $manager->persist($testHistory);
         array_push($result, $testHistory);
         $manager->flush();
         unset($testHistory);
     }
     return $result;
 }
 /**
  * @param array $result
  */
 public function addHistory(array $result)
 {
     //add a history entry
     $history = new History;
     $history->setJob($this->_jobEntity);
     $history->setTimestamp($this->getLastrunDate());
     $history->setStatus($result['status']);
     $history->setSeverity($result['severity']);
     $history->setMessage($result['message']);
     $history->setActive(1);
     $this->_em->persist($history);
     $this->_em->flush();
     unset($history);
 }