function commerce_invoice_pdf_download_invoices_submit in Commerce Invoice 7.2
Assembles a unique URI for the archive.
File
- modules/
pdf/ commerce_invoice_pdf.module, line 383 - The Commerce Invoice PDF module.
Code
function commerce_invoice_pdf_download_invoices_submit($form, $form_state) {
$dir = 'private://commerce_invoice/archives';
if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
throw new Exception(t('The directory does not exist or is not writable: @dir', [
'@dir' => $dir,
]));
}
$destination = $dir . basename($form_state['values']['filename']) . '.zip';
// If the chosen filename already exists, file_destination() will append
// an integer to it in order to make it unique.
$destination = file_destination($destination, FILE_EXISTS_RENAME);
return array(
'destination' => $destination,
);
}