From: Michael M Slusarz Date: Tue, 16 Nov 2010 04:52:41 +0000 (-0700) Subject: Need way to override Horde config when creating Prefs object X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=43c26eb4bb0405ed2b4391df3b6c57a7340525a4;p=horde.git Need way to override Horde config when creating Prefs object --- diff --git a/framework/Core/lib/Horde/Core/Factory/Prefs.php b/framework/Core/lib/Horde/Core/Factory/Prefs.php index 8d72ead7b..584215949 100644 --- a/framework/Core/lib/Horde/Core/Factory/Prefs.php +++ b/framework/Core/lib/Horde/Core/Factory/Prefs.php @@ -55,13 +55,23 @@ class Horde_Core_Factory_Prefs * Return the Horde_Prefs:: instance. * * @param string $scope The scope for this set of preferences. - * @param array $opts See Horde_Prefs::__construct(). + * @param array $opts See Horde_Prefs::__construct(). Additional + * parameters: + *
+     * driver - (boolean) Use this driver instead of the value in the Horde
+     *          config.
+     * driver_params - (array) Use these driver parameters instead of the
+     *                 values in the Horde config.
+     * 
* * @return Horde_Prefs The singleton instance. */ public function create($scope = 'horde', array $opts = array()) { - if (empty($GLOBALS['conf']['prefs']['driver'])) { + if (array_key_exists('driver', $opts)) { + $driver = $opts['driver']; + $params = array(); + } elseif (empty($GLOBALS['conf']['prefs']['driver'])) { $driver = null; $params = array(); } else { @@ -69,6 +79,10 @@ class Horde_Core_Factory_Prefs $params = Horde::getDriverConfig('prefs', $driver); } + if (array_key_exists('driver_params', $opts)) { + $params = $opts['driver_params']; + } + $opts = array_merge(array( 'cache' => true, 'logger' => $this->_injector->getInstance('Horde_Log_Logger'), @@ -118,7 +132,7 @@ class Horde_Core_Factory_Prefs $hooks_driver ); - if ($opts['cache']) { + if ($driver && $opts['cache']) { $opts['cache'] = new Horde_Core_Prefs_Cache_Session($opts['user']); } else { unset($opts['cache']); diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index fee181a2c..3a8130569 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -1335,8 +1335,7 @@ class Horde_Registry /* If there is no logged in user, return an empty Horde_Prefs * object with just default preferences. */ $opts = array( - 'cache' => null, - 'session' => true + 'driver' => null ); }