Пример #1
0
 /**
  * connects to the database
  * @return boolean|null true if connection can be established or false on error
  *
  * Connects to the database as specified in config.php
  */
 public static function connect()
 {
     if (self::$connection) {
         return true;
     }
     $type = OC_Config::getValue('dbtype', 'sqlite');
     $factory = new \OC\DB\ConnectionFactory();
     if (!$factory->isValidType($type)) {
         return false;
     }
     $connectionParams = array('user' => OC_Config::getValue('dbuser', ''), 'password' => OC_Config::getValue('dbpassword', ''));
     $name = OC_Config::getValue('dbname', 'owncloud');
     if ($factory->normalizeType($type) === 'sqlite3') {
         $datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data');
         $connectionParams['path'] = $datadir . '/' . $name . '.db';
     } else {
         $host = OC_Config::getValue('dbhost', '');
         if (strpos($host, ':')) {
             // Host variable may carry a port or socket.
             list($host, $portOrSocket) = explode(':', $host, 2);
             if (ctype_digit($portOrSocket)) {
                 $connectionParams['port'] = $portOrSocket;
             } else {
                 $connectionParams['unix_socket'] = $portOrSocket;
             }
         }
         $connectionParams['host'] = $host;
         $connectionParams['dbname'] = $name;
     }
     $connectionParams['tablePrefix'] = OC_Config::getValue('dbtableprefix', 'oc_');
     //additional driver options, eg. for mysql ssl
     $driverOptions = OC_Config::getValue('dbdriveroptions', null);
     if ($driverOptions) {
         $connectionParams['driverOptions'] = $driverOptions;
     }
     try {
         self::$connection = $factory->getConnection($type, $connectionParams);
     } catch (\Doctrine\DBAL\DBALException $e) {
         OC_Log::write('core', $e->getMessage(), OC_Log::FATAL);
         OC_User::setUserId(null);
         // send http status 503
         header('HTTP/1.1 503 Service Temporarily Unavailable');
         header('Status: 503 Service Temporarily Unavailable');
         OC_Template::printErrorPage('Failed to connect to database');
         die;
     }
     return true;
 }
Пример #2
0
 /**
  * @param string $webRoot
  */
 public function __construct($webRoot)
 {
     parent::__construct();
     $this->webRoot = $webRoot;
     $this->registerService('ContactsManager', function ($c) {
         return new ContactsManager();
     });
     $this->registerService('PreviewManager', function (Server $c) {
         return new PreviewManager($c->getConfig());
     });
     $this->registerService('EncryptionManager', function (Server $c) {
         $view = new View();
         $util = new Encryption\Util($view, $c->getUserManager(), $c->getGroupManager(), $c->getConfig());
         return new Encryption\Manager($c->getConfig(), $c->getLogger(), $c->getL10N('core'), new View(), $util);
     });
     $this->registerService('EncryptionFileHelper', function (Server $c) {
         $util = new Encryption\Util(new View(), $c->getUserManager(), $c->getGroupManager(), $c->getConfig());
         return new Encryption\File($util);
     });
     $this->registerService('EncryptionKeyStorage', function (Server $c) {
         $view = new View();
         $util = new Encryption\Util($view, $c->getUserManager(), $c->getGroupManager(), $c->getConfig());
         return new Encryption\Keys\Storage($view, $util);
     });
     $this->registerService('TagMapper', function (Server $c) {
         return new TagMapper($c->getDatabaseConnection());
     });
     $this->registerService('TagManager', function (Server $c) {
         $tagMapper = $c->query('TagMapper');
         return new TagManager($tagMapper, $c->getUserSession());
     });
     $this->registerService('SystemTagManager', function (Server $c) {
         return new SystemTag\SystemTagManager($c->getDatabaseConnection());
     });
     $this->registerService('SystemTagObjectMapper', function (Server $c) {
         return new SystemTag\SystemTagObjectMapper($c->getDatabaseConnection(), $c->getSystemTagManager());
     });
     $this->registerService('RootFolder', function (Server $c) {
         // TODO: get user and user manager from container as well
         $user = \OC_User::getUser();
         /** @var $c SimpleContainer */
         $userManager = $c->query('UserManager');
         $user = $userManager->get($user);
         $manager = \OC\Files\Filesystem::getMountManager();
         $view = new View();
         $root = new Root($manager, $view, $user);
         $connector = new HookConnector($root, $view);
         $connector->viewToNode();
         return $root;
     });
     $this->registerService('UserManager', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\User\Manager($config);
     });
     $this->registerService('GroupManager', function (Server $c) {
         $groupManager = new \OC\Group\Manager($this->getUserManager());
         $groupManager->listen('\\OC\\Group', 'preCreate', function ($gid) {
             \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
         });
         $groupManager->listen('\\OC\\Group', 'postCreate', function (\OC\Group\Group $gid) {
             \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
             //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
             \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         return $groupManager;
     });
     $this->registerService('UserSession', function (Server $c) {
         $manager = $c->getUserManager();
         $session = new \OC\Session\Memory('');
         $userSession = new \OC\User\Session($manager, $session);
         $userSession->listen('\\OC\\User', 'preCreateUser', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postCreateUser', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'preDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'postDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'preLogin', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postLogin', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'logout', function () {
             \OC_Hook::emit('OC_User', 'logout', array());
         });
         return $userSession;
     });
     $this->registerService('NavigationManager', function ($c) {
         return new \OC\NavigationManager();
     });
     $this->registerService('AllConfig', function (Server $c) {
         return new \OC\AllConfig($c->getSystemConfig());
     });
     $this->registerService('SystemConfig', function ($c) {
         return new \OC\SystemConfig();
     });
     $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 (Server $c) {
         $config = $c->getConfig();
         $cacheFactory = $c->getMemCacheFactory();
         return new \OC\URLGenerator($config, $cacheFactory);
     });
     $this->registerService('AppHelper', function ($c) {
         return new \OC\AppHelper();
     });
     $this->registerService('UserCache', function ($c) {
         return new Cache\File();
     });
     $this->registerService('MemCacheFactory', function (Server $c) {
         $config = $c->getConfig();
         if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
             $v = \OC_App::getAppVersions();
             $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
             $version = implode(',', $v);
             $instanceId = \OC_Util::getInstanceId();
             $path = \OC::$SERVERROOT;
             $prefix = md5($instanceId . '-' . $version . '-' . $path);
             return new \OC\Memcache\Factory($prefix, $c->getLogger(), $config->getSystemValue('memcache.local', null), $config->getSystemValue('memcache.distributed', null), $config->getSystemValue('memcache.locking', null));
         }
         return new \OC\Memcache\Factory('', $c->getLogger(), '\\OC\\Memcache\\ArrayCache', '\\OC\\Memcache\\ArrayCache', '\\OC\\Memcache\\ArrayCache');
     });
     $this->registerService('ActivityManager', function (Server $c) {
         return new ActivityManager($c->getRequest(), $c->getUserSession(), $c->getConfig());
     });
     $this->registerService('AvatarManager', function (Server $c) {
         return new AvatarManager($c->getUserManager(), $c->getRootFolder(), $c->getL10N('lib'));
     });
     $this->registerService('Logger', function (Server $c) {
         $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud');
         $logger = 'OC_Log_' . ucfirst($logClass);
         call_user_func(array($logger, 'init'));
         return new Log($logger);
     });
     $this->registerService('JobList', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
     });
     $this->registerService('Router', function (Server $c) {
         $cacheFactory = $c->getMemCacheFactory();
         $logger = $c->getLogger();
         if ($cacheFactory->isAvailable()) {
             $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
         } else {
             $router = new \OC\Route\Router($logger);
         }
         return $router;
     });
     $this->registerService('Search', function ($c) {
         return new Search();
     });
     $this->registerService('SecureRandom', function ($c) {
         return new SecureRandom();
     });
     $this->registerService('Crypto', function (Server $c) {
         return new Crypto($c->getConfig(), $c->getSecureRandom());
     });
     $this->registerService('Hasher', function (Server $c) {
         return new Hasher($c->getConfig());
     });
     $this->registerService('DatabaseConnection', function (Server $c) {
         $factory = new \OC\DB\ConnectionFactory();
         $systemConfig = $c->getSystemConfig();
         $type = $systemConfig->getValue('dbtype', 'sqlite');
         if (!$factory->isValidType($type)) {
             throw new \OC\DatabaseException('Invalid database type');
         }
         $connectionParams = $factory->createConnectionParams($systemConfig);
         $connection = $factory->getConnection($type, $connectionParams);
         $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
         return $connection;
     });
     $this->registerService('Db', function (Server $c) {
         return new Db($c->getDatabaseConnection());
     });
     $this->registerService('HTTPHelper', function (Server $c) {
         $config = $c->getConfig();
         return new HTTPHelper($config, $c->getHTTPClientService());
     });
     $this->registerService('HttpClientService', function (Server $c) {
         $user = \OC_User::getUser();
         $uid = $user ? $user : null;
         return new ClientService($c->getConfig(), new \OC\Security\CertificateManager($uid, new View(), $c->getConfig()));
     });
     $this->registerService('EventLogger', function (Server $c) {
         if ($c->getSystemConfig()->getValue('debug', false)) {
             return new EventLogger();
         } else {
             return new NullEventLogger();
         }
     });
     $this->registerService('QueryLogger', function (Server $c) {
         if ($c->getSystemConfig()->getValue('debug', false)) {
             return new QueryLogger();
         } else {
             return new NullQueryLogger();
         }
     });
     $this->registerService('TempManager', function (Server $c) {
         return new TempManager($c->getLogger(), $c->getConfig());
     });
     $this->registerService('AppManager', function (Server $c) {
         return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager(), $c->getMemCacheFactory());
     });
     $this->registerService('DateTimeZone', function (Server $c) {
         return new DateTimeZone($c->getConfig(), $c->getSession());
     });
     $this->registerService('DateTimeFormatter', function (Server $c) {
         $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
         return new DateTimeFormatter($c->getDateTimeZone()->getTimeZone(), $c->getL10N('lib', $language));
     });
     $this->registerService('MountConfigManager', function () {
         $loader = \OC\Files\Filesystem::getLoader();
         return new \OC\Files\Config\MountProviderCollection($loader);
     });
     $this->registerService('IniWrapper', function ($c) {
         return new IniGetWrapper();
     });
     $this->registerService('AsyncCommandBus', function (Server $c) {
         $jobList = $c->getJobList();
         return new AsyncBus($jobList);
     });
     $this->registerService('TrustedDomainHelper', function ($c) {
         return new TrustedDomainHelper($this->getConfig());
     });
     $this->registerService('IntegrityCodeChecker', function (Server $c) {
         // IConfig and IAppManager requires a working database. This code
         // might however be called when ownCloud is not yet setup.
         if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
             $config = $c->getConfig();
             $appManager = $c->getAppManager();
         } else {
             $config = null;
             $appManager = null;
         }
         return new Checker(new EnvironmentHelper(), new FileAccessHelper(), new AppLocator(), $config, $c->getMemCacheFactory(), $appManager);
     });
     $this->registerService('Request', function ($c) {
         if (isset($this['urlParams'])) {
             $urlParams = $this['urlParams'];
         } else {
             $urlParams = [];
         }
         if ($this->getSession()->exists('requesttoken')) {
             $requestToken = $this->getSession()->get('requesttoken');
         } else {
             $requestToken = false;
         }
         if (defined('PHPUNIT_RUN') && PHPUNIT_RUN && in_array('fakeinput', stream_get_wrappers())) {
             $stream = 'fakeinput://data';
         } else {
             $stream = 'php://input';
         }
         return new Request(['get' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'server' => $_SERVER, 'env' => $_ENV, 'cookies' => $_COOKIE, 'method' => isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null, 'urlParams' => $urlParams, 'requesttoken' => $requestToken], $this->getSecureRandom(), $this->getConfig(), $stream);
     });
     $this->registerService('Mailer', function (Server $c) {
         return new Mailer($c->getConfig(), $c->getLogger(), new \OC_Defaults());
     });
     $this->registerService('OcsClient', function (Server $c) {
         return new OCSClient($this->getHTTPClientService(), $this->getConfig(), $this->getLogger());
     });
     $this->registerService('LockingProvider', function (Server $c) {
         if ($c->getConfig()->getSystemValue('filelocking.enabled', true) or defined('PHPUNIT_RUN') && PHPUNIT_RUN) {
             /** @var \OC\Memcache\Factory $memcacheFactory */
             $memcacheFactory = $c->getMemCacheFactory();
             $memcache = $memcacheFactory->createLocking('lock');
             if (!$memcache instanceof \OC\Memcache\NullCache) {
                 return new MemcacheLockingProvider($memcache);
             }
             return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory());
         }
         return new NoopLockingProvider();
     });
     $this->registerService('MountManager', function () {
         return new \OC\Files\Mount\Manager();
     });
     $this->registerService('MimeTypeDetector', function (Server $c) {
         return new \OC\Files\Type\Detection($c->getURLGenerator(), \OC::$SERVERROOT . '/config/', \OC::$SERVERROOT . '/resources/config/');
     });
     $this->registerService('MimeTypeLoader', function (Server $c) {
         return new \OC\Files\Type\Loader($c->getDatabaseConnection());
     });
     $this->registerService('NotificationManager', function () {
         return new Manager();
     });
     $this->registerService('CapabilitiesManager', function (Server $c) {
         $manager = new \OC\CapabilitiesManager();
         $manager->registerCapability(function () use($c) {
             return new \OC\OCS\CoreCapabilities($c->getConfig());
         });
         return $manager;
     });
     $this->registerService('CommentsManager', function (Server $c) {
         $config = $c->getConfig();
         $factoryClass = $config->getSystemValue('comments.managerFactory', '\\OC\\Comments\\ManagerFactory');
         /** @var \OCP\Comments\ICommentsManagerFactory $factory */
         $factory = new $factoryClass();
         return $factory->getManager();
     });
     $this->registerService('EventDispatcher', function () {
         return new EventDispatcher();
     });
     $this->registerService('CryptoWrapper', function (Server $c) {
         // FIXME: Instantiiated here due to cyclic dependency
         $request = new Request(['get' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'server' => $_SERVER, 'env' => $_ENV, 'cookies' => $_COOKIE, 'method' => isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null], new SecureRandom(), $c->getConfig());
         return new CryptoWrapper($c->getConfig(), $c->getCrypto(), $c->getSecureRandom(), $request);
     });
 }
Пример #3
0
 /**
  * @param string $webRoot
  */
 public function __construct($webRoot)
 {
     $this->webRoot = $webRoot;
     $this->registerService('ContactsManager', function ($c) {
         return new ContactsManager();
     });
     $this->registerService('PreviewManager', function (Server $c) {
         return new PreviewManager($c->getConfig());
     });
     $this->registerService('EncryptionManager', function (Server $c) {
         return new Encryption\Manager($c->getConfig(), $c->getLogger(), $c->getL10N('core'));
     });
     $this->registerService('EncryptionFileHelper', function (Server $c) {
         $util = new \OC\Encryption\Util(new \OC\Files\View(), $c->getUserManager(), $c->getGroupManager(), $c->getConfig());
         return new Encryption\File($util);
     });
     $this->registerService('EncryptionKeyStorage', function (Server $c) {
         $view = new \OC\Files\View();
         $util = new \OC\Encryption\Util($view, $c->getUserManager(), $c->getGroupManager(), $c->getConfig());
         return new Encryption\Keys\Storage($view, $util);
     });
     $this->registerService('TagMapper', function (Server $c) {
         return new TagMapper($c->getDatabaseConnection());
     });
     $this->registerService('TagManager', function (Server $c) {
         $tagMapper = $c->query('TagMapper');
         return new TagManager($tagMapper, $c->getUserSession());
     });
     $this->registerService('RootFolder', function (Server $c) {
         // TODO: get user and user manager from container as well
         $user = \OC_User::getUser();
         /** @var $c SimpleContainer */
         $userManager = $c->query('UserManager');
         $user = $userManager->get($user);
         $manager = \OC\Files\Filesystem::getMountManager();
         $view = new View();
         return new Root($manager, $view, $user);
     });
     $this->registerService('UserManager', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\User\Manager($config);
     });
     $this->registerService('GroupManager', function (Server $c) {
         $groupManager = new \OC\Group\Manager($this->getUserManager());
         $groupManager->listen('\\OC\\Group', 'preCreate', function ($gid) {
             \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
         });
         $groupManager->listen('\\OC\\Group', 'postCreate', function (\OC\Group\Group $gid) {
             \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         return $groupManager;
     });
     $this->registerService('UserSession', function (Server $c) {
         $manager = $c->getUserManager();
         $userSession = new \OC\User\Session($manager, new \OC\Session\Memory(''));
         $userSession->listen('\\OC\\User', 'preCreateUser', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postCreateUser', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'preDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'postDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'preLogin', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postLogin', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'logout', function () {
             \OC_Hook::emit('OC_User', 'logout', array());
         });
         return $userSession;
     });
     $this->registerService('NavigationManager', function ($c) {
         return new \OC\NavigationManager();
     });
     $this->registerService('AllConfig', function (Server $c) {
         return new \OC\AllConfig($c->getSystemConfig());
     });
     $this->registerService('SystemConfig', function ($c) {
         return new \OC\SystemConfig();
     });
     $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 (Server $c) {
         $config = $c->getConfig();
         $cacheFactory = $c->getMemCacheFactory();
         return new \OC\URLGenerator($config, $cacheFactory);
     });
     $this->registerService('AppHelper', function ($c) {
         return new \OC\AppHelper();
     });
     $this->registerService('UserCache', function ($c) {
         return new Cache\File();
     });
     $this->registerService('MemCacheFactory', function (Server $c) {
         $config = $c->getConfig();
         if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
             $v = \OC_App::getAppVersions();
             $v['core'] = implode('.', \OC_Util::getVersion());
             $version = implode(',', $v);
             $instanceId = \OC_Util::getInstanceId();
             $path = \OC::$SERVERROOT;
             $prefix = md5($instanceId . '-' . $version . '-' . $path);
             return new \OC\Memcache\Factory($prefix, $config->getSystemValue('memcache.local', null), $config->getSystemValue('memcache.distributed', null), $config->getSystemValue('memcache.locking', null));
         }
         return new \OC\Memcache\Factory('', new ArrayCache(), new ArrayCache(), new ArrayCache());
     });
     $this->registerService('ActivityManager', function (Server $c) {
         return new ActivityManager($c->getRequest(), $c->getUserSession(), $c->getConfig());
     });
     $this->registerService('AvatarManager', function ($c) {
         return new AvatarManager();
     });
     $this->registerService('Logger', function (Server $c) {
         $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud');
         $logger = 'OC_Log_' . ucfirst($logClass);
         call_user_func(array($logger, 'init'));
         return new Log($logger);
     });
     $this->registerService('JobList', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
     });
     $this->registerService('Router', function (Server $c) {
         $cacheFactory = $c->getMemCacheFactory();
         if ($cacheFactory->isAvailable()) {
             $router = new \OC\Route\CachingRouter($cacheFactory->create('route'));
         } else {
             $router = new \OC\Route\Router();
         }
         return $router;
     });
     $this->registerService('Search', function ($c) {
         return new Search();
     });
     $this->registerService('SecureRandom', function ($c) {
         return new SecureRandom();
     });
     $this->registerService('Crypto', function (Server $c) {
         return new Crypto($c->getConfig(), $c->getSecureRandom());
     });
     $this->registerService('Hasher', function (Server $c) {
         return new Hasher($c->getConfig());
     });
     $this->registerService('DatabaseConnection', function (Server $c) {
         $factory = new \OC\DB\ConnectionFactory();
         $systemConfig = $c->getSystemConfig();
         $type = $systemConfig->getValue('dbtype', 'sqlite');
         if (!$factory->isValidType($type)) {
             throw new \OC\DatabaseException('Invalid database type');
         }
         $connectionParams = $factory->createConnectionParams($systemConfig);
         $connection = $factory->getConnection($type, $connectionParams);
         $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
         return $connection;
     });
     $this->registerService('Db', function (Server $c) {
         return new Db($c->getDatabaseConnection());
     });
     $this->registerService('HTTPHelper', function (Server $c) {
         $config = $c->getConfig();
         return new HTTPHelper($config, $c->getHTTPClientService());
     });
     $this->registerService('HttpClientService', function (Server $c) {
         $user = \OC_User::getUser();
         $uid = $user ? $user : null;
         return new ClientService($c->getConfig(), new \OC\Security\CertificateManager($uid, new \OC\Files\View()));
     });
     $this->registerService('EventLogger', function (Server $c) {
         if (defined('DEBUG') and DEBUG) {
             return new EventLogger();
         } else {
             return new NullEventLogger();
         }
     });
     $this->registerService('QueryLogger', function ($c) {
         if (defined('DEBUG') and DEBUG) {
             return new QueryLogger();
         } else {
             return new NullQueryLogger();
         }
     });
     $this->registerService('TempManager', function (Server $c) {
         return new TempManager(get_temp_dir(), $c->getLogger());
     });
     $this->registerService('AppManager', function (Server $c) {
         return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager(), $c->getMemCacheFactory());
     });
     $this->registerService('DateTimeZone', function (Server $c) {
         return new DateTimeZone($c->getConfig(), $c->getSession());
     });
     $this->registerService('DateTimeFormatter', function (Server $c) {
         $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
         return new DateTimeFormatter($c->getDateTimeZone()->getTimeZone(), $c->getL10N('lib', $language));
     });
     $this->registerService('MountConfigManager', function () {
         $loader = \OC\Files\Filesystem::getLoader();
         return new \OC\Files\Config\MountProviderCollection($loader);
     });
     $this->registerService('IniWrapper', function ($c) {
         return new IniGetWrapper();
     });
     $this->registerService('AsyncCommandBus', function (Server $c) {
         $jobList = $c->getJobList();
         return new AsyncBus($jobList);
     });
     $this->registerService('TrustedDomainHelper', function ($c) {
         return new TrustedDomainHelper($this->getConfig());
     });
     $this->registerService('Request', function ($c) {
         if (isset($this['urlParams'])) {
             $urlParams = $this['urlParams'];
         } else {
             $urlParams = [];
         }
         if ($this->getSession()->exists('requesttoken')) {
             $requestToken = $this->getSession()->get('requesttoken');
         } else {
             $requestToken = false;
         }
         if (defined('PHPUNIT_RUN') && PHPUNIT_RUN && in_array('fakeinput', stream_get_wrappers())) {
             $stream = 'fakeinput://data';
         } else {
             $stream = 'php://input';
         }
         return new Request(['get' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'server' => $_SERVER, 'env' => $_ENV, 'cookies' => $_COOKIE, 'method' => isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null, 'urlParams' => $urlParams, 'requesttoken' => $requestToken], $this->getSecureRandom(), $this->getConfig(), $stream);
     });
     $this->registerService('Mailer', function (Server $c) {
         return new Mailer($c->getConfig(), $c->getLogger(), new \OC_Defaults());
     });
     $this->registerService('OcsClient', function (Server $c) {
         return new OCSClient($this->getHTTPClientService(), $this->getConfig(), $this->getLogger());
     });
     $this->registerService('LockingProvider', function (Server $c) {
         if ($c->getConfig()->getSystemValue('filelocking.enabled', false) or defined('PHPUNIT_RUN') && PHPUNIT_RUN) {
             /** @var \OC\Memcache\Factory $memcacheFactory */
             $memcacheFactory = $c->getMemCacheFactory();
             $memcache = $memcacheFactory->createLocking('lock');
             if (!$memcache instanceof \OC\Memcache\NullCache) {
                 return new MemcacheLockingProvider($memcache);
             }
             throw new HintException('File locking is enabled but the locking cache class was not found', 'Please check the "memcache.locking" setting and make sure the matching PHP module is installed and enabled');
         }
         return new NoopLockingProvider();
     });
 }
