Author: sevein
Date: Tue Jun 14 11:01:30 2011
New Revision: 9160
Log:
Use sfFileCache for SiteSettingsFilter, clean it when settings are modified
from settings module
Modified:
trunk/apps/qubit/modules/settings/actions/listAction.class.php
trunk/lib/SiteSettingsFilter.class.php
Modified: trunk/apps/qubit/modules/settings/actions/listAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/settings/actions/listAction.class.php Tue Jun
14 10:13:02 2011 (r9159)
+++ trunk/apps/qubit/modules/settings/actions/listAction.class.php Tue Jun
14 11:01:30 2011 (r9160)
@@ -69,6 +69,10 @@
// Handle POST data (form submit)
if ($request->isMethod('post'))
{
+ // Clean cache
+ $cache = new sfFileCache(array('cache_dir' =>
sfConfig::get('sf_app_cache_dir').'/settings'));
+ $cache->clean();
+
// Global settings form submission
if (null !== $request->global_settings)
{
Modified: trunk/lib/SiteSettingsFilter.class.php
==============================================================================
--- trunk/lib/SiteSettingsFilter.class.php Tue Jun 14 10:13:02 2011
(r9159)
+++ trunk/lib/SiteSettingsFilter.class.php Tue Jun 14 11:01:30 2011
(r9160)
@@ -20,30 +20,29 @@
class siteSettingsFilter extends sfFilter
{
/*
- * execute this filter on every request in case some params have changed
since the last page load
+ * Execute this filter on every request in case some params have changed
since the last page load
*/
public function execute($filterChain)
{
- // create a function cache object for the QubitSettings method call
- //$fileCache = new sfFileCache(array('cache_dir' =>
sfConfig::get('sf_app_cache_dir').'/settings'));
+ // Create a function cache object for the QubitSettings method call
+ $cache = new sfFileCache(array('cache_dir' =>
sfConfig::get('sf_app_cache_dir').'/settings'));
- // invalidate cache when user switches culture
- // FIXME: there must be a smarter way to detect this accurately; user
culture is set very early after routing
- if ($this->context->request->sf_culture)
+ // Get settings (from cache if exists)
+ if ($cache->has('settings'))
{
- //$fileCache->clean();
+ $settings = unserialize($cache->get('settings'));
}
+ else
+ {
+ $settings = QubitSetting::getSettingsArray();
- //$functionCache = new sfFunctionCache($fileCache);
-
- // get settings (from cache if it exists)
- //$settings = $functionCache->call(array(new QubitSetting,
'getSettingsArray'));
- $settings = QubitSetting::getSettingsArray();
+ $cache->set('settings', serialize($settings));
+ }
- // overwrite/populate settings into sfConfig object
+ // Overwrite/populate settings into sfConfig object
sfConfig::add($settings);
- // execute next filter
+ // Execute next filter
$filterChain->execute();
}
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" 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/qubit-commits?hl=en.