mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Throw exceptions only when datasource has wrong package, not check for instance of Datasource
This commit is contained in:
parent
3d4ebc038c
commit
dde0912d1e
1 changed files with 5 additions and 6 deletions
|
@ -99,17 +99,16 @@ class ConnectionManager {
|
||||||
$conn = self::$_connectionsEnum[$name];
|
$conn = self::$_connectionsEnum[$name];
|
||||||
$class = $conn['classname'];
|
$class = $conn['classname'];
|
||||||
|
|
||||||
$instance = new $class(self::$config->{$name});
|
if (strpos(App::location($class), 'Datasource') === false) {
|
||||||
$instance->configKeyName = $name;
|
|
||||||
|
|
||||||
if (!$instance instanceof Datasource) {
|
|
||||||
throw new MissingDatasourceException(array(
|
throw new MissingDatasourceException(array(
|
||||||
'class' => $class,
|
'class' => $class,
|
||||||
'plugin' => null,
|
'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];
|
return self::$_dataSources[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue