From: Ben Klang Date: Sun, 3 Oct 2010 02:29:18 +0000 (-0400) Subject: Rebuild factory for Perms X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4c9851a3f408d9f7823cd4ee7eb1520ac3435010;p=horde.git Rebuild factory for Perms --- diff --git a/framework/Core/lib/Horde/Core/Binder/Perms.php b/framework/Core/lib/Horde/Core/Binder/Perms.php deleted file mode 100644 index 5a7d83120..000000000 --- a/framework/Core/lib/Horde/Core/Binder/Perms.php +++ /dev/null @@ -1,30 +0,0 @@ -getInstance('Horde_Db')->getDb('horde', 'perms'); - } - - $params['cache'] = $injector->getInstance('Horde_Cache'); - $params['logger'] = $injector->getInstance('Horde_Log_Logger'); - - return Horde_Perms::factory($driver, $params); - } - - public function equals(Horde_Injector_Binder $binder) - { - return false; - } - -} diff --git a/framework/Core/lib/Horde/Core/Factory/Perms.php b/framework/Core/lib/Horde/Core/Factory/Perms.php new file mode 100644 index 000000000..937948732 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Factory/Perms.php @@ -0,0 +1,48 @@ + + * + * @category Horde + * @package Core + */ +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']; + $params = isset($GLOBALS['conf']['perms']) + ? Horde::getDriverConfig('perms', $driver) + : array(); + + if (strcasecmp($driver, 'Sql') === 0) { + $params['db'] = $injector->getInstance('Horde_Db')->getDb('horde', 'perms'); + } + + $params['cache'] = $injector->getInstance('Horde_Cache'); + $params['logger'] = $injector->getInstance('Horde_Log_Logger'); + + $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) + { + return false; + } + +} 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: