moving some laravel classes around, switching alias to reflect changes. added some factories. removed system ioc container config file.
This commit is contained in:
29
laravel/database/connectors/factory.php
Normal file
29
laravel/database/connectors/factory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php namespace Laravel\Database\Connectors;
|
||||
|
||||
class Factory {
|
||||
|
||||
/**
|
||||
* Create a new database connector instance.
|
||||
*
|
||||
* @param string $driver
|
||||
* @return Connector
|
||||
*/
|
||||
public static function make($driver)
|
||||
{
|
||||
switch ($driver)
|
||||
{
|
||||
case 'sqlite':
|
||||
return new SQLite(DATABASE_PATH);
|
||||
|
||||
case 'mysql':
|
||||
return new MySQL;
|
||||
|
||||
case 'pgsql':
|
||||
return new Postgres;
|
||||
|
||||
default:
|
||||
throw new \Exception("Database driver [$driver] is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class Manager {
|
||||
{
|
||||
if (is_null($connection)) $connection = Config::get('database.default');
|
||||
|
||||
if ( ! array_key_exists($connection, static::$connections))
|
||||
if ( ! isset(static::$connections[$connection]))
|
||||
{
|
||||
$config = Config::get("database.connections.{$connection}");
|
||||
|
||||
@@ -65,7 +65,7 @@ class Manager {
|
||||
return call_user_func($config['connector'], $config);
|
||||
}
|
||||
|
||||
return IoC::core("database.connectors.{$config['driver']}")->connect($config);
|
||||
return Connectors\Factory::make($config['driver'])->connect($config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user