Is there a reason why sfDatabaseManager must depend on 
sfApplicationConfiguration?  Can't it depend on sfProjectConfiguration 
instead?

If we remove this dependency, then we can use symfony's database manager 
outside of an application context.  Then we can remove the application 
argument on the propel:data-load task (and prevent me from adding it to an 
sfSearch task).

Initial patch for this is attached.  If it's viable, I will create a ticket.  
This patch simply moves two methods to sfProjectConfiguration and writes the 
configuration cache to %SF_ROOT_DIR%/cache/default/config when outside of an 
application context.

The patch has an unattended side-affect of causing the Propel functional tests 
to fail.  I will fix these if/when this patch is accepted.

Carl

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" 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-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Index: lib/database/sfDatabaseManager.class.php
===================================================================
--- lib/database/sfDatabaseManager.class.php	(revision 8563)
+++ lib/database/sfDatabaseManager.class.php	(working copy)
@@ -31,7 +31,7 @@
    *
    * @see initialize()
    */
-  public function __construct(sfApplicationConfiguration $configuration, $options = array())
+  public function __construct(sfProjectConfiguration $configuration, $options = array())
   {
     $this->initialize($configuration);
 
@@ -44,13 +44,13 @@
   /**
    * Initializes this sfDatabaseManager object
    *
-   * @param  sfApplicationConfiguration A sfApplicationConfiguration instance
+   * @param  sfProjectConfiguration A sfProjectConfiguration instance
    *
    * @return bool true, if initialization completes successfully, otherwise false
    *
    * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfDatabaseManager object
    */
-  public function initialize(sfApplicationConfiguration $configuration)
+  public function initialize(sfProjectConfiguration $configuration)
   {
     $this->configuration = $configuration;
 
Index: lib/config/sfProjectConfiguration.class.php
===================================================================
--- lib/config/sfProjectConfiguration.class.php	(revision 8563)
+++ lib/config/sfProjectConfiguration.class.php	(working copy)
@@ -20,7 +20,8 @@
 {
   protected
     $rootDir       = null,
-    $symfonyLibDir = null;
+    $symfonyLibDir = null,
+    $configCache = null;
 
   static protected
     $active = null;
@@ -110,6 +111,7 @@
   public function setCacheDir($cacheDir)
   {
     sfConfig::set('sf_cache_dir', $cacheDir);
+    sfConfig::set('sf_config_cache_dir', $cacheDir.DIRECTORY_SEPARATOR.'default'.DIRECTORY_SEPARATOR.'config');
   }
 
   /**
@@ -136,6 +138,68 @@
   }
 
   /**
+   * Returns a configuration cache object for the current configuration.
+   *
+   * @return sfConfigCache A sfConfigCache instance
+   */
+  public function getConfigCache()
+  {
+    if (is_null($this->configCache))
+    {
+      $this->configCache = new sfConfigCache($this);
+    }
+
+    return $this->configCache;
+  }
+
+  /**
+   * Gets the configuration file paths for a given relative configuration path.
+   *
+   * @param string The configuration path
+   *
+   * @return array An array of paths
+   */
+  public function getConfigPaths($configPath)
+  {
+    $globalConfigPath = basename(dirname($configPath)).'/'.basename($configPath);
+
+    $files = array(
+      sfConfig::get('sf_symfony_lib_dir').'/config/'.$globalConfigPath,              // symfony
+    );
+
+    if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/'.$globalConfigPath))
+    {
+      $files = array_merge($files, $bundledPluginDirs);                              // bundled plugins
+    }
+
+    if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$globalConfigPath))
+    {
+      $files = array_merge($files, $pluginDirs);                                     // plugins
+    }
+
+    $files = array_merge($files, array(
+      sfConfig::get('sf_root_dir').'/'.$globalConfigPath,                            // project
+      sfConfig::get('sf_root_dir').'/'.$configPath,                                  // project
+    ));
+
+    if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$configPath))
+    {
+      $files = array_merge($files, $pluginDirs);                                     // plugins
+    }
+
+    $configs = array();
+    foreach (array_unique($files) as $file)
+    {
+      if (is_readable($file))
+      {
+        $configs[] = $file;
+      }
+    }
+
+    return $configs;
+  }
+
+  /**
    * Gets directories where model classes are stored.
    *
    * @return array An array of directories
Index: lib/config/sfConfigCache.class.php
===================================================================
--- lib/config/sfConfigCache.class.php	(revision 8563)
+++ lib/config/sfConfigCache.class.php	(working copy)
@@ -30,9 +30,9 @@
   /**
    * Constructor
    *
-   * @param sfApplicationConfiguration A sfApplicationConfiguration instance
+   * @param sfProjectConfiguration A sfProjectConfiguration instance
    */
-  public function __construct(sfApplicationConfiguration $configuration)
+  public function __construct(sfProjectConfiguration $configuration)
   {
     $this->configuration = $configuration;
   }
Index: lib/config/sfApplicationConfiguration.class.php
===================================================================
--- lib/config/sfApplicationConfiguration.class.php	(revision 8563)
+++ lib/config/sfApplicationConfiguration.class.php	(working copy)
@@ -19,7 +19,6 @@
 abstract class sfApplicationConfiguration extends ProjectConfiguration
 {
   protected
-    $configCache = null,
     $application = null,
     $environment = null,
     $debug       = false,
@@ -145,21 +144,6 @@
   }
 
   /**
-   * Returns a configuration cache object for the current configuration.
-   *
-   * @return sfConfigCache A sfConfigCache instance
-   */
-  public function getConfigCache()
-  {
-    if (is_null($this->configCache))
-    {
-      $this->configCache = new sfConfigCache($this);
-    }
-
-    return $this->configCache;
-  }
-
-  /**
    * Check lock files to see if we're not in a cache cleaning process.
    *
    * @return void
@@ -449,42 +433,16 @@
   }
 
   /**
-   * Gets the configuration file paths for a given relative configuration path.
-   *
-   * @param string The configuration path
-   *
-   * @return array An array of paths
+   * @see sfProjectConfiguration
    */
   public function getConfigPaths($configPath)
   {
+    $files = parent::getConfigPaths($configPath);
+
     $globalConfigPath = basename(dirname($configPath)).'/'.basename($configPath);
 
-    $files = array(
-      sfConfig::get('sf_symfony_lib_dir').'/config/'.$globalConfigPath,              // symfony
-    );
-
-    if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/'.$globalConfigPath))
-    {
-      $files = array_merge($files, $bundledPluginDirs);                              // bundled plugins
-    }
-
-    if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$globalConfigPath))
-    {
-      $files = array_merge($files, $pluginDirs);                                     // plugins
-    }
-
-    $files = array_merge($files, array(
-      sfConfig::get('sf_root_dir').'/'.$globalConfigPath,                            // project
-      sfConfig::get('sf_root_dir').'/'.$configPath,                                  // project
-      sfConfig::get('sf_app_dir').'/'.$globalConfigPath,                             // application
-      sfConfig::get('sf_app_cache_dir').'/'.$configPath,                             // generated modules
-    ));
-
-    if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$configPath))
-    {
-      $files = array_merge($files, $pluginDirs);                                     // plugins
-    }
-
+    $files[] = sfConfig::get('sf_app_dir').'/'.$globalConfigPath;                    // application
+    $files[] = sfConfig::get('sf_app_cache_dir').'/'.$configPath;                    // generated modules
     $files[] = sfConfig::get('sf_app_dir').'/'.$configPath;                          // module
 
     $configs = array();

Reply via email to