bundles/Jabber/GenericBundle/EventListener/NewThumbnails.php line 24

Open in your IDE?
  1. <?php 
  2. namespace Jabber\GenericBundle\EventListener;
  3. use Pimcore\Model\DataObject;
  4. use Pimcore\Model\Asset;
  5. use Pimcore\Model\DataObject\Product;
  6. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  7. use Pimcore\Event\Model\ElementEventInterface;
  8. use Pimcore\Event\Model\DataObjectEvent;
  9. use Symfony\Component\EventDispatcher\GenericEvent;
  10. use Symfony\Component\Process\Process;
  11. class NewThumbnails {
  12.     public $redis;
  13.     public $parameterBag;
  14.     public function __construct(ParameterBagInterface $parameterBag) {
  15.         $this->parameterBag $parameterBag;
  16.     }
  17.     public function onImageCreated(GenericEvent $e) {
  18.         $fileName $e->getSubject()->getAsset()->getFilename();
  19.         if ($e->getSubject()->getAsset()->getFilename() && preg_match('@\.CR2z?$@'$e->getSubject()->getAsset()->getFilename())) {
  20.             $pathReferences $e->getSubject()->getPathReference();
  21.             if ($pathReferences['storagePath']) {
  22.                 $thumbnailFile "\"" PIMCORE_WEB_ROOT '/var/tmp/nasthumbnails' $pathReferences['storagePath'] . "\"";
  23.                 if ($e->getSubject()->getConfig()->getName() == "DAM") {
  24.                     $this->redis = new \Redis();
  25.                     $this->redis->connect('127.0.0.1'6379);
  26.                     $this->redis->sAdd('pimcore_thumbnails_whitebalance_queue'"\"" PIMCORE_WEB_ROOT '/var/tmp/nasthumbnails' $pathReferences['storagePath'] . "\"");
  27.                 } 
  28.             }
  29.         } else if ($e->getSubject()->getConfig()->getName() == "Next" || $e->getSubject()->getConfig()->getName() == "next-dynamic" || $e->getSubject()->getConfig()->getName() == "mands-dynamic") {
  30.             $thumbnailConfig $e->getSubject()->getConfig();
  31.             $pathReferences $e->getSubject()->getPathReference();
  32.             if ($pathReferences['storagePath']) {
  33.                 $thumbnailFile "\"" PIMCORE_WEB_ROOT '/var/tmp/nasthumbnails' $pathReferences['storagePath'] . "\"";
  34.                 $exiftool \Pimcore\Tool\Console::getExecutable('exiftool');
  35.                 if ($exiftool) {
  36.                     $dpi 300;
  37.                     $process = new Process([$exiftool'-overwrite_original''-xresolution=' $dpi'-yresolution=' $dpi'-resolutionunit=inches'$thumbnailFile]);
  38.                     $result $process->run();
  39.                 }
  40.             }
  41.         }
  42.     }
  43.     
  44. }