Skip to content

Commit

Permalink
Update ConnectionManager to use new Connection class.
Browse files Browse the repository at this point in the history
Update ConnectionManager temporarily to work with the incomplete
database layer. Fixtures are not functional at this time, but at least
getDataSource() works.
  • Loading branch information
markstory committed Apr 7, 2013
1 parent baffc96 commit c9f1780
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions lib/Cake/Model/ConnectionManager.php
Expand Up @@ -23,6 +23,7 @@

use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Database\Connection;
use Cake\Error;

/**
Expand Down Expand Up @@ -88,8 +89,7 @@ public static function getDataSource($name) {
}

if (!empty(static::$_dataSources[$name])) {
$return = static::$_dataSources[$name];
return $return;
return static::$_dataSources[$name];
}

if (empty(static::$_connectionsEnum[$name])) {
Expand All @@ -98,15 +98,24 @@ public static function getDataSource($name) {

$class = static::loadDataSource($name);

if (strpos($class, '\Datasource') === false) {
if (
strpos($class, '\Datasource') === false &&
strpos($class, '\Database') === false
) {
throw new Error\MissingDatasourceException(array(
'class' => $class,
'plugin' => null,
'message' => 'Datasource is not found in Model/Datasource package.'
));
}
static::$_dataSources[$name] = new $class(static::$config[$name]);
static::$_dataSources[$name]->configKeyName = $name;
// TODO fix this once the datasource interface &
// internals are solved.
if (strpos($class, '\Database') !== false) {
static::$_dataSources[$name] = new Connection(static::$config[$name]);
} else {
static::$_dataSources[$name] = new $class(static::$config[$name]);
static::$_dataSources[$name]->configKeyName = $name;
}

return static::$_dataSources[$name];
}
Expand Down Expand Up @@ -164,7 +173,7 @@ public static function loadDataSource($connName) {
$conn = static::$_connectionsEnum[$connName];
}

if (class_exists($conn['classname'], false)) {
if (class_exists($conn['classname'])) {
return $conn['classname'];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/TestSuite/Fixture/FixtureManager.php
Expand Up @@ -162,7 +162,7 @@ protected function _setupTable($fixture, $db = null, $drop = true) {
return;
}

$sources = (array)$db->listSources();
$sources = (array)$db->listTables();
$table = $db->config['prefix'] . $fixture->table;
$exists = in_array($table, $sources);

Expand Down

0 comments on commit c9f1780

Please sign in to comment.