public function testFilterDelegatesResolverResponse()
 {
     $response = $this->getMock('Symfony\\Component\\HttpFoundation\\Response');
     $cacheManager = $this->getMockCacheManager();
     $cacheManager->expects($this->once())->method('resolve')->will($this->returnValue($response));
     $dataManager = $this->getMock('Liip\\ImagineBundle\\Imagine\\Data\\DataManager', array(), array($this->configuration));
     $filterManager = $this->getMock('Liip\\ImagineBundle\\Imagine\\Filter\\FilterManager', array(), array($this->configuration));
     $controller = new ImagineController($dataManager, $filterManager, $cacheManager);
     $this->assertSame($response, $controller->filterAction(Request::create('/media/cache/thumbnail/cats.jpeg'), 'cats.jpeg', 'thumbnail'));
 }
 /**
  * {@inheritdoc}
  */
 public function filterRuntimeAction(Request $request, $hash, $path, $filter)
 {
     if ($request->query->has('originalExtension')) {
         $info = pathinfo($path);
         $path = $info['dirname'] . DIRECTORY_SEPARATOR . $info['filename'] . '.' . $request->query->getAlpha('originalExtension');
     }
     return parent::filterRuntimeAction($request, $hash, $path, $filter);
 }
Ejemplo n.º 3
0
 /**
  * @param Request $request
  * @param string  $filename
  * @param string  $filter
  *
  * @return RedirectResponse
  */
 public function showAction(Request $request, $filename, $filter = null)
 {
     $filename = urldecode($filename);
     $result = $this->renderDefaultImage(FileTypes::MISC, $filter);
     if (self::DEFAULT_IMAGE_KEY !== $filename) {
         $fileType = $this->fileTypeGuesser->guess($this->getMimeType($filename));
         $result = $this->renderDefaultImage($fileType, $filter);
         if (FileTypes::IMAGE === $fileType) {
             try {
                 $result = $this->imagineController->filterAction($request, $filename, $filter);
             } catch (NotFoundHttpException $exception) {
                 $result = $this->renderDefaultImage(FileTypes::IMAGE, $filter);
             }
         }
     }
     return $result;
 }
 /**
  * @param Request $request
  * @param string  $filename
  * @param string  $filter
  *
  * @return RedirectResponse
  */
 public function showAction(Request $request, $filename, $filter = null)
 {
     $filename = urldecode($filename);
     if (self::DEFAULT_IMAGE_KEY === $filename) {
         return $this->renderDefaultImage(FileTypes::MISC, $filter);
     }
     $file = $this->fileInfoRepository->findOneByIdentifier($filename);
     if (null !== $file) {
         if (FileTypes::IMAGE === ($fileType = $this->fileTypeGuesser->guess($file->getMimeType()))) {
             try {
                 return $this->imagineController->filterAction($request, $filename, $filter);
             } catch (NotFoundHttpException $e) {
                 return $this->renderDefaultImage(FileTypes::IMAGE, $filter);
             }
         }
         return $this->renderDefaultImage($fileType, $filter);
     }
     return $this->renderDefaultImage(FileTypes::MISC, $filter);
 }
 /**
  * @param ImagesMappingService $mappingService
  * @param DataManager     $dataManager
  * @param FilterManager   $filterManager
  * @param CacheManager    $cacheManager
  * @param SignerInterface $signer
  * @param LoggerInterface $logger
  */
 public function __construct(ImagesMappingService $mappingService, DataManager $dataManager, FilterManager $filterManager, CacheManager $cacheManager, SignerInterface $signer, LoggerInterface $logger = null)
 {
     $this->imagesMappingService = $mappingService;
     parent::__construct($dataManager, $filterManager, $cacheManager, $signer, $logger);
 }