Пример #4
0
 function __construct()
 {
     $this->registerService('ContactsManager', function ($c) {
         return new ContactsManager();
     });
     $this->registerService('Request', function ($c) {
         if (isset($c['urlParams'])) {
             $urlParams = $c['urlParams'];
         } else {
             $urlParams = array();
         }
         if (\OC::$server->getSession()->exists('requesttoken')) {
             $requestToken = \OC::$server->getSession()->get('requesttoken');
         } else {
             $requestToken = false;
         }
         if (defined('PHPUNIT_RUN') && PHPUNIT_RUN && in_array('fakeinput', stream_get_wrappers())) {
             $stream = 'fakeinput://data';
         } else {
             $stream = 'php://input';
         }
         return new Request(array('get' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'server' => $_SERVER, 'env' => $_ENV, 'cookies' => $_COOKIE, 'method' => isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null, 'urlParams' => $urlParams, 'requesttoken' => $requestToken), $stream);
     });
     $this->registerService('PreviewManager', function ($c) {
         return new PreviewManager();
     });
     $this->registerService('TagMapper', function (Server $c) {
         return new TagMapper($c->getDb());
     });
     $this->registerService('TagManager', function (Server $c) {
         $tagMapper = $c->query('TagMapper');
         $user = \OC_User::getUser();
         return new TagManager($tagMapper, $user);
     });
     $this->registerService('RootFolder', function (Server $c) {
         // TODO: get user and user manager from container as well
         $user = \OC_User::getUser();
         /** @var $c SimpleContainer */
         $userManager = $c->query('UserManager');
         $user = $userManager->get($user);
         $manager = \OC\Files\Filesystem::getMountManager();
         $view = new View();
         return new Root($manager, $view, $user);
     });
     $this->registerService('UserManager', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\User\Manager($config);
     });
     $this->registerService('GroupManager', function (Server $c) {
         $userManager = $c->getUserManager();
         return new \OC\Group\Manager($userManager);
     });
     $this->registerService('UserSession', function (Server $c) {
         $manager = $c->getUserManager();
         $userSession = new \OC\User\Session($manager, new \OC\Session\Memory(''));
         $userSession->listen('\\OC\\User', 'preCreateUser', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postCreateUser', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'preDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'postDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'preLogin', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postLogin', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'logout', function () {
             \OC_Hook::emit('OC_User', 'logout', array());
         });
         return $userSession;
     });
     $this->registerService('NavigationManager', function ($c) {
         return new \OC\NavigationManager();
     });
     $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 (Server $c) {
         $config = $c->getConfig();
         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();
     });
     $this->registerService('Logger', function (Server $c) {
         $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud');
         $logger = 'OC_Log_' . ucfirst($logClass);
         call_user_func(array($logger, 'init'));
         return new Log($logger);
     });
     $this->registerService('JobList', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
     });
     $this->registerService('Router', function (Server $c) {
         $cacheFactory = $c->getMemCacheFactory();
         if ($cacheFactory->isAvailable()) {
             $router = new \OC\Route\CachingRouter($cacheFactory->create('route'));
         } else {
             $router = new \OC\Route\Router();
         }
         return $router;
     });
     $this->registerService('Search', function ($c) {
         return new Search();
     });
     $this->registerService('SecureRandom', function ($c) {
         return new SecureRandom();
     });
     $this->registerService('Crypto', function (Server $c) {
         return new Crypto($c->getConfig(), $c->getSecureRandom());
     });
     $this->registerService('DatabaseConnection', function (Server $c) {
         $factory = new \OC\DB\ConnectionFactory();
         $type = $c->getConfig()->getSystemValue('dbtype', 'sqlite');
         if (!$factory->isValidType($type)) {
             throw new \DatabaseException('Invalid database type');
         }
         $connectionParams = $factory->createConnectionParams($c->getConfig());
         $connection = $factory->getConnection($type, $connectionParams);
         $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
         return $connection;
     });
     $this->registerService('Db', function (Server $c) {
         return new Db($c->getDatabaseConnection());
     });
     $this->registerService('HTTPHelper', function (Server $c) {
         $config = $c->getConfig();
         return new HTTPHelper($config);
     });
     $this->registerService('EventLogger', function (Server $c) {
         if (defined('DEBUG') and DEBUG) {
             return new EventLogger();
         } else {
             return new NullEventLogger();
         }
     });
     $this->registerService('QueryLogger', function ($c) {
         if (defined('DEBUG') and DEBUG) {
             return new QueryLogger();
         } else {
             return new NullQueryLogger();
         }
     });
     $this->registerService('TempManager', function ($c) {
         /** @var Server $c */
         return new TempManager(get_temp_dir(), $c->getLogger());
     });
 }
