move db into iservercontainer

This commit is contained in:
Bernhard Posselt 2014-04-19 19:30:12 +02:00
parent 0fe4db0992
commit 4a7e0561ca
8 changed files with 28 additions and 10 deletions

View File

@ -23,7 +23,7 @@
namespace OC\AppFramework\Db;
use \OCP\AppFramework\Db\IDb;
use \OCP\IDb;
/**

View File

@ -61,13 +61,6 @@ class DIContainer extends SimpleContainer implements IAppContainer{
return new API($c['AppName']);
});
/**
* Database
*/
$this['Db'] = $this->share(function($c){
return new Db();
});
/**
* Http
*/

View File

@ -3,6 +3,7 @@
namespace OC;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Db\Db;
use OC\AppFramework\Utility\SimpleContainer;
use OC\Cache\UserCache;
use OC\DB\ConnectionWrapper;
@ -177,6 +178,9 @@ class Server extends SimpleContainer implements IServerContainer {
}
return $router;
});
$this['Db'] = $this->share(function($c){
return new Db();
});
}
/**
@ -392,4 +396,13 @@ class Server extends SimpleContainer implements IServerContainer {
function getRouter(){
return $this->query('Router');
}
/**
* Returns an instance of the db facade
* @return \OCP\IDb
*/
function getDb() {
return $this->query('Db');
}
}

View File

@ -26,6 +26,8 @@
namespace OCP\AppFramework\Db;
use \OCP\IDb;
/**
* Simple parent class for inheriting your data access layer from. This class

View File

@ -21,7 +21,7 @@
*
*/
namespace OCP\AppFramework\Db;
namespace OCP;
/**

View File

@ -113,6 +113,14 @@ interface IServerContainer {
*/
function getConfig();
/**
* Returns an instance of the db facade
* @return \OCP\IDb
*/
function getDb();
/**
* Returns the app config manager
*

View File

@ -24,6 +24,8 @@
namespace OCP\AppFramework\Db;
use \OCP\IDb;
require_once __DIR__ . '/MapperTestUtility.php';

View File

@ -46,7 +46,7 @@ abstract class MapperTestUtility extends \PHPUnit_Framework_TestCase {
*/
protected function setUp(){
$this->db = $this->getMockBuilder(
'\OCP\AppFramework\Db\IDb')
'\OCP\IDb')
->disableOriginalConstructor()
->getMock();