From bbcc3d99be030fff78a96de30676a35502c287d6 Mon Sep 17 00:00:00 2001 From: Sergio Dinis Lopes Date: Mon, 16 Feb 2015 18:43:09 +0000 Subject: [PATCH] Optionally pass the database configuration parameters on Rbac constructor --- PhpRbac/src/PhpRbac/Rbac.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/PhpRbac/src/PhpRbac/Rbac.php b/PhpRbac/src/PhpRbac/Rbac.php index 0002cf2..e0855f4 100644 --- a/PhpRbac/src/PhpRbac/Rbac.php +++ b/PhpRbac/src/PhpRbac/Rbac.php @@ -13,10 +13,23 @@ */ class Rbac { - public function __construct($unit_test = '') + public function __construct($unit_test = '', array $databaseConfig = array()) { if ((string) $unit_test === 'unit_test') { require_once dirname(dirname(__DIR__)) . '/tests/database/database.config'; + } elseif (!empty($databaseConfig)) { + $databaseConfig = $databaseConfig + array( + 'host' => 'localhost', + 'user' => 'root', + 'pass' => '', + 'dbname' => dirname(dirname(__DIR__)) . "/phprbac.sqlite3", + 'adapter' => 'pdo_sqlite', // 'pdo_sqlite', 'pdo_mysql', 'mysqli' + 'tablePrefix' => 'phprbac_' + ); + + extract($databaseConfig); + unset($databaseConfig); + } else { require_once dirname(dirname(__DIR__)) . '/database/database.config'; }