示例#1
0
 public function getStandardExtension()
 {
     if (is_null($this->standardExtension) && !is_null($this->_bin)) {
         $this->standardExtension = ContentType::byString($this->_bin)->standardExtension();
     }
     return $this->standardExtension;
 }
 private function reportOpenOfficeConverter()
 {
     $converter = new Converter();
     $converter->configure(ContentType::pdf(), $this->tempDirectory);
     try {
         $bin = $converter->convert(file_get_contents(__DIR__ . '/../../../../test/data/test.odt'));
     } catch (OpenOfficeException $e) {
         return 'ERROR: Plugin openoffice cannot convert document.';
     }
     return strval(ContentType::pdf()) === strval(ContentType::byString($bin)) ? null : 'ERROR: Plugin openoffice converts to wrong content type.';
 }
示例#3
0
 /**
  * @return Response
  * @throws Controller\NotFoundException
  */
 public function GET()
 {
     try {
         $bin = $this->storage->getById($this->request->id);
     } catch (Storage\NotFoundException $e) {
         throw new Controller\NotFoundException();
     }
     if (is_null($this->request->contentType)) {
         $this->request->defineContentType(ContentType::byString($bin));
     }
     try {
         return self::response($this->request->contentType, $this->directionFactory->direction(ContentType::byString($bin), $this->request->contentType, $this->request->commandString)->convert($bin));
     } catch (Plugin\NotAvailableException $e) {
         throw new Controller\NotFoundException();
     } catch (Exception\AmbiguousPluginCommand $e) {
         throw new Controller\NotFoundException();
     } catch (Exception\ConversionNotPossible $e) {
         throw new Controller\NotFoundException();
     }
 }
 public function testConvertsGifToJpegWithResizingAndBackgroundAndCanvasAndQuality()
 {
     $bin = self::converter()->convert(file_get_contents(__DIR__ . '/data/1x1.gif'), self::resize10x10bgFF00FFcanvas20x20quality41Command());
     $this->assertEquals(ContentType::jpeg(), ContentType::byString($bin));
 }
 public function testConvertsGitToJpegWithResizing()
 {
     $bin = $this->converter()->convert(file_get_contents(__DIR__ . '/data/test.odt'));
     $this->assertEquals(ContentType::pdf(), ContentType::byString($bin));
 }