Author: caefer
Date: 2010-03-25 10:17:20 +0100 (Thu, 25 Mar 2010)
New Revision: 28779
Modified:
plugins/sfImageTransformExtraPlugin/trunk/config/settings.yml
plugins/sfImageTransformExtraPlugin/trunk/config/sfImageTransformExtraPluginConfiguration.class.php
plugins/sfImageTransformExtraPlugin/trunk/lib/cache/sfRawFileCache.class.php
plugins/sfImageTransformExtraPlugin/trunk/package.xml.tmpl
plugins/sfImageTransformExtraPlugin/trunk/test/unit/config/sfImageTransformExtraPluginConfigurationTest.php
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/cache/sfRawFileCacheTest.php
Log:
small refactoring.
* sf_cache_namespace_callable is now dynamically set only for
sfImageTransformator module instead of globally which caused sideeffects
* setCacheKey callback moved to sfRawFileCache
Modified: plugins/sfImageTransformExtraPlugin/trunk/config/settings.yml
===================================================================
--- plugins/sfImageTransformExtraPlugin/trunk/config/settings.yml
2010-03-25 08:52:43 UTC (rev 28778)
+++ plugins/sfImageTransformExtraPlugin/trunk/config/settings.yml
2010-03-25 09:17:20 UTC (rev 28779)
@@ -1,7 +1,5 @@
all:
.settings:
- cache_namespace_callable:
sfImageTransformExtraPluginConfiguration::setCacheKey
-
thumbnail_cache:
class: sfRawFileCache
param:
Modified:
plugins/sfImageTransformExtraPlugin/trunk/config/sfImageTransformExtraPluginConfiguration.class.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/config/sfImageTransformExtraPluginConfiguration.class.php
2010-03-25 08:52:43 UTC (rev 28778)
+++
plugins/sfImageTransformExtraPlugin/trunk/config/sfImageTransformExtraPluginConfiguration.class.php
2010-03-25 09:17:20 UTC (rev 28779)
@@ -38,22 +38,6 @@
}
/**
- * Callback to set a custom cache key
- *
- * This sets the cache key to the same value as the current image url.
- * set in settings.yml / cache_namespace_callable
- *
- * @static
- * @param sfEvent $event Event object as passed by symfony event system
- *
- * @return void
- */
- static public function setCacheKey($internalUri, $hostName = '', $vary = '',
$contextualPrefix = '', $sfViewCacheManager)
- {
- return sfContext::getInstance()->getController()->genUrl($internalUri,
false);
- }
-
- /**
* Set a custom view cache class that just dumps the raw file with no expire
time stuff
*
* @static
@@ -67,6 +51,8 @@
if(sfConfig::get('sf_cache') && 'sfImageTransformator' ==
$params['module'] && 'index' == $params['action'])
{
+ sfConfig::set('sf_cache_namespace_callable',
'sfRawFileCache::setCacheKey');
+
$viewCacheManager =
sfContext::getInstance(sfConfig::get('sf_app'))->getViewCacheManager();
$viewCacheManager->initialize(
$viewCacheManager->getContext(),
Modified:
plugins/sfImageTransformExtraPlugin/trunk/lib/cache/sfRawFileCache.class.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/lib/cache/sfRawFileCache.class.php
2010-03-25 08:52:43 UTC (rev 28778)
+++
plugins/sfImageTransformExtraPlugin/trunk/lib/cache/sfRawFileCache.class.php
2010-03-25 09:17:20 UTC (rev 28779)
@@ -157,4 +157,20 @@
{
return
$this->getOption('cache_dir').DIRECTORY_SEPARATOR.str_replace(sfCache::SEPARATOR,
DIRECTORY_SEPARATOR, $key);
}
+
+ /**
+ * Callback to set a custom cache key
+ *
+ * This sets the cache key to the same value as the current image url.
+ * set in settings.yml / cache_namespace_callable
+ *
+ * @static
+ * @param sfEvent $event Event object as passed by symfony event system
+ *
+ * @return void
+ */
+ static public function setCacheKey($internalUri, $hostName = '', $vary = '',
$contextualPrefix = '', $sfViewCacheManager)
+ {
+ return sfContext::getInstance()->getController()->genUrl($internalUri,
false);
+ }
}
Modified: plugins/sfImageTransformExtraPlugin/trunk/package.xml.tmpl
===================================================================
--- plugins/sfImageTransformExtraPlugin/trunk/package.xml.tmpl 2010-03-25
08:52:43 UTC (rev 28778)
+++ plugins/sfImageTransformExtraPlugin/trunk/package.xml.tmpl 2010-03-25
09:17:20 UTC (rev 28779)
@@ -50,6 +50,23 @@
<changelog>
<release>
<version>
+ <release>0.9.5</release>
+ <api>0.9.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.org/license">MIT
license</license>
+ <date>2010-03-21</date>
+ <license>MIT</license>
+ <notes>
+ * caefer: sf_cache_namespace_callable now set only for
sfImageTranformator module and moved from settings.yml to
sfImageTransformExtraPluginConfiguration
+ * caefer: moved setCacheKey callback from
sfImageTransformExtraPluginConfiguration to sfRawFileCache
+ </notes>
+ </release>
+ <release>
+ <version>
<release>0.9.4</release>
<api>0.9.0</api>
</version>
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/unit/config/sfImageTransformExtraPluginConfigurationTest.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/unit/config/sfImageTransformExtraPluginConfigurationTest.php
2010-03-25 08:52:43 UTC (rev 28778)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/unit/config/sfImageTransformExtraPluginConfigurationTest.php
2010-03-25 09:17:20 UTC (rev 28779)
@@ -37,14 +37,6 @@
$this->assertEquals($changed_source + 1,
count($dispatcher->getListeners('sf_image_transform.changed_source')));
}
- public function testSetCacheKey()
- {
- $internalUri =
'sfImageTransformator/index?type=TestFile&format=original&path=00/00/00&slug=barfoo&id=1&sf_format=jpg';
- $viewCacheManager = new sfViewCacheManager(sfContext::getInstance(), new
sfNoCache());
- $path =
sfImageTransformExtraPluginConfiguration::setCacheKey($internalUri, '', '', '',
$viewCacheManager);
-
$this->assertContains('/thumbnails/TestFile/original/00/00/00/barfoo-1.jpg',
$path);
- }
-
public function testSetViewCache()
{
if(false !== sfConfig::get('sf_cache'))
Modified:
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/cache/sfRawFileCacheTest.php
===================================================================
---
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/cache/sfRawFileCacheTest.php
2010-03-25 08:52:43 UTC (rev 28778)
+++
plugins/sfImageTransformExtraPlugin/trunk/test/unit/lib/cache/sfRawFileCacheTest.php
2010-03-25 09:17:20 UTC (rev 28779)
@@ -59,6 +59,14 @@
$this->assertEquals(0, $this->cache->getTimeout('any_key'));
}
+ public function testSetCacheKey()
+ {
+ $internalUri =
'sfImageTransformator/index?type=TestFile&format=original&path=00/00/00&slug=barfoo&id=1&sf_format=jpg';
+ $viewCacheManager = new sfViewCacheManager(sfContext::getInstance(), new
sfNoCache());
+ $path = sfRawFileCache::setCacheKey($internalUri, '', '', '',
$viewCacheManager);
+
$this->assertContains('/thumbnails/TestFile/original/00/00/00/barfoo-1.jpg',
$path);
+ }
+
private function getCache($dir)
{
return new sfRawFileCache(array(
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.