Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • DatabaseAdapterRegistry
 1 <?php
 2 
 3 /**
 4  * This class keeps track of the available database adapters
 5  * and provides a meaning of registering community built
 6  * adapters in to the installer process.
 7  *
 8  * @package installer
 9  * @author Tom Rix
10  */
11 class DatabaseAdapterRegistry {
12     
13     static $default_fields = array(
14         'server' => array(
15             'title' => 'Database server', 
16             'envVar' => 'SS_DATABASE_SERVER', 
17             'default' => 'localhost'
18         ),
19         'username' => array(
20             'title' => 'Database username', 
21             'envVar' => 'SS_DATABASE_USERNAME', 
22             'default' => 'root'
23         ),
24         'password' => array(
25             'title' => 'Database password', 
26             'envVar' => 'SS_DATABASE_PASSWORD', 
27             'default' => 'password'
28         ),
29         'database' => array(
30             'title' => 'Database name', 
31             'default' => 'SS_mysite',
32             'attributes' => array(
33                 "onchange" => "this.value = this.value.replace(/[\/\\:*?&quot;<>|. \t]+/g,'');"
34             )
35         ),
36     );
37     
38     /**
39      * Internal array of registered database adapters
40      */
41     private static $adapters = array();
42     
43     /**
44      * Add new adapter to the registry
45      * @param array $config Associative array of configuration details
46      */
47     static function register($config) {
48         $missingExtensionText = isset($config['missingExtensionText'])
49             ? $config['missingExtensionText']
50             : 'The PHP extension is missing, please enable or install it.';
51 
52         $moduleName = array_shift(explode('/', $config['helperPath']));
53         $missingModuleText = isset($config['missingModuleText'])
54             ? $config['missingModuleText']
55             : 'The SilverStripe module, '.$moduleName.', is missing or incomplete. Please <a href="http://silverstripe.org/modules">download it</a>.';
56         
57         $config['missingModuleText'] = $missingModuleText;
58         $config['missingExtensionText'] = $missingExtensionText;
59         
60         // set default fields if none are defined already
61         if(!isset($config['fields'])) $config['fields'] = self::$default_fields;
62         
63         self::$adapters[$config['class']] = $config;
64     }
65     
66     static function unregister($class) {
67         if(isset($adapters[$class])) unset($adapters[$class]);
68     }
69     
70     static function autodiscover() {
71         foreach(glob(dirname(__FILE__) . '/../../../*', GLOB_ONLYDIR) as $directory) {
72             if(file_exists($directory . '/_register_database.php')) include_once($directory . '/_register_database.php');
73         }
74     }
75     
76     static function get_adapters() {
77         return self::$adapters;
78     }
79 
80 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0