Skip to content

Instantly share code, notes, and snippets.

@kawahara
Created April 2, 2010 19:09
Show Gist options
  • Save kawahara/353563 to your computer and use it in GitHub Desktop.
Save kawahara/353563 to your computer and use it in GitHub Desktop.
diff --git a/lib/config/sfOpenPNEApplicationConfiguration.class.php b/lib/config/sfOpenPNEApplicationConfiguration.class.php
index aabc8bd..43b3699 100644
--- a/lib/config/sfOpenPNEApplicationConfiguration.class.php
+++ b/lib/config/sfOpenPNEApplicationConfiguration.class.php
@@ -19,6 +19,9 @@ abstract class sfOpenPNEApplicationConfiguration extends sfApplicationConfigurat
{
static protected $zendLoaded = false;
+ protected $globEnablePluginList = array();
+ protected $globEnablePluginControllerList = array();
+
public function initialize()
{
mb_internal_encoding('UTF-8');
@@ -377,7 +380,40 @@ abstract class sfOpenPNEApplicationConfiguration extends sfApplicationConfigurat
public function globEnablePlugin($pattern, $isControllerPath = false)
{
- return $this->globPlugins($pattern, false, $isControllerPath);
+ $cacheKey = md5($pattern);
+ $cacheHead = substr($cacheKey, 0, 2);
+ $cacheDir = sfConfig::get('sf_app_cache_dir').'/config/';
+
+ if ($isControllerPath)
+ {
+ $cacheFile = $cacheDir.substr($cacheKey, 0, 2).'_glob_enable_plugin_path_controller.php';
+ $cacheProperty = 'globEnablePluginControllerList';
+ }
+ else
+ {
+ $cacheFile = $cacheDir.substr($cacheKey, 0, 2).'_glob_enable_plugin_path.php';
+ $cacheProperty = 'globEnablePluginList';
+ }
+
+ $_prop =& $this->$cacheProperty;
+
+ if (empty($_prop[$cacheHead]))
+ {
+ if (is_readable($cacheFile))
+ {
+ $_prop[$cacheHead] = include $cacheFile;
+ }
+ }
+
+ if (isset($_prop[$cacheHead][$cacheKey]))
+ {
+ return $_prop[$cacheHead][$cacheKey];
+ }
+
+ $_prop[$cacheHead][$cacheKey] = $this->globPlugins($pattern, false, $isControllerPath);
+ file_put_contents($cacheFile, "<?php\nreturn ".var_export($_prop[$cacheHead], true).";");
+
+ return $_prop[$cacheHead][$cacheKey];
}
public function getGlobalTemplateDir($templateFile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment