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

fixed #81 cache clearer only registered for sf2.1 #82

Merged
merged 3 commits into from
Jun 20, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions DependencyInjection/LiipImagineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
namespace Liip\ImagineBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Reference;

use Liip\ImagineBundle\LiipImagineBundle;

class LiipImagineExtension extends Extension
{
/**
Expand Down Expand Up @@ -40,5 +44,9 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('liip_imagine.data.loader.default', $config['data_loader']);

$container->setParameter('liip_imagine.controller_action', $config['controller_action']);

if (version_compare(LiipImagineBundle::getSymfonyVersion(Kernel::VERSION), '2.1.0', '<')) {
$container->removeDefinition('liip_imagine.cache.clearer');
}
}
}
14 changes: 14 additions & 0 deletions LiipImagineBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,18 @@ public function build(ContainerBuilder $container)

$container->addCompilerPass(new LoadersCompilerPass());
}

/**
* Returns a cleaned version number
*
* @param string $version
* @return string
*/
public static function getSymfonyVersion($version)
{
return implode('.', array_slice(array_map(function($val)
{
return (int)$val;
}, explode('.', $version)), 0, 3));
}
}
17 changes: 17 additions & 0 deletions Tests/DependencyInjection/LiipImagineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace Liip\ImagineBundle\Tests\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Liip\ImagineBundle\LiipImagineBundle;
use Liip\ImagineBundle\DependencyInjection\LiipImagineExtension;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -46,6 +48,21 @@ public function testLoadWithDefaults()
);
}

public function testCacheClearerRegistration()
{
$this->createFullConfiguration();

if (version_compare(LiipImagineBundle::getSymfonyVersion(Kernel::VERSION), '2.1.0', '<')) {
$this->assertFalse($this->containerBuilder->hasDefinition('liip_imagine.cache.clearer'));
} else {
$this->assertTrue($this->containerBuilder->hasDefinition('liip_imagine.cache.clearer'));

$definition = $this->containerBuilder->getDefinition('liip_imagine.cache.clearer');
$definition->hasTag('kernel.cache_clearer');
$this->assertCount(2, $definition->getArguments());
}
}

/**
* @return ContainerBuilder
*/
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"require": {
"php": ">=5.3.2",
"imagine/Imagine": "<=0.2.8",
"symfony/framework-bundle": ">=2.0,<2.2-dev"
"symfony/framework-bundle": ">=2.0,<2.2-dev",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should require >=2.0.14 as you use the constant without doing a defined check (which is fine IMO as we have 2 working releases in the 2.0 series already)

"symfony/yaml": ">=2.0,<2.2-dev"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is depending on yaml ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its missing in the DIC tests...checked it out standalone, and it didnt get installed by composer.

should it be installed for "symfony/framework-bundle" dep?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is only for the tests, it should go in require-dev, not in require

},

"require-dev": {
Expand Down