You are here

class MediaPdfThumbnailImagickManager in Media PDF Thumbnail 8.2

Same name and namespace in other branches
  1. 8.4 src/Manager/MediaPdfThumbnailImagickManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImagickManager
  2. 8 src/Manager/MediaPdfThumbnailImagickManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImagickManager
  3. 8.3 src/Manager/MediaPdfThumbnailImagickManager.php \Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImagickManager

Class MediaPdfThumbnailImagickManager.

@package Drupal\media_pdf_thumbnail\Manager

Hierarchy

Expanded class hierarchy of MediaPdfThumbnailImagickManager

1 string reference to 'MediaPdfThumbnailImagickManager'
media_pdf_thumbnail.services.yml in ./media_pdf_thumbnail.services.yml
media_pdf_thumbnail.services.yml
1 service uses MediaPdfThumbnailImagickManager
media_pdf_thumbnail.imagick.manager in ./media_pdf_thumbnail.services.yml
Drupal\media_pdf_thumbnail\Manager\MediaPdfThumbnailImagickManager

File

src/Manager/MediaPdfThumbnailImagickManager.php, line 13

Namespace

Drupal\media_pdf_thumbnail\Manager
View source
class MediaPdfThumbnailImagickManager {
  protected $logger;

  /**
   * MediaPdfThumbnailImagickManager constructor.
   *
   * @param \Drupal\Core\Logger\LoggerChannel $loggerChannel
   */
  public function __construct(LoggerChannel $loggerChannel) {
    $this->logger = $loggerChannel;
  }

  /**
   * Generate image from PDF file.
   *
   * @param string $source
   *   File source.
   * @param string $target
   *   File target.
   *
   * @return string
   *   File path.
   *
   */
  public function generateImage($source, $target) {
    try {
      $pdf = new Pdf($source);
      $pdf
        ->saveImage($target);
    } catch (\Exception $e) {
      $this->logger
        ->error($e
        ->getMessage(), [
        'Media Pdf Thumbnail',
      ]);
      return FALSE;
    }
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MediaPdfThumbnailImagickManager::$logger protected property
MediaPdfThumbnailImagickManager::generateImage public function Generate image from PDF file.
MediaPdfThumbnailImagickManager::__construct public function MediaPdfThumbnailImagickManager constructor.