Пример #5
0
 /**
  * @param string $webRoot
  */
 function __construct($webRoot)
 {
     $this->webRoot = $webRoot;
     $this->registerService('ContactsManager', function ($c) {
         return new ContactsManager();
     });
     $this->registerService('PreviewManager', function ($c) {
         return new PreviewManager();
     });
     $this->registerService('TagMapper', function (Server $c) {
         return new TagMapper($c->getDb());
     });
     $this->registerService('TagManager', function (Server $c) {
         $tagMapper = $c->query('TagMapper');
         return new TagManager($tagMapper, $c->getUserSession());
     });
     $this->registerService('RootFolder', function (Server $c) {
         // TODO: get user and user manager from container as well
         $user = \OC_User::getUser();
         /** @var $c SimpleContainer */
         $userManager = $c->query('UserManager');
         $user = $userManager->get($user);
         $manager = \OC\Files\Filesystem::getMountManager();
         $view = new View();
         return new Root($manager, $view, $user);
     });
     $this->registerService('UserManager', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\User\Manager($config);
     });
     $this->registerService('GroupManager', function (Server $c) {
         $groupManager = new \OC\Group\Manager($this->getUserManager());
         $groupManager->listen('\\OC\\Group', 'preCreate', function ($gid) {
             \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
         });
         $groupManager->listen('\\OC\\Group', 'postCreate', function (\OC\Group\Group $gid) {
             \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postDelete', function (\OC\Group\Group $group) {
             \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         $groupManager->listen('\\OC\\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
             \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
         });
         return $groupManager;
     });
     $this->registerService('UserSession', function (Server $c) {
         $manager = $c->getUserManager();
         $userSession = new \OC\User\Session($manager, new \OC\Session\Memory(''));
         $userSession->listen('\\OC\\User', 'preCreateUser', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postCreateUser', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'preDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'postDelete', function ($user) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
         });
         $userSession->listen('\\OC\\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
         });
         $userSession->listen('\\OC\\User', 'preLogin', function ($uid, $password) {
             \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'postLogin', function ($user, $password) {
             /** @var $user \OC\User\User */
             \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
         });
         $userSession->listen('\\OC\\User', 'logout', function () {
             \OC_Hook::emit('OC_User', 'logout', array());
         });
         return $userSession;
     });
     $this->registerService('NavigationManager', function ($c) {
         return new \OC\NavigationManager();
     });
     $this->registerService('AllConfig', function (Server $c) {
         return new \OC\AllConfig($c->getSystemConfig());
     });
     $this->registerService('SystemConfig', function ($c) {
         return new \OC\SystemConfig();
     });
     $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 (Server $c) {
         $config = $c->getConfig();
         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();
     });
     $this->registerService('Logger', function (Server $c) {
         $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud');
         $logger = 'OC_Log_' . ucfirst($logClass);
         call_user_func(array($logger, 'init'));
         return new Log($logger);
     });
     $this->registerService('JobList', function (Server $c) {
         $config = $c->getConfig();
         return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
     });
     $this->registerService('Router', function (Server $c) {
         $cacheFactory = $c->getMemCacheFactory();
         if ($cacheFactory->isAvailable()) {
             $router = new \OC\Route\CachingRouter($cacheFactory->create('route'));
         } else {
             $router = new \OC\Route\Router();
         }
         return $router;
     });
     $this->registerService('Search', function ($c) {
         return new Search();
     });
     $this->registerService('SecureRandom', function ($c) {
         return new SecureRandom();
     });
     $this->registerService('Crypto', function (Server $c) {
         return new Crypto($c->getConfig(), $c->getSecureRandom());
     });
     $this->registerService('Hasher', function (Server $c) {
         return new Hasher($c->getConfig());
     });
     $this->registerService('DatabaseConnection', function (Server $c) {
         $factory = new \OC\DB\ConnectionFactory();
         $systemConfig = $c->getSystemConfig();
         $type = $systemConfig->getValue('dbtype', 'sqlite');
         if (!$factory->isValidType($type)) {
             throw new \OC\DatabaseException('Invalid database type');
         }
         $connectionParams = $factory->createConnectionParams($systemConfig);
         $connection = $factory->getConnection($type, $connectionParams);
         $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
         return $connection;
     });
     $this->registerService('Db', function (Server $c) {
         return new Db($c->getDatabaseConnection());
     });
     $this->registerService('HTTPHelper', function (Server $c) {
         $config = $c->getConfig();
         $user = $c->getUserSession()->getUser();
         $uid = $user ? $user->getUID() : null;
         return new HTTPHelper($config, new \OC\Security\CertificateManager($uid, new \OC\Files\View()));
     });
     $this->registerService('EventLogger', function (Server $c) {
         if (defined('DEBUG') and DEBUG) {
             return new EventLogger();
         } else {
             return new NullEventLogger();
         }
     });
     $this->registerService('QueryLogger', function ($c) {
         if (defined('DEBUG') and DEBUG) {
             return new QueryLogger();
         } else {
             return new NullQueryLogger();
         }
     });
     $this->registerService('TempManager', function (Server $c) {
         return new TempManager(get_temp_dir(), $c->getLogger());
     });
     $this->registerService('AppManager', function (Server $c) {
         $userSession = $c->getUserSession();
         $appConfig = $c->getAppConfig();
         $groupManager = $c->getGroupManager();
         return new \OC\App\AppManager($userSession, $appConfig, $groupManager);
     });
     $this->registerService('DateTimeZone', function (Server $c) {
         return new DateTimeZone($c->getConfig(), $c->getSession());
     });
     $this->registerService('DateTimeFormatter', function (Server $c) {
         $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
         return new DateTimeFormatter($c->getDateTimeZone()->getTimeZone(), $c->getL10N('lib', $language));
     });
     $this->registerService('MountConfigManager', function () {
         $loader = \OC\Files\Filesystem::getLoader();
         return new \OC\Files\Config\MountProviderCollection($loader);
     });
     $this->registerService('IniWrapper', function ($c) {
         return new IniGetWrapper();
     });
     $this->registerService('TrustedDomainHelper', function ($c) {
         return new TrustedDomainHelper($this->getConfig());
     });
 }