Example #1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $handle = fopen(__DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'history_data.csv', 'r');
     $headers = fgetcsv($handle, 1000, ',');
     while (($data = fgetcsv($handle, 1000, ',')) !== false) {
         $combined = array_combine($headers, $data);
         $logDate = new \DateTime($combined['Created Date UTC'], new \DateTimeZone('UTC'));
         $historyEntry = new LifetimeValueHistory();
         $historyEntry->setAccount($this->ensureAccountCreated($manager, $combined['Account name']));
         $historyEntry->setDataChannel($this->ensureChannelCreated($manager, $combined['Channel name'], $logDate));
         $historyEntry->setCreatedAt($logDate);
         $historyEntry->setStatus($combined['Status']);
         $historyEntry->setAmount($combined['Amount']);
         $manager->persist($historyEntry);
     }
     $manager->flush();
     fclose($handle);
 }