From 4bb458b14a9d6713afff4c2f4a930c74fddc8f43 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Tue, 27 Apr 2010 04:53:39 +0200 Subject: [PATCH] Pull the factory over to the binder. --- framework/Cache/lib/Horde/Cache.php | 34 -------------------------- framework/Core/lib/Horde/Core/Binder/Cache.php | 18 +++++++++++++- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/framework/Cache/lib/Horde/Cache.php b/framework/Cache/lib/Horde/Cache.php index 347166c52..ee39a5b03 100644 --- a/framework/Cache/lib/Horde/Cache.php +++ b/framework/Cache/lib/Horde/Cache.php @@ -16,38 +16,4 @@ */ class Horde_Cache { - /** - * Attempts to return a concrete Horde_Cache instance based on $driver. - * - * @param mixed $driver The type of concrete Horde_Cache subclass to - * return. If $driver is an array, then we will look - * in $driver[0]/lib/Cache/ for the subclass - * implementation named $driver[1].php. - * @param array $params A hash containing any additional configuration - * or connection parameters a subclass might need. - * - * @return Horde_Cache The newly created concrete Horde_Cache instance. - * @throws Horde_Exception - */ - static public function factory($driver, $params = array()) - { - if (is_array($driver)) { - list($app, $driv_name) = $driver; - $driver = basename($driv_name); - } else { - $driver = basename($driver); - } - - if (empty($driver) || $driver == 'none') { - return new Horde_Cache_Null($params); - } - - $class = (empty($app) ? 'Horde' : $app) . '_Cache_' . ucfirst($driver); - if (class_exists($class)) { - return new $class($params); - } - - throw new Horde_Exception('Class definition of ' . $class . ' not found.'); - } - } diff --git a/framework/Core/lib/Horde/Core/Binder/Cache.php b/framework/Core/lib/Horde/Core/Binder/Cache.php index 7379fd80d..4b38fb073 100644 --- a/framework/Core/lib/Horde/Core/Binder/Cache.php +++ b/framework/Core/lib/Horde/Core/Binder/Cache.php @@ -32,7 +32,23 @@ class Horde_Core_Binder_Cache implements Horde_Injector_Binder $params['logger'] = $injector->getInstance('Horde_Log_Logger'); - return Horde_Cache::factory($driver, $params); + if (is_array($driver)) { + list($app, $driv_name) = $driver; + $driver = basename($driv_name); + } else { + $driver = basename($driver); + } + + if (empty($driver) || $driver == 'none') { + return new Horde_Cache_Null($params); + } + + $class = (empty($app) ? 'Horde' : $app) . '_Cache_' . ucfirst($driver); + if (class_exists($class)) { + return new $class($params); + } + + throw new Horde_Exception('Class definition of ' . $class . ' not found.'); } public function equals(Horde_Injector_Binder $binder) -- 2.11.0