diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index a756c75bb..e117fb2c1 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -99,17 +99,16 @@ class ConnectionManager { $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]; }