/**
  * {@inheritDoc}
  */
 public function getBrowserPath($path, $filter, $absolute = false)
 {
     $objectPath = $this->getObjectPath($path, $filter);
     if ($this->objectExists($objectPath)) {
         return $this->getObjectUrl($objectPath);
     }
     return $this->cacheManager->generateUrl($path, $filter, $absolute);
 }
Exemple #2
0
    public function testGenerateUrl()
    {
        $path = 'thePath';
        $expectedUrl = 'theUrl';

        $routerMock = $this->createRouterMock();
        $routerMock
            ->expects($this->once())
            ->method('generate')
            ->with(
                'liip_imagine_filter',
                array(
                    'path' => $path,
                    'filter' => 'thumbnail',
                ),
                true
            )
            ->will($this->returnValue($expectedUrl))
        ;

        $cacheManager = new CacheManager(
            $this->createFilterConfigurationMock(),
            $routerMock,
            new Signer('secret'),
            $this->createEventDispatcherMock()
        );

        $this->assertEquals(
            $expectedUrl,
            $cacheManager->generateUrl($path, 'thumbnail')
        );
    }
 /**
  * @dataProvider generateUrlProvider
  */
 public function testGenerateUrl($filterConfig, $targetPath, $expectedPath)
 {
     $config = $this->getMockFilterConfiguration();
     $config->expects($this->once())->method('get')->with('thumbnail')->will($this->returnValue($filterConfig));
     $router = $this->getMockRouter();
     $router->expects($this->once())->method('generate')->with('_imagine_thumbnail', array('path' => $expectedPath), true);
     $cacheManager = new CacheManager($config, $router, $this->fixturesDir . '/assets');
     $cacheManager->generateUrl($targetPath, 'thumbnail', true);
 }
 /**
  * @inheritDoc
  */
 public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver = null)
 {
     $path = parse_url($path, PHP_URL_PATH);
     return parent::generateUrl($path, $filter, $runtimeConfig, $resolver);
 }
 /**
  * {@inheritdoc}
  */
 public function generateUrl($path, $filter, array $runtimeConfig = array(), $resolver = null)
 {
     $filterConf = $this->filterConfig->get($filter);
     $path = $this->changeFileExtension(ltrim($path, '/'), $filterConf['format']);
     return parent::generateUrl($path, $filter, $runtimeConfig, $resolver);
 }