protected function MediaPdfThumbnailImageManager::createThumbnailFileEntity in Media PDF Thumbnail 8.3
Same name and namespace in other branches
- 8.4 src/Manager/MediaPdfThumbnailImageManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImageManager::createThumbnailFileEntity()
- 8 src/Manager/MediaPdfThumbnailImageManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImageManager::createThumbnailFileEntity()
- 8.2 src/Manager/MediaPdfThumbnailImageManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImageManager::createThumbnailFileEntity()
Create file entity.
Parameters
string $fileUri: File uri.
Return value
array File entity id. File entity id.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
1 call to MediaPdfThumbnailImageManager::createThumbnailFileEntity()
- MediaPdfThumbnailImageManager::createThumbnail in src/
Manager/ MediaPdfThumbnailImageManager.php - Create pdf thumbnail.
File
- src/
Manager/ MediaPdfThumbnailImageManager.php, line 150
Class
- MediaPdfThumbnailImageManager
- Class MediaPdfThumbnailImageManager.
Namespace
Drupal\media_pdf_thumbnail\ManagerCode
protected function createThumbnailFileEntity($fileUri) {
$fileUriArray = explode('/', $fileUri);
$filenameNoExtension = str_replace('.pdf', '', end($fileUriArray));
$fileUri = str_replace('.pdf', '.pdf.jpeg', $fileUri);
$fileEntity = $this->entityTypeManager
->getStorage('file')
->create([
'uri' => $fileUri,
'status' => FILE_STATUS_PERMANENT,
]);
$fileEntity
->save();
return $fileEntity ? [
'fid' => $fileEntity
->id(),
'filename' => $filenameNoExtension,
] : NULL;
}