コード例 #1
0
 /**
  * @param FileUploadEvent $event
  */
 public function beforeUpload(FileUploadEvent $event)
 {
     if (!$this->belongsToProfile($event->getProfile()->getIdentifier())) {
         return;
     }
     $upload = $event->getFileUpload();
     if (!preg_match("/^image/", $upload->getMimeType())) {
         return;
     }
     $helper = new ImageMagickHelper($upload->getRealPath(), $this->tempFiles, $this->commandDefinitions);
     $tempnam = $helper->execute();
     $pinfo = pathinfo($upload->getUploadFilename());
     $nupload = new FileUpload($tempnam);
     $mimeTypes = new MimeTypes();
     $extension = $mimeTypes->mimeTypeToExtension($nupload->getMimeType());
     $nupload->setOverrideFilename($pinfo['filename'] . '.' . $extension);
     $event->setFileUpload($nupload);
 }
コード例 #2
0
 /**
  * @param File $file
  * @param Version $version
  * @return array
  */
 protected function doCreateTemporaryVersion(File $file, Version $version)
 {
     $version = $this->ensureValidVersion($version);
     $retrieved = $this->storage->retrieve($file->getResource());
     $commandDefinitions = call_user_func_array($this->commandDefinitionsGetter, array($file, $version, $this));
     $helper = new ImageMagickHelper($retrieved, $this->tempFiles, $commandDefinitions);
     return array($version->toString(), $helper->execute());
 }
コード例 #3
0
 /**
  * @test
  */
 public function throwsUpWithInvalidSource()
 {
     $helper = new ImageMagickHelper(ROOT_TESTS . '/data/illusive-manatee.jpg', new TemporaryFileManager(ROOT_TESTS . '/data/temp'));
     $this->setExpectedException('Xi\\Filelib\\RuntimeException');
     $helper->execute();
 }