-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENHANCEMENT show all database systems we support, along with messages…
… if the user cannot use them. Also allow 3rd parties to register their own database classes to appear in this list. (from r100696) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105626 467b73ca-7a2a-4603-9d3b-597d59a354a9
- Loading branch information
Showing
3 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,49 @@ | |||
<?php | |||
|
|||
/** | |||
* This class keeps track of the available database adapters | |||
* and provides a meaning of registering community built | |||
* adapters in to the installer process. | |||
* | |||
* @package installer | |||
* @author Tom Rix | |||
*/ | |||
class DatabaseAdapterRegistry { | |||
/** | |||
* Internal array of registered database adapters | |||
*/ | |||
private static $adapters = array(); | |||
|
|||
/** | |||
* 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 | |||
*/ | |||
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 <a href="http://silverstripe.org/modules">download it</a>.'; | |||
} | |||
self::$adapters[$class]['missingModuleText'] = $missingModuleText; | |||
self::$adapters[$class]['missingExtensionText'] = $missingExtensionText; | |||
} | |||
|
|||
static function autodiscover() { | |||
foreach(glob(dirname(__FILE__).'/../../../*', GLOB_ONLYDIR) as $directory) { | |||
if (file_exists($directory.'/_register_database.php')) include_once($directory.'/_register_database.php'); | |||
} | |||
} | |||
|
|||
static function adapters() { | |||
return self::$adapters; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters