protected function PDFPreviewGenerator::getDestinationURI in PDFPreview 8
Same name and namespace in other branches
- 2.0.x 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;
}