You are here

protected function MediaPdfThumbnailImageManager::createThumbnailFileEntity in Media PDF Thumbnail 8.4

Same name and namespace in other branches
  1. 8 src/Manager/MediaPdfThumbnailImageManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImageManager::createThumbnailFileEntity()
  2. 8.2 src/Manager/MediaPdfThumbnailImageManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImageManager::createThumbnailFileEntity()
  3. 8.3 src/Manager/MediaPdfThumbnailImageManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImageManager::createThumbnailFileEntity()

Parameters

$fileUri:

Return value

array|void|null

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

File

src/Manager/MediaPdfThumbnailImageManager.php, line 146

Class

MediaPdfThumbnailImageManager
Class MediaPdfThumbnailImageManager.

Namespace

Drupal\media_pdf_thumbnail\Manager

Code

protected function createThumbnailFileEntity($fileUri) {
  if (empty($fileUri)) {
    return;
  }
  $infos = pathinfo($fileUri);
  $fileEntity = $this->entityTypeManager
    ->getStorage('file')
    ->create([
    'uri' => $fileUri,
    'status' => FILE_STATUS_PERMANENT,
  ]);
  $fileEntity
    ->save();
  return $fileEntity ? [
    'fid' => $fileEntity
      ->id(),
    'filename' => $infos['filename'],
  ] : NULL;
}