move db into iservercontainer
This commit is contained in:
parent
0fe4db0992
commit
4a7e0561ca
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace OC\AppFramework\Db;
|
||||
|
||||
use \OCP\AppFramework\Db\IDb;
|
||||
use \OCP\IDb;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
namespace OCP\AppFramework\Db;
|
||||
|
||||
use \OCP\IDb;
|
||||
|
||||
|
||||
/**
|
||||
* Simple parent class for inheriting your data access layer from. This class
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OCP\AppFramework\Db;
|
||||
namespace OCP;
|
||||
|
||||
|
||||
/**
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
namespace OCP\AppFramework\Db;
|
||||
|
||||
use \OCP\IDb;
|
||||
|
||||
|
||||
require_once __DIR__ . '/MapperTestUtility.php';
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue