Permalink
Browse files

added new option "auto_clear_cache" so the cache_clearer can be disabled

  • Loading branch information...
1 parent e01cb51 commit c4a6ccb0be880e22a8f6a1cb33116299bbb7fd0c Martin Parsiegla committed Aug 23, 2012
@@ -32,6 +32,7 @@ public function getConfigTreeBuilder()
->scalarNode('cache_prefix')->defaultValue('/media/cache')->end()
->scalarNode('cache')->defaultValue('web_path')->end()
->scalarNode('cache_base_path')->defaultValue('')->end()
+ ->booleanNode('auto_clear_cache')->defaultValue(true)->end()
->scalarNode('data_loader')->defaultValue('filesystem')->end()
->scalarNode('controller_action')->defaultValue('liip_imagine.controller:filterAction')->end()
->arrayNode('formats')
@@ -25,6 +25,10 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('imagine.xml');
+ if ($config['auto_clear_cache']) {
+ $loader->load('cache_clearer.xml');
+ }
+
$container->setAlias('liip_imagine', new Alias('liip_imagine.'.$config['driver']));
$cachePrefix = $config['cache_prefix'] ? '/'.trim($config['cache_prefix'], '/') : '';
View
@@ -169,6 +169,7 @@ liip_imagine:
data_root: %liip_imagine.web_root%
cache_prefix: /media/cache
cache: web_path
+ auto_clear_cache true
data_loader: filesystem
controller_action: liip_imagine.controller:filterAction
formats: []
@@ -212,6 +213,11 @@ There are several configuration options available:
default: web_path (which means the standard web_path resolver is used)
+ - `auto_clear_cache` - Whether or not to clear the image cache when the `kernel.cache_clearer` event occurs.
+ This option doesn't have any effect in symfony < 2.1
+
+ default: true
+
- `data_loader` - name of a custom data loader
default: filesystem (which means the standard filesystem loader is used)
@@ -454,7 +460,7 @@ liip_imagine:
my_custom_filter: { }
```
-Add loader to your services
+Add loader to your services
``` xml
<service id="liip_imagine.data.loader.grid_fs" class="Liip\ImagineBundle\Imagine\Data\Loader\GridFSLoader">
<tag name="liip_imagine.data.loader" loader="grid_fs" />
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<container xmlns="http://symfony.com/schema/dic/services"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+ <parameters>
+ <parameter key="liip_imagine.cache.clearer.class">Liip\ImagineBundle\Imagine\Cache\CacheClearer</parameter>
+ </parameters>
+
+ <services>
+
+ <service id="liip_imagine.cache.clearer" class="%liip_imagine.cache.clearer.class%">
+ <tag name="kernel.cache_clearer" />
+ <argument type="service" id="liip_imagine.cache.manager" />
+ <argument>%liip_imagine.cache_prefix%</argument>
+ </service>
+
+ </services>
+</container>
@@ -48,10 +48,6 @@
<parameter key="liip_imagine.cache.resolver.web_path.class">Liip\ImagineBundle\Imagine\Cache\Resolver\WebPathResolver</parameter>
<parameter key="liip_imagine.cache.resolver.no_cache.class">Liip\ImagineBundle\Imagine\Cache\Resolver\NoCacheResolver</parameter>
- <!-- Cache clearers' classes -->
-
- <parameter key="liip_imagine.cache.clearer.class">Liip\ImagineBundle\Imagine\Cache\CacheClearer</parameter>
-
</parameters>
<services>
@@ -159,13 +155,5 @@
<argument type="service" id="filesystem" />
</service>
- <!-- Cache Clearer -->
-
- <service id="liip_imagine.cache.clearer" class="%liip_imagine.cache.clearer.class%">
- <tag name="kernel.cache_clearer" />
- <argument type="service" id="liip_imagine.cache.manager" />
- <argument>%liip_imagine.cache_prefix%</argument>
- </service>
-
</services>
</container>
@@ -50,7 +50,7 @@ public function testLoadWithDefaults()
public function testCacheClearerRegistration()
{
- $this->createFullConfiguration();
+ $this->createEmptyConfiguration();
if ('2' == Kernel::MAJOR_VERSION && '0' == Kernel::MINOR_VERSION) {
$this->assertFalse($this->containerBuilder->hasDefinition('liip_imagine.cache.clearer'));
@@ -63,6 +63,13 @@ public function testCacheClearerRegistration()
}
}
+ public function testCacheClearerIsNotRegistered()
+ {
+ $this->createFullConfiguration();
+
+ $this->assertFalse($this->containerBuilder->hasDefinition('liip_imagine.cache.clearer'));
+ }
+
/**
* @return ContainerBuilder
*/
@@ -92,6 +99,7 @@ protected function getFullConfig()
web_root: ../foo/bar
cache_prefix: /imagine/cache
cache: false
+auto_clear_cache: false
formats: ['json', 'xml', 'jpg', 'png', 'gif']
filter_sets:
small:

0 comments on commit c4a6ccb

Please sign in to comment.