Data\Db\DbConnection: implement fromResourceName

This allows to instantiate DB connections with less code in our
controllers.
This commit is contained in:
Thomas Gelf 2014-06-17 09:51:37 +00:00
parent d2ccc68214
commit 9e1e502fc8
1 changed files with 6 additions and 0 deletions

View File

@ -31,6 +31,7 @@ namespace Icinga\Data\Db;
use Icinga\Application\Benchmark;
use Icinga\Data\Db\DbQuery;
use Icinga\Data\ResourceFactory;
use Icinga\Data\Selectable;
use Icinga\Exception\ConfigurationError;
use PDO;
@ -173,6 +174,11 @@ class DbConnection implements Selectable
$this->dbAdapter->getProfiler()->setEnabled(false);
}
public static function fromResourceName($name)
{
return new static(ResourceFactory::getResourceConfig($name));
}
/**
* @deprecated Use Connection::getDbAdapter() instead
*/