tweaking and refactoring the database connectors. added connectors to the container.

This commit is contained in:
Taylor Otwell
2011-10-15 23:20:13 -05:00
parent 07f3f5d03c
commit 893acd8743
2 changed files with 31 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
<?php namespace Laravel\Database;
use Laravel\IoC;
use Laravel\Config;
class Manager {
@@ -56,27 +57,12 @@ class Manager {
*/
protected static function connect($config)
{
if (isset($config['connector'])) { return call_user_func($config['connector'], $config); }
switch ($config['driver'])
if (isset($config['connector']))
{
case 'sqlite':
$connector = new Connectors\SQLite;
break;
case 'mysql':
$connector = new Connectors\MySQL;
break;
case 'pgsql':
$connector = new Connectors\Postgres;
break;
default:
throw new \Exception("Database driver [{$config['driver']}] is not supported.");
return call_user_func($config['connector'], $config);
}
return $connector->connect($config);
return IoC::container()->core("database.connectors.{$config['driver']}")->connect($config);
}
/**