diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-02-07 13:42:18 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-02-07 13:45:59 +0100 |
commit | b537d90e58913be203fd96f31b624559be00abeb (patch) | |
tree | 9af6c432b3b503303f1315f82f602844664f837d /lib/private/server.php | |
parent | b35b22977cfc9412278ae70b49c402a95efca19e (diff) | |
parent | b9e724d4ae7635435b3cc7793237c3ab9fe2a1c0 (diff) | |
download | nextcloud-server-b537d90e58913be203fd96f31b624559be00abeb.tar.gz nextcloud-server-b537d90e58913be203fd96f31b624559be00abeb.zip |
use the 'new' server container for appconfig
Diffstat (limited to 'lib/private/server.php')
-rw-r--r-- | lib/private/server.php | 118 |
1 files changed, 107 insertions, 11 deletions
diff --git a/lib/private/server.php b/lib/private/server.php index cabb15324ec..fc8f170dc4a 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -5,6 +5,7 @@ namespace OC; use OC\AppFramework\Http\Request; use OC\AppFramework\Utility\SimpleContainer; use OC\Cache\UserCache; +use OC\DB\ConnectionWrapper; use OC\Files\Node\Root; use OC\Files\View; use OCP\IServerContainer; @@ -22,12 +23,16 @@ class Server extends SimpleContainer implements IServerContainer { return new ContactsManager(); }); $this->registerService('Request', function($c) { - $params = array(); + if (isset($c['urlParams'])) { + $urlParams = $c['urlParams']; + } else { + $urlParams = array(); + } - // we json decode the body only in case of content type json - if (isset($_SERVER['CONTENT_TYPE']) && stripos($_SERVER['CONTENT_TYPE'],'json') !== false ) { - $params = json_decode(file_get_contents('php://input'), true); - $params = is_array($params) ? $params: array(); + if (\OC::$session->exists('requesttoken')) { + $requesttoken = \OC::$session->get('requesttoken'); + } else { + $requesttoken = false; } return new Request( @@ -41,8 +46,8 @@ class Server extends SimpleContainer implements IServerContainer { 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : null, - 'params' => $params, - 'urlParams' => $c['urlParams'] + 'urlParams' => $urlParams, + 'requesttoken' => $requesttoken, ) ); }); @@ -64,10 +69,18 @@ class Server extends SimpleContainer implements IServerContainer { return new Root($manager, $view, $user); }); $this->registerService('UserManager', function($c) { - return new \OC\User\Manager(); + /** + * @var SimpleContainer $c + * @var \OC\AllConfig $config + */ + $config = $c->query('AllConfig'); + return new \OC\User\Manager($config); }); $this->registerService('UserSession', function($c) { - /** @var $c SimpleContainer */ + /** + * @var SimpleContainer $c + * @var \OC\User\Manager $manager + */ $manager = $c->query('UserManager'); $userSession = new \OC\User\Session($manager, \OC::$session); $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { @@ -111,9 +124,33 @@ class Server extends SimpleContainer implements IServerContainer { $this->registerService('AllConfig', function($c) { return new \OC\AllConfig(); }); + $this->registerService('AppConfig', function ($c) { + return new \OC\AppConfig(\OC_DB::getConnection()); + }); + $this->registerService('L10NFactory', function($c) { + return new \OC\L10N\Factory(); + }); + $this->registerService('URLGenerator', function($c) { + /** @var $c SimpleContainer */ + $config = $c->query('AllConfig'); + return new \OC\URLGenerator($config); + }); + $this->registerService('AppHelper', function($c) { + return new \OC\AppHelper(); + }); $this->registerService('UserCache', function($c) { return new UserCache(); }); + $this->registerService('MemCacheFactory', function ($c) { + $instanceId = \OC_Util::getInstanceId(); + return new \OC\Memcache\Factory($instanceId); + }); + $this->registerService('ActivityManager', function($c) { + return new ActivityManager(); + }); + $this->registerService('AvatarManager', function($c) { + return new AvatarManager(); + }); } /** @@ -154,6 +191,15 @@ class Server extends SimpleContainer implements IServerContainer { } /** + * Returns the avatar manager, used for avatar functionality + * + * @return \OCP\IAvatarManager + */ + function getAvatarManager() { + return $this->query('AvatarManager'); + } + + /** * Returns the root folder of ownCloud's data directory * * @return \OCP\Files\Folder @@ -220,13 +266,45 @@ class Server extends SimpleContainer implements IServerContainer { } /** - * @return \OC\Config + * @return \OCP\IConfig */ function getConfig() { return $this->query('AllConfig'); } /** + * Returns the app config manager + * + * @return \OCP\IAppConfig + */ + function getAppConfig(){ + return $this->query('AppConfig'); + } + + /** + * get an L10N instance + * @param $app string appid + * @return \OC_L10N + */ + function getL10N($app) { + return $this->query('L10NFactory')->get($app); + } + + /** + * @return \OC\URLGenerator + */ + function getURLGenerator() { + return $this->query('URLGenerator'); + } + + /** + * @return \OC\Helper + */ + function getHelper() { + return $this->query('AppHelper'); + } + + /** * Returns an ICache instance * * @return \OCP\ICache @@ -236,6 +314,15 @@ class Server extends SimpleContainer implements IServerContainer { } /** + * Returns an \OCP\CacheFactory instance + * + * @return \OCP\CacheFactory + */ + function getMemCacheFactory() { + return $this->query('MemCacheFactory'); + } + + /** * Returns the current session * * @return \OCP\ISession @@ -250,6 +337,15 @@ class Server extends SimpleContainer implements IServerContainer { * @return \OCP\IDBConnection */ function getDatabaseConnection() { - return \OC_DB::getConnection(); + return new ConnectionWrapper(\OC_DB::getConnection()); + } + + /** + * Returns the activity manager + * + * @return \OCP\Activity\IManager + */ + function getActivityManager() { + return $this->query('ActivityManager'); } } |