Ejemplo n.º 1
0
 protected function writeRawCsv($data, Sheet $sheet)
 {
     $fileName = $sheet->getGoogleId() . "_" . $sheet->getSheetId() . "_" . date('Y-m-d') . '-' . uniqid() . ".csv";
     /** @var SplFileInfo $fileInfo */
     $fileInfo = $this->temp->createFile($fileName);
     $fh = fopen($fileInfo->getPathname(), 'w+');
     if (!$fh) {
         throw new \Exception("Can't write to file " . $fileInfo->getPathname());
     }
     /* @var Stream $data */
     fwrite($fh, $data->getContents());
     fclose($fh);
     return $fileInfo->getPathname();
 }
Ejemplo n.º 2
0
 public function testCleanupFilePreserve()
 {
     $temp = new Temp();
     $file = $temp->createFile('file', true);
     unset($temp);
     self::assertFileExists($file->getPathname());
     unlink($file->getPathname());
     rmdir(dirname($file->getPathname()));
 }
Ejemplo n.º 3
0
 protected function getOutputCsv($tableName, Profile $profile)
 {
     $fileName = str_replace(' ', '-', $tableName) . '-' . str_replace('/', '', $profile->getGoogleId()) . "-" . microtime() . "-" . uniqid("", true) . ".csv";
     $tmpFileInfo = $this->temp->createFile($fileName);
     return new CsvFile($tmpFileInfo->getPathname());
 }