protected function PdfPreviewGenerator::getDestinationURI in PDFPreview 2.0.x
Same name and namespace in other branches
- 8 src/PDFPreviewGenerator.php \Drupal\pdfpreview\PDFPreviewGenerator::getDestinationURI()
Gets the destination URI of the file.
Parameters
\Drupal\file\Entity\File $file: The file that is being converted.
Return value
string The destination URI.
2 calls to PdfPreviewGenerator::getDestinationURI()
- PdfPreviewGenerator::deletePdfPreview in src/
PdfPreviewGenerator.php - Deletes the preview image for a file.
- PdfPreviewGenerator::getPdfPreview in src/
PdfPreviewGenerator.php - Gets the preview image if it exists, or creates it if it doesnt.
File
- src/
PdfPreviewGenerator.php, line 173
Class
- PdfPreviewGenerator
- Generates PDF Previews.
Namespace
Drupal\pdfpreviewCode
protected function getDestinationURI(File $file) {
$config = $this->configFactory
->get('pdfpreview.settings');
$scheme = $this->configFactory
->get('system.file')
->get('default_scheme');
$langcode = $this->languageManager
->getCurrentLanguage()
->getId();
$output_path = $scheme . '://' . $config
->get('path');
if ($config
->get('filenames') == 'human') {
$filename = $this->fileSystem
->basename($file
->getFileUri(), '.pdf');
$filename = $this->transliteration
->transliterate($filename, $langcode);
$filename = $file
->id() . '-' . $filename;
}
else {
$filename = md5('pdfpreview' . $file
->id());
}
if ($config
->get('type') == 'png') {
$extension = '.png';
}
else {
$extension = '.jpg';
}
return $output_path . '/' . $filename . $extension;
}