Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Imagine Adapter due to last ImagineBundle commits #106

Merged
merged 1 commit into from
Jul 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor/
composer.lock
Tests/Resources/app/cache
Tests/Resources/app/logs
Tests/Resources/web
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:

matrix:
allow_failures:
- php: 5.3
- env: SYMFONY_VERSION=dev-master
include:
- php: 5.5
Expand Down
4 changes: 2 additions & 2 deletions Adapter/LiipImagine/CmfMediaDoctrineLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,7 +47,7 @@ public function __construct(
{
$manager = $registry->getManager($managerName);

parent::__construct($imagine, $manager, $class);
parent::__construct($manager, $class);

$this->mediaManager = $mediaManager;
}
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/adapter-imagine-phpcr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="cmf_media.liip_imagine.doctrine_phpcr.data.loader.class">Symfony\Cmf\Bundle\MediaBundle\Adapter\LiipImagine\CmfMediaDoctrineLoader</parameter>
<parameter key="cmf_media.liip_imagine.doctrine_phpcr.binary.loader.class">Symfony\Cmf\Bundle\MediaBundle\Adapter\LiipImagine\CmfMediaDoctrineLoader</parameter>
</parameters>

<services>

<service id="cmf_media.liip_imagine.doctrine_phpcr.data.loader" class="%cmf_media.liip_imagine.doctrine_phpcr.data.loader.class%">
<tag name="liip_imagine.data.loader" loader="cmf_media_doctrine_phpcr" />
<service id="cmf_media.liip_imagine.doctrine_phpcr.binary.loader" class="%cmf_media.liip_imagine.doctrine_phpcr.binary.loader.class%">
<tag name="liip_imagine.binary.loader" loader="cmf_media_doctrine_phpcr" />
<argument type="service" id="liip_imagine" />
<argument type="service" id="doctrine_phpcr" />
<argument>%cmf_media.persistence.phpcr.manager_name%</argument>
Expand Down
3 changes: 1 addition & 2 deletions Templating/Helper/CmfMediaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
}

Expand Down
5 changes: 4 additions & 1 deletion Tests/Resources/app/config/cmf_media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions Tests/Resources/app/config/routing/liip_imagine.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
_imagine:
resource: .
type: imagine
_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.xml"
15 changes: 13 additions & 2 deletions Tests/WebTest/TestApp/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down