From 1c6e0c3102271013359781c79ffb4108b85e21d5 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 4 Oct 2010 04:16:16 +0000 Subject: [PATCH] MINOR Changed the way DatabaseAdapterRegistry accepts databases (from r100898) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@111536 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/install/DatabaseAdapterRegistry.php | 43 ++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/dev/install/DatabaseAdapterRegistry.php b/dev/install/DatabaseAdapterRegistry.php index 7e31e119e..c9524a03e 100644 --- a/dev/install/DatabaseAdapterRegistry.php +++ b/dev/install/DatabaseAdapterRegistry.php @@ -9,6 +9,7 @@ * @author Tom Rix */ class DatabaseAdapterRegistry { + /** * Internal array of registered database adapters */ @@ -16,34 +17,32 @@ class DatabaseAdapterRegistry { /** * Add new adapter to the registry - * - * @param string $class classname of the adapter - * @param string $title friendly name for the adapter - * @param string $helperPath path to the DatabaseConfigurationHelper for the adapter - * @param boolean $supported whether or not php has the required functions + * @param array $config Associative array of configuration details */ - static function register($class, $title, $helperPath, $supported, $missingModuleText = null, $missingExtensionText = null) { - self::$adapters[$class] = array( - 'title' => $title, - 'helperPath' => $helperPath, - 'supported' => $supported - ); - if (!$missingExtensionText) $missingExtensionText = 'The PHP extension is missing, please enable or install it.'; - if (!$missingModuleText) { - $moduleName = array_shift(explode('/', $helperPath)); - $missingModuleText = 'The SilverStripe module, '.$moduleName.', is missing or incomplete. Please download it.'; - } - self::$adapters[$class]['missingModuleText'] = $missingModuleText; - self::$adapters[$class]['missingExtensionText'] = $missingExtensionText; + static function register($config) { + $missingExtensionText = isset($config['missingExtensionText']) + ? $config['missingExtensionText'] + : 'The PHP extension is missing, please enable or install it.'; + + $moduleName = array_shift(explode('/', $config['helperPath'])); + $missingModuleText = isset($config['missingModuleText']) + ? $config['missingModuleText'] + : 'The SilverStripe module, '.$moduleName.', is missing or incomplete. Please download it.'; + + $config['missingModuleText'] = $missingModuleText; + $config['missingExtensionText'] = $missingExtensionText; + + self::$adapters[$config['class']] = $config; } static function autodiscover() { - foreach(glob(dirname(__FILE__).'/../../../*', GLOB_ONLYDIR) as $directory) { - if (file_exists($directory.'/_register_database.php')) include_once($directory.'/_register_database.php'); + foreach(glob(dirname(__FILE__) . '/../../../*', GLOB_ONLYDIR) as $directory) { + if(file_exists($directory . '/_register_database.php')) include_once($directory . '/_register_database.php'); } } - static function adapters() { + static function get_adapters() { return self::$adapters; } -} + +} \ No newline at end of file