Commit 893acd87 authored by Taylor Otwell's avatar Taylor Otwell

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

parent 07f3f5d0
...@@ -39,6 +39,33 @@ return array( ...@@ -39,6 +39,33 @@ return array(
return new Routing\Caller($c, require APP_PATH.'filters'.EXT, CONTROLLER_PATH); return new Routing\Caller($c, require APP_PATH.'filters'.EXT, CONTROLLER_PATH);
}), }),
/*
|--------------------------------------------------------------------------
| Laravel Database Connectors
|--------------------------------------------------------------------------
|
| The following components are used to establish PDO database connections
| to the various database systems supported by Laravel. By resolving these
| connectors out of the IoC container, new database systems may be added
| by simply registering a connector.
|
*/
'laravel.database.connectors.sqlite' => function($c)
{
return new Database\Connectors\SQLite;
},
'laravel.database.connectors.mysql' => function($c)
{
return new Database\Connectors\MySQL;
},
'laravel.database.connectors.pgsql' => function($c)
{
return new Database\Connectors\Postgres;
},
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Laravel Caching Components | Laravel Caching Components
......
<?php namespace Laravel\Database; <?php namespace Laravel\Database;
use Laravel\IoC;
use Laravel\Config; use Laravel\Config;
class Manager { class Manager {
...@@ -56,27 +57,12 @@ class Manager { ...@@ -56,27 +57,12 @@ class Manager {
*/ */
protected static function connect($config) protected static function connect($config)
{ {
if (isset($config['connector'])) { return call_user_func($config['connector'], $config); } if (isset($config['connector']))
switch ($config['driver'])
{ {
case 'sqlite': return call_user_func($config['connector'], $config);
$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 $connector->connect($config); return IoC::container()->core("database.connectors.{$config['driver']}")->connect($config);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment