protected static function ContactStorageExportBatches::createTempFile in Contact Storage Export 8
Create the temporary file.
Return value
\Drupal\file\FileInterface The file.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to ContactStorageExportBatches::createTempFile()
- ContactStorageExportBatches::getTempFile in src/
ContactStorageExportBatches.php - Get the temp file.
File
- src/
ContactStorageExportBatches.php, line 258
Class
- ContactStorageExportBatches
- Class ContactStorageExportBatches.
Namespace
Drupal\contact_storage_exportCode
protected static function createTempFile() {
// Get file temp name.
$dir = 'temporary://contact_storage_export';
$file_system = \Drupal::service('file_system');
$temp_nam = $file_system
->tempnam($dir, 'contact_storage_export');
// Create the file.
$file = File::create([
'filename' => 'contact-storage-export.csv',
'uri' => $temp_nam,
]);
$file
->setTemporary();
$file
->save();
return $file;
}