You are here

protected function MediaPdfThumbnailImageManager::createThumbnailFileEntity in Media PDF Thumbnail 8

Same name and namespace in other branches
  1. 8.4 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()

Create file entity.

Parameters

string $fileUri: File uri.

Return value

int|null|string 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 114

Class

MediaPdfThumbnailImageManager
Class MediaPdfThumbnailImageManager.

Namespace

Drupal\media_pdf_thumbnail\Manager

Code

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