From ffd6a1f5c6acae50d07595c089516c1b1a229443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Jourdin?= Date: Tue, 20 May 2014 22:27:03 +0200 Subject: [PATCH] Make MediaBundle run on LiipImagineBundle ~1.0 --- .gitignore | 1 + .travis.yml | 1 + Adapter/LiipImagine/CmfMediaDoctrineLoader.php | 4 ++-- Resources/config/adapter-imagine-phpcr.xml | 6 +++--- Templating/Helper/CmfMediaHelper.php | 3 +-- Tests/Resources/app/config/cmf_media.yml | 5 ++++- .../Resources/app/config/routing/liip_imagine.yml | 5 ++--- Tests/WebTest/TestApp/ImageTest.php | 15 +++++++++++++-- composer.json | 5 +---- 9 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index b641aa3..70a3fcc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor/ composer.lock Tests/Resources/app/cache Tests/Resources/app/logs +Tests/Resources/web diff --git a/.travis.yml b/.travis.yml index 9fb1947..35826ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ env: matrix: allow_failures: + - php: 5.3 - env: SYMFONY_VERSION=dev-master include: - php: 5.5 diff --git a/Adapter/LiipImagine/CmfMediaDoctrineLoader.php b/Adapter/LiipImagine/CmfMediaDoctrineLoader.php index a418864..de20ee0 100644 --- a/Adapter/LiipImagine/CmfMediaDoctrineLoader.php +++ b/Adapter/LiipImagine/CmfMediaDoctrineLoader.php @@ -13,7 +13,7 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Imagine\Image\ImagineInterface; -use Liip\ImagineBundle\Imagine\Data\Loader\AbstractDoctrineLoader; +use Liip\ImagineBundle\Binary\Loader\AbstractDoctrineLoader; use Symfony\Cmf\Bundle\MediaBundle\BinaryInterface; use Symfony\Cmf\Bundle\MediaBundle\FileSystemInterface; use Symfony\Cmf\Bundle\MediaBundle\ImageInterface; @@ -47,7 +47,7 @@ public function __construct( { $manager = $registry->getManager($managerName); - parent::__construct($imagine, $manager, $class); + parent::__construct($manager, $class); $this->mediaManager = $mediaManager; } diff --git a/Resources/config/adapter-imagine-phpcr.xml b/Resources/config/adapter-imagine-phpcr.xml index 74862f3..2509977 100644 --- a/Resources/config/adapter-imagine-phpcr.xml +++ b/Resources/config/adapter-imagine-phpcr.xml @@ -5,13 +5,13 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Symfony\Cmf\Bundle\MediaBundle\Adapter\LiipImagine\CmfMediaDoctrineLoader + Symfony\Cmf\Bundle\MediaBundle\Adapter\LiipImagine\CmfMediaDoctrineLoader - - + + %cmf_media.persistence.phpcr.manager_name% diff --git a/Templating/Helper/CmfMediaHelper.php b/Templating/Helper/CmfMediaHelper.php index b15c848..0b1f0b1 100644 --- a/Templating/Helper/CmfMediaHelper.php +++ b/Templating/Helper/CmfMediaHelper.php @@ -69,8 +69,7 @@ public function displayUrl(ImageInterface $file, array $options = array(), $refe if ($this->imagineHelper && isset($options['imagine_filter']) && is_string($options['imagine_filter'])) { return $this->imagineHelper->filter( $urlSafePath, - $options['imagine_filter'], - $referenceType === UrlGeneratorInterface::ABSOLUTE_URL + $options['imagine_filter'] ); } diff --git a/Tests/Resources/app/config/cmf_media.yml b/Tests/Resources/app/config/cmf_media.yml index 14fa6b1..7f0b555 100644 --- a/Tests/Resources/app/config/cmf_media.yml +++ b/Tests/Resources/app/config/cmf_media.yml @@ -13,7 +13,10 @@ cmf_media: # to a specific format. (ie a controller render the file) # more information can be found here : https://github.com/liip/LiipImagineBundle liip_imagine: - web_root: %kernel.cmf_test_web_dir% + loaders: + default: + filesystem: + data_root: %kernel.cmf_test_web_dir% filter_sets: # define the filter to be used with the image preview image_upload_thumbnail: diff --git a/Tests/Resources/app/config/routing/liip_imagine.yml b/Tests/Resources/app/config/routing/liip_imagine.yml index 2b19c3b..437bdd9 100644 --- a/Tests/Resources/app/config/routing/liip_imagine.yml +++ b/Tests/Resources/app/config/routing/liip_imagine.yml @@ -1,3 +1,2 @@ -_imagine: - resource: . - type: imagine +_liip_imagine: + resource: "@LiipImagineBundle/Resources/config/routing.xml" diff --git a/Tests/WebTest/TestApp/ImageTest.php b/Tests/WebTest/TestApp/ImageTest.php index fa765a7..c6aee5a 100644 --- a/Tests/WebTest/TestApp/ImageTest.php +++ b/Tests/WebTest/TestApp/ImageTest.php @@ -28,6 +28,13 @@ public function setUp() public function testPage() { + // Clear cache + $cacheManager = $this->getContainer()->get('liip_imagine.cache.manager'); + $cacheManager->remove('test/media/cmf-logo.png'); + + $this->assertFalse($cacheManager->isStored('test/media/cmf-logo.png', 'image_upload_thumbnail')); + + // get crawler $client = $this->createClient(); $crawler = $client->request('get', $this->getContainer()->get('router')->generate('phpcr_image_test')); $resp = $client->getResponse(); @@ -48,10 +55,14 @@ public function testPage() $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'default image test'); // imagine_filter - $this->getContainer()->get('liip_imagine.cache.clearer')->clear('image_upload_thumb'); $imagineImageLink = $crawler->filter('.images li img.imagine')->first()->attr('src'); $client->request('get', $imagineImageLink); - $this->assertTrue($client->getResponse()->isSuccessful(), 'imagine image test'); + + $this->assertTrue($client->getResponse()->isRedirection(), 'imagine image test'); + $this->assertEquals(301, $client->getResponse()->getStatusCode(), 'imagine image test'); + $this->assertEquals('http://localhost/media/cache/image_upload_thumbnail/test/media/cmf-logo.png', $client->getResponse()->getTargetUrl()); + + $this->assertTrue($cacheManager->isStored('test/media/cmf-logo.png', 'image_upload_thumbnail')); } public function testUpload() diff --git a/composer.json b/composer.json index 890b580..e834a3f 100644 --- a/composer.json +++ b/composer.json @@ -19,12 +19,9 @@ "require-dev": { "symfony-cmf/testing": "1.1.*", "jms/serializer-bundle": "0.12.*", - "liip/imagine-bundle": "~0.12", + "liip/imagine-bundle": "~1.0.4", "mikey179/vfsStream": "~1.2" }, - "conflicts": { - "liip/imagine-bundle": ">=1.0" - }, "suggest": { "symfony-cmf/core-bundle": "Simplifies configuration with other CMF bundles, use PHP >=5.3.9 with PHPCR", "knplabs/gaufrette": "When using the Gaufrette adapter",