Data\Db\DbConnection: implement fromResourceName
This allows to instantiate DB connections with less code in our controllers.
This commit is contained in:
parent
d2ccc68214
commit
9e1e502fc8
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue