diff --git a/src/Illuminate/Database/Connection.php b/src/Illuminate/Database/Connection.php index a6537e5c4a13..f76a20778922 100755 --- a/src/Illuminate/Database/Connection.php +++ b/src/Illuminate/Database/Connection.php @@ -136,6 +136,13 @@ class Connection implements ConnectionInterface */ protected $doctrineConnection; + /** + * The connection resolvers. + * + * @var array + */ + protected static $resolvers = []; + /** * Create a new database connection instance. * @@ -937,6 +944,30 @@ public function setReconnector(callable $reconnector) return $this; } + /** + * Register a connection resolver. + * + * @param string $driver + * @param \Closure $callback + * @return void + */ + public static function resolveConnection($driver, Closure $callback) + { + static::$resolvers[$driver] = $callback; + } + + /** + * Get the connection resolver for the given driver. + * + * @param string $driver + * @return mixed + */ + public static function getResolver($driver) + { + return isset(static::$resolvers[$driver]) ? + static::$resolvers[$driver] : null; + } + /** * Get the database connection name. * diff --git a/src/Illuminate/Database/Connectors/ConnectionFactory.php b/src/Illuminate/Database/Connectors/ConnectionFactory.php index 1274f0b9f3e3..f224dbe48ba8 100755 --- a/src/Illuminate/Database/Connectors/ConnectionFactory.php +++ b/src/Illuminate/Database/Connectors/ConnectionFactory.php @@ -5,6 +5,7 @@ use PDOException; use Illuminate\Support\Arr; use InvalidArgumentException; +use Illuminate\Database\Connection; use Illuminate\Database\MySqlConnection; use Illuminate\Database\SQLiteConnection; use Illuminate\Database\PostgresConnection; @@ -267,8 +268,8 @@ public function createConnector(array $config) */ protected function createConnection($driver, $connection, $database, $prefix = '', array $config = []) { - if ($this->container->bound($key = "db.connection.{$driver}")) { - return $this->container->make($key, [$connection, $database, $prefix, $config]); + if ($resolver = Connection::getResolver($driver)) { + return $resolver($connection, $database, $prefix, $config); } switch ($driver) {