Skip to content

Commit

Permalink
Throw exceptions only when datasource has wrong package, not check fo…
Browse files Browse the repository at this point in the history
…r instance of Datasource
  • Loading branch information
ceeram committed Mar 13, 2013
1 parent 3d4ebc0 commit dde0912
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/Cake/Model/ConnectionManager.php
Expand Up @@ -99,17 +99,16 @@ public static function getDataSource($name) {
$conn = self::$_connectionsEnum[$name];
$class = $conn['classname'];

$instance = new $class(self::$config->{$name});
$instance->configKeyName = $name;

if (!$instance instanceof Datasource) {
if (strpos(App::location($class), 'Datasource') === false) {
throw new MissingDatasourceException(array(
'class' => $class,
'plugin' => null,
'message' => 'Only classes extending Datasource can be used as datasources.'
'message' => 'Datasource is not found in Model/Datasource package.'
));
}
self::$_dataSources[$name] = $instance;
self::$_dataSources[$name] = new $class(self::$config->{$name});
self::$_dataSources[$name]->configKeyName = $name;

return self::$_dataSources[$name];
}

Expand Down

0 comments on commit dde0912

Please sign in to comment.