From 4c9851a3f408d9f7823cd4ee7eb1520ac3435010 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Sat, 2 Oct 2010 22:29:18 -0400 Subject: [PATCH] Rebuild factory for Perms --- .../lib/Horde/Core/{Binder => Factory}/Perms.php | 22 +++++++++++++++++-- framework/Core/lib/Horde/Registry.php | 5 ++++- framework/Core/package.xml | 6 +++--- framework/Perms/lib/Horde/Perms.php | 25 ---------------------- 4 files changed, 27 insertions(+), 31 deletions(-) rename framework/Core/lib/Horde/Core/{Binder => Factory}/Perms.php (53%) diff --git a/framework/Core/lib/Horde/Core/Binder/Perms.php b/framework/Core/lib/Horde/Core/Factory/Perms.php similarity index 53% rename from framework/Core/lib/Horde/Core/Binder/Perms.php rename to framework/Core/lib/Horde/Core/Factory/Perms.php index 5a7d83120..937948732 100644 --- a/framework/Core/lib/Horde/Core/Binder/Perms.php +++ b/framework/Core/lib/Horde/Core/Factory/Perms.php @@ -1,10 +1,20 @@ + * * @category Horde * @package Core */ -class Horde_Core_Binder_Perms implements Horde_Injector_Binder +class Horde_Core_Factory_Perms { + /** + * Attempts to return a concrete instance based on $driver. + * + * @return Horde_Perms The newly created concrete instance. + * @throws Horde_Perms_Exception + */ public function create(Horde_Injector $injector) { $driver = $GLOBALS['conf']['perms']['driver']; @@ -19,7 +29,15 @@ class Horde_Core_Binder_Perms implements Horde_Injector_Binder $params['cache'] = $injector->getInstance('Horde_Cache'); $params['logger'] = $injector->getInstance('Horde_Log_Logger'); - return Horde_Perms::factory($driver, $params); + $class = is_null($driver) + ? 'Horde_Perms' + : 'Horde_Perms' . '_' . ucfirst(basename($driver)); + + if (class_exists($class)) { + return new $class($params); + } + + throw new Horde_Perms_Exception('Unknown driver: ' . $driver); } public function equals(Horde_Injector_Binder $binder) diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index c6514ef0d..fe0d07e26 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -282,7 +282,6 @@ class Horde_Registry 'Horde_Memcache' => 'Horde_Core_Binder_Memcache', 'Horde_Mime_Viewer' => 'Horde_Core_Binder_MimeViewer', 'Horde_Notification' => 'Horde_Core_Binder_Notification', - 'Horde_Perms' => 'Horde_Core_Binder_Perms', 'Horde_Prefs' => 'Horde_Core_Binder_Prefs', 'Horde_Prefs_Identity' => 'Horde_Core_Binder_Identity', // 'Horde_Registry' - initialized below @@ -338,6 +337,10 @@ class Horde_Registry 'Horde_Core_Factory_Lock', 'create', ), + 'Horde_Perms' => array( + 'Horde_Core_Factory_Perms', + 'create', + ), 'Horde_View' => array( 'Horde_Core_Factory_View', 'create', diff --git a/framework/Core/package.xml b/framework/Core/package.xml index a17348335..71ae8c7ff 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -24,7 +24,7 @@ Application Framework. yes 2010-10-02 - + 0.1.0 0.1.0 @@ -132,7 +132,6 @@ Application Framework. - @@ -170,6 +169,7 @@ Application Framework. + @@ -453,7 +453,6 @@ Application Framework. - @@ -487,6 +486,7 @@ Application Framework. + diff --git a/framework/Perms/lib/Horde/Perms.php b/framework/Perms/lib/Horde/Perms.php index 550860bf1..4ec0e721d 100644 --- a/framework/Perms/lib/Horde/Perms.php +++ b/framework/Perms/lib/Horde/Perms.php @@ -60,31 +60,6 @@ class Horde_Perms static protected $_itaCache = array(); /** - * Attempts to return a concrete instance based on $driver. - * - * @param string $driver The type of the concrete subclass to return. - * The class name is based on the perms driver - * ($driver). The code is dynamically included. - * @param array $params A hash containing any additional configuration - * or connection parameters a subclass might need. - * - * @return Horde_Perms The newly created concrete instance. - * @throws Horde_Perms_Exception - */ - static public function factory($driver = null, $params = null) - { - $class = is_null($driver) - ? __CLASS__ - : __CLASS__ . '_' . ucfirst(basename($driver)); - - if (class_exists($class)) { - return new $class($params); - } - - throw new Horde_Perms_Exception('Unknown driver: ' . $driver); - } - - /** * Constructor. * * @param array $params Configuration parameters: -- 2.11.0