1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-09 15:47:23 +02:00

DibiProfiler is configurable via DibiConnection $config

This commit is contained in:
David Grudl
2010-05-19 20:32:36 +02:00
parent 88b1a45e42
commit 651c0f8c4a
4 changed files with 38 additions and 12 deletions

View File

@@ -89,15 +89,20 @@ class DibiConnection extends DibiObject
$this->config = $config;
$this->driver = new $class;
if (!empty($config['profiler'])) {
$class = $config['profiler'];
if (is_numeric($class) || is_bool($class)) {
$class = 'DibiProfiler';
}
// profiler
$profilerCfg = & $config['profiler'];
if (is_numeric($profilerCfg) || is_bool($profilerCfg)) { // back compatibility
$profilerCfg = array('run' => (bool) $profilerCfg);
} elseif (is_string($profilerCfg)) {
$profilerCfg = array('run' => TRUE, 'class' => $profilerCfg);
}
if (!empty($profilerCfg['run'])) {
$class = isset($profilerCfg['class']) ? $profilerCfg['class'] : 'DibiProfiler';
if (!class_exists($class)) {
throw new DibiException("Unable to create instance of dibi profiler '$class'.");
}
$this->setProfiler(new $class);
$this->setProfiler(new $class($profilerCfg));
}
if (!empty($config['substitutes'])) {