Completed
Pull Request — master (#6254)
by Robin
29:04 queued 13:31
created
lib/private/Server.php 3 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -55,8 +55,6 @@  discard block
 block discarded – undo
55 55
 use OC\Command\CronBus;
56 56
 use OC\Contacts\ContactsMenu\ActionFactory;
57 57
 use OC\Diagnostics\EventLogger;
58
-use OC\Diagnostics\NullEventLogger;
59
-use OC\Diagnostics\NullQueryLogger;
60 58
 use OC\Diagnostics\QueryLogger;
61 59
 use OC\Federation\CloudIdManager;
62 60
 use OC\Files\Config\UserMountCache;
@@ -101,7 +99,6 @@  discard block
 block discarded – undo
101 99
 use OC\Tagging\TagMapper;
102 100
 use OC\Template\SCSSCacher;
103 101
 use OCA\Theming\ThemingDefaults;
104
-
105 102
 use OCP\App\IAppManager;
106 103
 use OCP\Defaults;
107 104
 use OCA\Theming\Util;
Please login to merge, or discard this patch.
Indentation   +1672 added lines, -1672 removed lines patch added patch discarded remove patch
@@ -129,1681 +129,1681 @@
 block discarded – undo
129 129
  * TODO: hookup all manager classes
130 130
  */
131 131
 class Server extends ServerContainer implements IServerContainer {
132
-	/** @var string */
133
-	private $webRoot;
134
-
135
-	/**
136
-	 * @param string $webRoot
137
-	 * @param \OC\Config $config
138
-	 */
139
-	public function __construct($webRoot, \OC\Config $config) {
140
-		parent::__construct();
141
-		$this->webRoot = $webRoot;
142
-
143
-		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
144
-			return $c;
145
-		});
146
-
147
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
148
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
149
-
150
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
151
-
152
-
153
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
154
-			return new PreviewManager(
155
-				$c->getConfig(),
156
-				$c->getRootFolder(),
157
-				$c->getAppDataDir('preview'),
158
-				$c->getEventDispatcher(),
159
-				$c->getSession()->get('user_id')
160
-			);
161
-		});
162
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
163
-
164
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
165
-			return new \OC\Preview\Watcher(
166
-				$c->getAppDataDir('preview')
167
-			);
168
-		});
169
-
170
-		$this->registerService('EncryptionManager', function (Server $c) {
171
-			$view = new View();
172
-			$util = new Encryption\Util(
173
-				$view,
174
-				$c->getUserManager(),
175
-				$c->getGroupManager(),
176
-				$c->getConfig()
177
-			);
178
-			return new Encryption\Manager(
179
-				$c->getConfig(),
180
-				$c->getLogger(),
181
-				$c->getL10N('core'),
182
-				new View(),
183
-				$util,
184
-				new ArrayCache()
185
-			);
186
-		});
187
-
188
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
189
-			$util = new Encryption\Util(
190
-				new View(),
191
-				$c->getUserManager(),
192
-				$c->getGroupManager(),
193
-				$c->getConfig()
194
-			);
195
-			return new Encryption\File(
196
-				$util,
197
-				$c->getRootFolder(),
198
-				$c->getShareManager()
199
-			);
200
-		});
201
-
202
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
203
-			$view = new View();
204
-			$util = new Encryption\Util(
205
-				$view,
206
-				$c->getUserManager(),
207
-				$c->getGroupManager(),
208
-				$c->getConfig()
209
-			);
210
-
211
-			return new Encryption\Keys\Storage($view, $util);
212
-		});
213
-		$this->registerService('TagMapper', function (Server $c) {
214
-			return new TagMapper($c->getDatabaseConnection());
215
-		});
216
-
217
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
218
-			$tagMapper = $c->query('TagMapper');
219
-			return new TagManager($tagMapper, $c->getUserSession());
220
-		});
221
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
222
-
223
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
224
-			$config = $c->getConfig();
225
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
226
-			/** @var \OC\SystemTag\ManagerFactory $factory */
227
-			$factory = new $factoryClass($this);
228
-			return $factory;
229
-		});
230
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
231
-			return $c->query('SystemTagManagerFactory')->getManager();
232
-		});
233
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
234
-
235
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
236
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
237
-		});
238
-		$this->registerService('RootFolder', function (Server $c) {
239
-			$manager = \OC\Files\Filesystem::getMountManager(null);
240
-			$view = new View();
241
-			$root = new Root(
242
-				$manager,
243
-				$view,
244
-				null,
245
-				$c->getUserMountCache(),
246
-				$this->getLogger(),
247
-				$this->getUserManager()
248
-			);
249
-			$connector = new HookConnector($root, $view);
250
-			$connector->viewToNode();
251
-
252
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
253
-			$previewConnector->connectWatcher();
254
-
255
-			return $root;
256
-		});
257
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
258
-
259
-		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
260
-			return new LazyRoot(function () use ($c) {
261
-				return $c->query('RootFolder');
262
-			});
263
-		});
264
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
265
-
266
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
267
-			$config = $c->getConfig();
268
-			return new \OC\User\Manager($config);
269
-		});
270
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
271
-
272
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
273
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
274
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
275
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
276
-			});
277
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
278
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
279
-			});
280
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
281
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
282
-			});
283
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
284
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
285
-			});
286
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
287
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
288
-			});
289
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
290
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
291
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
292
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
293
-			});
294
-			return $groupManager;
295
-		});
296
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
297
-
298
-		$this->registerService(Store::class, function (Server $c) {
299
-			$session = $c->getSession();
300
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
301
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
302
-			} else {
303
-				$tokenProvider = null;
304
-			}
305
-			$logger = $c->getLogger();
306
-			return new Store($session, $logger, $tokenProvider);
307
-		});
308
-		$this->registerAlias(IStore::class, Store::class);
309
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
310
-			$dbConnection = $c->getDatabaseConnection();
311
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
312
-		});
313
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
314
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
315
-			$crypto = $c->getCrypto();
316
-			$config = $c->getConfig();
317
-			$logger = $c->getLogger();
318
-			$timeFactory = new TimeFactory();
319
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
320
-		});
321
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
322
-
323
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
324
-			$manager = $c->getUserManager();
325
-			$session = new \OC\Session\Memory('');
326
-			$timeFactory = new TimeFactory();
327
-			// Token providers might require a working database. This code
328
-			// might however be called when ownCloud is not yet setup.
329
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
330
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
331
-			} else {
332
-				$defaultTokenProvider = null;
333
-			}
334
-
335
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
336
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
337
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
338
-			});
339
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
340
-				/** @var $user \OC\User\User */
341
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
342
-			});
343
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
344
-				/** @var $user \OC\User\User */
345
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
346
-			});
347
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
348
-				/** @var $user \OC\User\User */
349
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
350
-			});
351
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
352
-				/** @var $user \OC\User\User */
353
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
354
-			});
355
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
356
-				/** @var $user \OC\User\User */
357
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
358
-			});
359
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
360
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
361
-			});
362
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
363
-				/** @var $user \OC\User\User */
364
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
365
-			});
366
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
367
-				/** @var $user \OC\User\User */
368
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
369
-			});
370
-			$userSession->listen('\OC\User', 'logout', function () {
371
-				\OC_Hook::emit('OC_User', 'logout', array());
372
-			});
373
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
374
-				/** @var $user \OC\User\User */
375
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
376
-			});
377
-			return $userSession;
378
-		});
379
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
380
-
381
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
382
-			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
383
-		});
384
-
385
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
386
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
387
-
388
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
389
-			return new \OC\AllConfig(
390
-				$c->getSystemConfig()
391
-			);
392
-		});
393
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
394
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
395
-
396
-		$this->registerService('SystemConfig', function ($c) use ($config) {
397
-			return new \OC\SystemConfig($config);
398
-		});
399
-
400
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
401
-			return new \OC\AppConfig($c->getDatabaseConnection());
402
-		});
403
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
404
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
405
-
406
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
407
-			return new \OC\L10N\Factory(
408
-				$c->getConfig(),
409
-				$c->getRequest(),
410
-				$c->getUserSession(),
411
-				\OC::$SERVERROOT
412
-			);
413
-		});
414
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
415
-
416
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
417
-			$config = $c->getConfig();
418
-			$cacheFactory = $c->getMemCacheFactory();
419
-			$request = $c->getRequest();
420
-			return new \OC\URLGenerator(
421
-				$config,
422
-				$cacheFactory,
423
-				$request
424
-			);
425
-		});
426
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
427
-
428
-		$this->registerService('AppHelper', function ($c) {
429
-			return new \OC\AppHelper();
430
-		});
431
-		$this->registerAlias('AppFetcher', AppFetcher::class);
432
-		$this->registerAlias('CategoryFetcher', CategoryFetcher::class);
433
-
434
-		$this->registerService(\OCP\ICache::class, function ($c) {
435
-			return new Cache\File();
436
-		});
437
-		$this->registerAlias('UserCache', \OCP\ICache::class);
438
-
439
-		$this->registerService(Factory::class, function (Server $c) {
440
-
441
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
442
-				'\\OC\\Memcache\\ArrayCache',
443
-				'\\OC\\Memcache\\ArrayCache',
444
-				'\\OC\\Memcache\\ArrayCache'
445
-			);
446
-			$config = $c->getConfig();
447
-			$request = $c->getRequest();
448
-			$urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
449
-
450
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
451
-				$v = \OC_App::getAppVersions();
452
-				$v['core'] = implode(',', \OC_Util::getVersion());
453
-				$version = implode(',', $v);
454
-				$instanceId = \OC_Util::getInstanceId();
455
-				$path = \OC::$SERVERROOT;
456
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
457
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
458
-					$config->getSystemValue('memcache.local', null),
459
-					$config->getSystemValue('memcache.distributed', null),
460
-					$config->getSystemValue('memcache.locking', null)
461
-				);
462
-			}
463
-			return $arrayCacheFactory;
464
-
465
-		});
466
-		$this->registerAlias('MemCacheFactory', Factory::class);
467
-		$this->registerAlias(ICacheFactory::class, Factory::class);
468
-
469
-		$this->registerService('RedisFactory', function (Server $c) {
470
-			$systemConfig = $c->getSystemConfig();
471
-			return new RedisFactory($systemConfig);
472
-		});
473
-
474
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
475
-			return new \OC\Activity\Manager(
476
-				$c->getRequest(),
477
-				$c->getUserSession(),
478
-				$c->getConfig(),
479
-				$c->query(IValidator::class)
480
-			);
481
-		});
482
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
483
-
484
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
485
-			return new \OC\Activity\EventMerger(
486
-				$c->getL10N('lib')
487
-			);
488
-		});
489
-		$this->registerAlias(IValidator::class, Validator::class);
490
-
491
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
492
-			return new AvatarManager(
493
-				$c->getUserManager(),
494
-				$c->getAppDataDir('avatar'),
495
-				$c->getL10N('lib'),
496
-				$c->getLogger(),
497
-				$c->getConfig()
498
-			);
499
-		});
500
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
501
-
502
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
503
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
504
-			$logger = Log::getLogClass($logType);
505
-			call_user_func(array($logger, 'init'));
506
-
507
-			return new Log($logger);
508
-		});
509
-		$this->registerAlias('Logger', \OCP\ILogger::class);
510
-
511
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
512
-			$config = $c->getConfig();
513
-			return new \OC\BackgroundJob\JobList(
514
-				$c->getDatabaseConnection(),
515
-				$config,
516
-				new TimeFactory()
517
-			);
518
-		});
519
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
520
-
521
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
522
-			$cacheFactory = $c->getMemCacheFactory();
523
-			$logger = $c->getLogger();
524
-			if ($cacheFactory->isAvailable()) {
525
-				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
526
-			} else {
527
-				$router = new \OC\Route\Router($logger);
528
-			}
529
-			return $router;
530
-		});
531
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
532
-
533
-		$this->registerService(\OCP\ISearch::class, function ($c) {
534
-			return new Search();
535
-		});
536
-		$this->registerAlias('Search', \OCP\ISearch::class);
537
-
538
-		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) {
539
-			return new \OC\Security\RateLimiting\Limiter(
540
-				$this->getUserSession(),
541
-				$this->getRequest(),
542
-				new \OC\AppFramework\Utility\TimeFactory(),
543
-				$c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
544
-			);
545
-		});
546
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
547
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
548
-				$this->getMemCacheFactory(),
549
-				new \OC\AppFramework\Utility\TimeFactory()
550
-			);
551
-		});
552
-
553
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
554
-			return new SecureRandom();
555
-		});
556
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
557
-
558
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
559
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
560
-		});
561
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
562
-
563
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
564
-			return new Hasher($c->getConfig());
565
-		});
566
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
567
-
568
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
569
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
570
-		});
571
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
572
-
573
-		$this->registerService(IDBConnection::class, function (Server $c) {
574
-			$systemConfig = $c->getSystemConfig();
575
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
576
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
577
-			if (!$factory->isValidType($type)) {
578
-				throw new \OC\DatabaseException('Invalid database type');
579
-			}
580
-			$connectionParams = $factory->createConnectionParams();
581
-			$connection = $factory->getConnection($type, $connectionParams);
582
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
583
-			return $connection;
584
-		});
585
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
586
-
587
-		$this->registerService('HTTPHelper', function (Server $c) {
588
-			$config = $c->getConfig();
589
-			return new HTTPHelper(
590
-				$config,
591
-				$c->getHTTPClientService()
592
-			);
593
-		});
594
-
595
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
596
-			$user = \OC_User::getUser();
597
-			$uid = $user ? $user : null;
598
-			return new ClientService(
599
-				$c->getConfig(),
600
-				new \OC\Security\CertificateManager(
601
-					$uid,
602
-					new View(),
603
-					$c->getConfig(),
604
-					$c->getLogger(),
605
-					$c->getSecureRandom()
606
-				)
607
-			);
608
-		});
609
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
610
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
611
-			$eventLogger = new EventLogger();
612
-			if ($c->getSystemConfig()->getValue('debug', false)) {
613
-				// In debug mode, module is being activated by default
614
-				$eventLogger->activate();
615
-			}
616
-			return $eventLogger;
617
-		});
618
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
619
-
620
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
621
-			$queryLogger = new QueryLogger();
622
-			if ($c->getSystemConfig()->getValue('debug', false)) {
623
-				// In debug mode, module is being activated by default
624
-				$queryLogger->activate();
625
-			}
626
-			return $queryLogger;
627
-		});
628
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
629
-
630
-		$this->registerService(TempManager::class, function (Server $c) {
631
-			return new TempManager(
632
-				$c->getLogger(),
633
-				$c->getConfig()
634
-			);
635
-		});
636
-		$this->registerAlias('TempManager', TempManager::class);
637
-		$this->registerAlias(ITempManager::class, TempManager::class);
638
-
639
-		$this->registerService(AppManager::class, function (Server $c) {
640
-			return new \OC\App\AppManager(
641
-				$c->getUserSession(),
642
-				$c->getAppConfig(),
643
-				$c->getGroupManager(),
644
-				$c->getMemCacheFactory(),
645
-				$c->getEventDispatcher()
646
-			);
647
-		});
648
-		$this->registerAlias('AppManager', AppManager::class);
649
-		$this->registerAlias(IAppManager::class, AppManager::class);
650
-
651
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
652
-			return new DateTimeZone(
653
-				$c->getConfig(),
654
-				$c->getSession()
655
-			);
656
-		});
657
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
658
-
659
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
660
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
661
-
662
-			return new DateTimeFormatter(
663
-				$c->getDateTimeZone()->getTimeZone(),
664
-				$c->getL10N('lib', $language)
665
-			);
666
-		});
667
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
668
-
669
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
670
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
671
-			$listener = new UserMountCacheListener($mountCache);
672
-			$listener->listen($c->getUserManager());
673
-			return $mountCache;
674
-		});
675
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
676
-
677
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
678
-			$loader = \OC\Files\Filesystem::getLoader();
679
-			$mountCache = $c->query('UserMountCache');
680
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
681
-
682
-			// builtin providers
683
-
684
-			$config = $c->getConfig();
685
-			$manager->registerProvider(new CacheMountProvider($config));
686
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
687
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
688
-
689
-			return $manager;
690
-		});
691
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
692
-
693
-		$this->registerService('IniWrapper', function ($c) {
694
-			return new IniGetWrapper();
695
-		});
696
-		$this->registerService('AsyncCommandBus', function (Server $c) {
697
-			$busClass = $c->getConfig()->getSystemValue('commandbus');
698
-			if ($busClass) {
699
-				list($app, $class) = explode('::', $busClass, 2);
700
-				if ($c->getAppManager()->isInstalled($app)) {
701
-					\OC_App::loadApp($app);
702
-					return $c->query($class);
703
-				} else {
704
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
705
-				}
706
-			} else {
707
-				$jobList = $c->getJobList();
708
-				return new CronBus($jobList);
709
-			}
710
-		});
711
-		$this->registerService('TrustedDomainHelper', function ($c) {
712
-			return new TrustedDomainHelper($this->getConfig());
713
-		});
714
-		$this->registerService('Throttler', function (Server $c) {
715
-			return new Throttler(
716
-				$c->getDatabaseConnection(),
717
-				new TimeFactory(),
718
-				$c->getLogger(),
719
-				$c->getConfig()
720
-			);
721
-		});
722
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
723
-			// IConfig and IAppManager requires a working database. This code
724
-			// might however be called when ownCloud is not yet setup.
725
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
726
-				$config = $c->getConfig();
727
-				$appManager = $c->getAppManager();
728
-			} else {
729
-				$config = null;
730
-				$appManager = null;
731
-			}
732
-
733
-			return new Checker(
734
-				new EnvironmentHelper(),
735
-				new FileAccessHelper(),
736
-				new AppLocator(),
737
-				$config,
738
-				$c->getMemCacheFactory(),
739
-				$appManager,
740
-				$c->getTempManager()
741
-			);
742
-		});
743
-		$this->registerService(\OCP\IRequest::class, function ($c) {
744
-			if (isset($this['urlParams'])) {
745
-				$urlParams = $this['urlParams'];
746
-			} else {
747
-				$urlParams = [];
748
-			}
749
-
750
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
751
-				&& in_array('fakeinput', stream_get_wrappers())
752
-			) {
753
-				$stream = 'fakeinput://data';
754
-			} else {
755
-				$stream = 'php://input';
756
-			}
757
-
758
-			return new Request(
759
-				[
760
-					'get' => $_GET,
761
-					'post' => $_POST,
762
-					'files' => $_FILES,
763
-					'server' => $_SERVER,
764
-					'env' => $_ENV,
765
-					'cookies' => $_COOKIE,
766
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
767
-						? $_SERVER['REQUEST_METHOD']
768
-						: null,
769
-					'urlParams' => $urlParams,
770
-				],
771
-				$this->getSecureRandom(),
772
-				$this->getConfig(),
773
-				$this->getCsrfTokenManager(),
774
-				$stream
775
-			);
776
-		});
777
-		$this->registerAlias('Request', \OCP\IRequest::class);
778
-
779
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
780
-			return new Mailer(
781
-				$c->getConfig(),
782
-				$c->getLogger(),
783
-				$c->query(Defaults::class),
784
-				$c->getURLGenerator(),
785
-				$c->getL10N('lib')
786
-			);
787
-		});
788
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
789
-
790
-		$this->registerService('LDAPProvider', function (Server $c) {
791
-			$config = $c->getConfig();
792
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
793
-			if (is_null($factoryClass)) {
794
-				throw new \Exception('ldapProviderFactory not set');
795
-			}
796
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
797
-			$factory = new $factoryClass($this);
798
-			return $factory->getLDAPProvider();
799
-		});
800
-		$this->registerService(ILockingProvider::class, function (Server $c) {
801
-			$ini = $c->getIniWrapper();
802
-			$config = $c->getConfig();
803
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
804
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
805
-				/** @var \OC\Memcache\Factory $memcacheFactory */
806
-				$memcacheFactory = $c->getMemCacheFactory();
807
-				$memcache = $memcacheFactory->createLocking('lock');
808
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
809
-					return new MemcacheLockingProvider($memcache, $ttl);
810
-				}
811
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
812
-			}
813
-			return new NoopLockingProvider();
814
-		});
815
-		$this->registerAlias('LockingProvider', ILockingProvider::class);
816
-
817
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
818
-			return new \OC\Files\Mount\Manager();
819
-		});
820
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
821
-
822
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
823
-			return new \OC\Files\Type\Detection(
824
-				$c->getURLGenerator(),
825
-				\OC::$configDir,
826
-				\OC::$SERVERROOT . '/resources/config/'
827
-			);
828
-		});
829
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
830
-
831
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
832
-			return new \OC\Files\Type\Loader(
833
-				$c->getDatabaseConnection()
834
-			);
835
-		});
836
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
837
-		$this->registerService(BundleFetcher::class, function () {
838
-			return new BundleFetcher($this->getL10N('lib'));
839
-		});
840
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
841
-			return new Manager(
842
-				$c->query(IValidator::class)
843
-			);
844
-		});
845
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
846
-
847
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
848
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
849
-			$manager->registerCapability(function () use ($c) {
850
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
851
-			});
852
-			$manager->registerCapability(function () use ($c) {
853
-				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
854
-			});
855
-			return $manager;
856
-		});
857
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
858
-
859
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
860
-			$config = $c->getConfig();
861
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
862
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
863
-			$factory = new $factoryClass($this);
864
-			return $factory->getManager();
865
-		});
866
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
867
-
868
-		$this->registerService('ThemingDefaults', function (Server $c) {
869
-			/*
132
+    /** @var string */
133
+    private $webRoot;
134
+
135
+    /**
136
+     * @param string $webRoot
137
+     * @param \OC\Config $config
138
+     */
139
+    public function __construct($webRoot, \OC\Config $config) {
140
+        parent::__construct();
141
+        $this->webRoot = $webRoot;
142
+
143
+        $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
144
+            return $c;
145
+        });
146
+
147
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
148
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
149
+
150
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
151
+
152
+
153
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
154
+            return new PreviewManager(
155
+                $c->getConfig(),
156
+                $c->getRootFolder(),
157
+                $c->getAppDataDir('preview'),
158
+                $c->getEventDispatcher(),
159
+                $c->getSession()->get('user_id')
160
+            );
161
+        });
162
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
163
+
164
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
165
+            return new \OC\Preview\Watcher(
166
+                $c->getAppDataDir('preview')
167
+            );
168
+        });
169
+
170
+        $this->registerService('EncryptionManager', function (Server $c) {
171
+            $view = new View();
172
+            $util = new Encryption\Util(
173
+                $view,
174
+                $c->getUserManager(),
175
+                $c->getGroupManager(),
176
+                $c->getConfig()
177
+            );
178
+            return new Encryption\Manager(
179
+                $c->getConfig(),
180
+                $c->getLogger(),
181
+                $c->getL10N('core'),
182
+                new View(),
183
+                $util,
184
+                new ArrayCache()
185
+            );
186
+        });
187
+
188
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
189
+            $util = new Encryption\Util(
190
+                new View(),
191
+                $c->getUserManager(),
192
+                $c->getGroupManager(),
193
+                $c->getConfig()
194
+            );
195
+            return new Encryption\File(
196
+                $util,
197
+                $c->getRootFolder(),
198
+                $c->getShareManager()
199
+            );
200
+        });
201
+
202
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
203
+            $view = new View();
204
+            $util = new Encryption\Util(
205
+                $view,
206
+                $c->getUserManager(),
207
+                $c->getGroupManager(),
208
+                $c->getConfig()
209
+            );
210
+
211
+            return new Encryption\Keys\Storage($view, $util);
212
+        });
213
+        $this->registerService('TagMapper', function (Server $c) {
214
+            return new TagMapper($c->getDatabaseConnection());
215
+        });
216
+
217
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
218
+            $tagMapper = $c->query('TagMapper');
219
+            return new TagManager($tagMapper, $c->getUserSession());
220
+        });
221
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
222
+
223
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
224
+            $config = $c->getConfig();
225
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
226
+            /** @var \OC\SystemTag\ManagerFactory $factory */
227
+            $factory = new $factoryClass($this);
228
+            return $factory;
229
+        });
230
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
231
+            return $c->query('SystemTagManagerFactory')->getManager();
232
+        });
233
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
234
+
235
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
236
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
237
+        });
238
+        $this->registerService('RootFolder', function (Server $c) {
239
+            $manager = \OC\Files\Filesystem::getMountManager(null);
240
+            $view = new View();
241
+            $root = new Root(
242
+                $manager,
243
+                $view,
244
+                null,
245
+                $c->getUserMountCache(),
246
+                $this->getLogger(),
247
+                $this->getUserManager()
248
+            );
249
+            $connector = new HookConnector($root, $view);
250
+            $connector->viewToNode();
251
+
252
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
253
+            $previewConnector->connectWatcher();
254
+
255
+            return $root;
256
+        });
257
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
258
+
259
+        $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
260
+            return new LazyRoot(function () use ($c) {
261
+                return $c->query('RootFolder');
262
+            });
263
+        });
264
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
265
+
266
+        $this->registerService(\OCP\IUserManager::class, function (Server $c) {
267
+            $config = $c->getConfig();
268
+            return new \OC\User\Manager($config);
269
+        });
270
+        $this->registerAlias('UserManager', \OCP\IUserManager::class);
271
+
272
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
273
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
274
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
275
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
276
+            });
277
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
278
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
279
+            });
280
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
281
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
282
+            });
283
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
284
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
285
+            });
286
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
287
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
288
+            });
289
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
290
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
291
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
292
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
293
+            });
294
+            return $groupManager;
295
+        });
296
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
297
+
298
+        $this->registerService(Store::class, function (Server $c) {
299
+            $session = $c->getSession();
300
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
301
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
302
+            } else {
303
+                $tokenProvider = null;
304
+            }
305
+            $logger = $c->getLogger();
306
+            return new Store($session, $logger, $tokenProvider);
307
+        });
308
+        $this->registerAlias(IStore::class, Store::class);
309
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
310
+            $dbConnection = $c->getDatabaseConnection();
311
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
312
+        });
313
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
314
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
315
+            $crypto = $c->getCrypto();
316
+            $config = $c->getConfig();
317
+            $logger = $c->getLogger();
318
+            $timeFactory = new TimeFactory();
319
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
320
+        });
321
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
322
+
323
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
324
+            $manager = $c->getUserManager();
325
+            $session = new \OC\Session\Memory('');
326
+            $timeFactory = new TimeFactory();
327
+            // Token providers might require a working database. This code
328
+            // might however be called when ownCloud is not yet setup.
329
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
330
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
331
+            } else {
332
+                $defaultTokenProvider = null;
333
+            }
334
+
335
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
336
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
337
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
338
+            });
339
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
340
+                /** @var $user \OC\User\User */
341
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
342
+            });
343
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
344
+                /** @var $user \OC\User\User */
345
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
346
+            });
347
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
348
+                /** @var $user \OC\User\User */
349
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
350
+            });
351
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
352
+                /** @var $user \OC\User\User */
353
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
354
+            });
355
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
356
+                /** @var $user \OC\User\User */
357
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
358
+            });
359
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
360
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
361
+            });
362
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
363
+                /** @var $user \OC\User\User */
364
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
365
+            });
366
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
367
+                /** @var $user \OC\User\User */
368
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
369
+            });
370
+            $userSession->listen('\OC\User', 'logout', function () {
371
+                \OC_Hook::emit('OC_User', 'logout', array());
372
+            });
373
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
374
+                /** @var $user \OC\User\User */
375
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
376
+            });
377
+            return $userSession;
378
+        });
379
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
380
+
381
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
382
+            return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
383
+        });
384
+
385
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
386
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
387
+
388
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
389
+            return new \OC\AllConfig(
390
+                $c->getSystemConfig()
391
+            );
392
+        });
393
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
394
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
395
+
396
+        $this->registerService('SystemConfig', function ($c) use ($config) {
397
+            return new \OC\SystemConfig($config);
398
+        });
399
+
400
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
401
+            return new \OC\AppConfig($c->getDatabaseConnection());
402
+        });
403
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
404
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
405
+
406
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
407
+            return new \OC\L10N\Factory(
408
+                $c->getConfig(),
409
+                $c->getRequest(),
410
+                $c->getUserSession(),
411
+                \OC::$SERVERROOT
412
+            );
413
+        });
414
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
415
+
416
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
417
+            $config = $c->getConfig();
418
+            $cacheFactory = $c->getMemCacheFactory();
419
+            $request = $c->getRequest();
420
+            return new \OC\URLGenerator(
421
+                $config,
422
+                $cacheFactory,
423
+                $request
424
+            );
425
+        });
426
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
427
+
428
+        $this->registerService('AppHelper', function ($c) {
429
+            return new \OC\AppHelper();
430
+        });
431
+        $this->registerAlias('AppFetcher', AppFetcher::class);
432
+        $this->registerAlias('CategoryFetcher', CategoryFetcher::class);
433
+
434
+        $this->registerService(\OCP\ICache::class, function ($c) {
435
+            return new Cache\File();
436
+        });
437
+        $this->registerAlias('UserCache', \OCP\ICache::class);
438
+
439
+        $this->registerService(Factory::class, function (Server $c) {
440
+
441
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
442
+                '\\OC\\Memcache\\ArrayCache',
443
+                '\\OC\\Memcache\\ArrayCache',
444
+                '\\OC\\Memcache\\ArrayCache'
445
+            );
446
+            $config = $c->getConfig();
447
+            $request = $c->getRequest();
448
+            $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
449
+
450
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
451
+                $v = \OC_App::getAppVersions();
452
+                $v['core'] = implode(',', \OC_Util::getVersion());
453
+                $version = implode(',', $v);
454
+                $instanceId = \OC_Util::getInstanceId();
455
+                $path = \OC::$SERVERROOT;
456
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
457
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
458
+                    $config->getSystemValue('memcache.local', null),
459
+                    $config->getSystemValue('memcache.distributed', null),
460
+                    $config->getSystemValue('memcache.locking', null)
461
+                );
462
+            }
463
+            return $arrayCacheFactory;
464
+
465
+        });
466
+        $this->registerAlias('MemCacheFactory', Factory::class);
467
+        $this->registerAlias(ICacheFactory::class, Factory::class);
468
+
469
+        $this->registerService('RedisFactory', function (Server $c) {
470
+            $systemConfig = $c->getSystemConfig();
471
+            return new RedisFactory($systemConfig);
472
+        });
473
+
474
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
475
+            return new \OC\Activity\Manager(
476
+                $c->getRequest(),
477
+                $c->getUserSession(),
478
+                $c->getConfig(),
479
+                $c->query(IValidator::class)
480
+            );
481
+        });
482
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
483
+
484
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
485
+            return new \OC\Activity\EventMerger(
486
+                $c->getL10N('lib')
487
+            );
488
+        });
489
+        $this->registerAlias(IValidator::class, Validator::class);
490
+
491
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
492
+            return new AvatarManager(
493
+                $c->getUserManager(),
494
+                $c->getAppDataDir('avatar'),
495
+                $c->getL10N('lib'),
496
+                $c->getLogger(),
497
+                $c->getConfig()
498
+            );
499
+        });
500
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
501
+
502
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
503
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
504
+            $logger = Log::getLogClass($logType);
505
+            call_user_func(array($logger, 'init'));
506
+
507
+            return new Log($logger);
508
+        });
509
+        $this->registerAlias('Logger', \OCP\ILogger::class);
510
+
511
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
512
+            $config = $c->getConfig();
513
+            return new \OC\BackgroundJob\JobList(
514
+                $c->getDatabaseConnection(),
515
+                $config,
516
+                new TimeFactory()
517
+            );
518
+        });
519
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
520
+
521
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
522
+            $cacheFactory = $c->getMemCacheFactory();
523
+            $logger = $c->getLogger();
524
+            if ($cacheFactory->isAvailable()) {
525
+                $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
526
+            } else {
527
+                $router = new \OC\Route\Router($logger);
528
+            }
529
+            return $router;
530
+        });
531
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
532
+
533
+        $this->registerService(\OCP\ISearch::class, function ($c) {
534
+            return new Search();
535
+        });
536
+        $this->registerAlias('Search', \OCP\ISearch::class);
537
+
538
+        $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) {
539
+            return new \OC\Security\RateLimiting\Limiter(
540
+                $this->getUserSession(),
541
+                $this->getRequest(),
542
+                new \OC\AppFramework\Utility\TimeFactory(),
543
+                $c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
544
+            );
545
+        });
546
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
547
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
548
+                $this->getMemCacheFactory(),
549
+                new \OC\AppFramework\Utility\TimeFactory()
550
+            );
551
+        });
552
+
553
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
554
+            return new SecureRandom();
555
+        });
556
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
557
+
558
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
559
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
560
+        });
561
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
562
+
563
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
564
+            return new Hasher($c->getConfig());
565
+        });
566
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
567
+
568
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
569
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
570
+        });
571
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
572
+
573
+        $this->registerService(IDBConnection::class, function (Server $c) {
574
+            $systemConfig = $c->getSystemConfig();
575
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
576
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
577
+            if (!$factory->isValidType($type)) {
578
+                throw new \OC\DatabaseException('Invalid database type');
579
+            }
580
+            $connectionParams = $factory->createConnectionParams();
581
+            $connection = $factory->getConnection($type, $connectionParams);
582
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
583
+            return $connection;
584
+        });
585
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
586
+
587
+        $this->registerService('HTTPHelper', function (Server $c) {
588
+            $config = $c->getConfig();
589
+            return new HTTPHelper(
590
+                $config,
591
+                $c->getHTTPClientService()
592
+            );
593
+        });
594
+
595
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
596
+            $user = \OC_User::getUser();
597
+            $uid = $user ? $user : null;
598
+            return new ClientService(
599
+                $c->getConfig(),
600
+                new \OC\Security\CertificateManager(
601
+                    $uid,
602
+                    new View(),
603
+                    $c->getConfig(),
604
+                    $c->getLogger(),
605
+                    $c->getSecureRandom()
606
+                )
607
+            );
608
+        });
609
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
610
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
611
+            $eventLogger = new EventLogger();
612
+            if ($c->getSystemConfig()->getValue('debug', false)) {
613
+                // In debug mode, module is being activated by default
614
+                $eventLogger->activate();
615
+            }
616
+            return $eventLogger;
617
+        });
618
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
619
+
620
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
621
+            $queryLogger = new QueryLogger();
622
+            if ($c->getSystemConfig()->getValue('debug', false)) {
623
+                // In debug mode, module is being activated by default
624
+                $queryLogger->activate();
625
+            }
626
+            return $queryLogger;
627
+        });
628
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
629
+
630
+        $this->registerService(TempManager::class, function (Server $c) {
631
+            return new TempManager(
632
+                $c->getLogger(),
633
+                $c->getConfig()
634
+            );
635
+        });
636
+        $this->registerAlias('TempManager', TempManager::class);
637
+        $this->registerAlias(ITempManager::class, TempManager::class);
638
+
639
+        $this->registerService(AppManager::class, function (Server $c) {
640
+            return new \OC\App\AppManager(
641
+                $c->getUserSession(),
642
+                $c->getAppConfig(),
643
+                $c->getGroupManager(),
644
+                $c->getMemCacheFactory(),
645
+                $c->getEventDispatcher()
646
+            );
647
+        });
648
+        $this->registerAlias('AppManager', AppManager::class);
649
+        $this->registerAlias(IAppManager::class, AppManager::class);
650
+
651
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
652
+            return new DateTimeZone(
653
+                $c->getConfig(),
654
+                $c->getSession()
655
+            );
656
+        });
657
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
658
+
659
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
660
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
661
+
662
+            return new DateTimeFormatter(
663
+                $c->getDateTimeZone()->getTimeZone(),
664
+                $c->getL10N('lib', $language)
665
+            );
666
+        });
667
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
668
+
669
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
670
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
671
+            $listener = new UserMountCacheListener($mountCache);
672
+            $listener->listen($c->getUserManager());
673
+            return $mountCache;
674
+        });
675
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
676
+
677
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
678
+            $loader = \OC\Files\Filesystem::getLoader();
679
+            $mountCache = $c->query('UserMountCache');
680
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
681
+
682
+            // builtin providers
683
+
684
+            $config = $c->getConfig();
685
+            $manager->registerProvider(new CacheMountProvider($config));
686
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
687
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
688
+
689
+            return $manager;
690
+        });
691
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
692
+
693
+        $this->registerService('IniWrapper', function ($c) {
694
+            return new IniGetWrapper();
695
+        });
696
+        $this->registerService('AsyncCommandBus', function (Server $c) {
697
+            $busClass = $c->getConfig()->getSystemValue('commandbus');
698
+            if ($busClass) {
699
+                list($app, $class) = explode('::', $busClass, 2);
700
+                if ($c->getAppManager()->isInstalled($app)) {
701
+                    \OC_App::loadApp($app);
702
+                    return $c->query($class);
703
+                } else {
704
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
705
+                }
706
+            } else {
707
+                $jobList = $c->getJobList();
708
+                return new CronBus($jobList);
709
+            }
710
+        });
711
+        $this->registerService('TrustedDomainHelper', function ($c) {
712
+            return new TrustedDomainHelper($this->getConfig());
713
+        });
714
+        $this->registerService('Throttler', function (Server $c) {
715
+            return new Throttler(
716
+                $c->getDatabaseConnection(),
717
+                new TimeFactory(),
718
+                $c->getLogger(),
719
+                $c->getConfig()
720
+            );
721
+        });
722
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
723
+            // IConfig and IAppManager requires a working database. This code
724
+            // might however be called when ownCloud is not yet setup.
725
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
726
+                $config = $c->getConfig();
727
+                $appManager = $c->getAppManager();
728
+            } else {
729
+                $config = null;
730
+                $appManager = null;
731
+            }
732
+
733
+            return new Checker(
734
+                new EnvironmentHelper(),
735
+                new FileAccessHelper(),
736
+                new AppLocator(),
737
+                $config,
738
+                $c->getMemCacheFactory(),
739
+                $appManager,
740
+                $c->getTempManager()
741
+            );
742
+        });
743
+        $this->registerService(\OCP\IRequest::class, function ($c) {
744
+            if (isset($this['urlParams'])) {
745
+                $urlParams = $this['urlParams'];
746
+            } else {
747
+                $urlParams = [];
748
+            }
749
+
750
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
751
+                && in_array('fakeinput', stream_get_wrappers())
752
+            ) {
753
+                $stream = 'fakeinput://data';
754
+            } else {
755
+                $stream = 'php://input';
756
+            }
757
+
758
+            return new Request(
759
+                [
760
+                    'get' => $_GET,
761
+                    'post' => $_POST,
762
+                    'files' => $_FILES,
763
+                    'server' => $_SERVER,
764
+                    'env' => $_ENV,
765
+                    'cookies' => $_COOKIE,
766
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
767
+                        ? $_SERVER['REQUEST_METHOD']
768
+                        : null,
769
+                    'urlParams' => $urlParams,
770
+                ],
771
+                $this->getSecureRandom(),
772
+                $this->getConfig(),
773
+                $this->getCsrfTokenManager(),
774
+                $stream
775
+            );
776
+        });
777
+        $this->registerAlias('Request', \OCP\IRequest::class);
778
+
779
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
780
+            return new Mailer(
781
+                $c->getConfig(),
782
+                $c->getLogger(),
783
+                $c->query(Defaults::class),
784
+                $c->getURLGenerator(),
785
+                $c->getL10N('lib')
786
+            );
787
+        });
788
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
789
+
790
+        $this->registerService('LDAPProvider', function (Server $c) {
791
+            $config = $c->getConfig();
792
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
793
+            if (is_null($factoryClass)) {
794
+                throw new \Exception('ldapProviderFactory not set');
795
+            }
796
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
797
+            $factory = new $factoryClass($this);
798
+            return $factory->getLDAPProvider();
799
+        });
800
+        $this->registerService(ILockingProvider::class, function (Server $c) {
801
+            $ini = $c->getIniWrapper();
802
+            $config = $c->getConfig();
803
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
804
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
805
+                /** @var \OC\Memcache\Factory $memcacheFactory */
806
+                $memcacheFactory = $c->getMemCacheFactory();
807
+                $memcache = $memcacheFactory->createLocking('lock');
808
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
809
+                    return new MemcacheLockingProvider($memcache, $ttl);
810
+                }
811
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
812
+            }
813
+            return new NoopLockingProvider();
814
+        });
815
+        $this->registerAlias('LockingProvider', ILockingProvider::class);
816
+
817
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
818
+            return new \OC\Files\Mount\Manager();
819
+        });
820
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
821
+
822
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
823
+            return new \OC\Files\Type\Detection(
824
+                $c->getURLGenerator(),
825
+                \OC::$configDir,
826
+                \OC::$SERVERROOT . '/resources/config/'
827
+            );
828
+        });
829
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
830
+
831
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
832
+            return new \OC\Files\Type\Loader(
833
+                $c->getDatabaseConnection()
834
+            );
835
+        });
836
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
837
+        $this->registerService(BundleFetcher::class, function () {
838
+            return new BundleFetcher($this->getL10N('lib'));
839
+        });
840
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
841
+            return new Manager(
842
+                $c->query(IValidator::class)
843
+            );
844
+        });
845
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
846
+
847
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
848
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
849
+            $manager->registerCapability(function () use ($c) {
850
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
851
+            });
852
+            $manager->registerCapability(function () use ($c) {
853
+                return $c->query(\OC\Security\Bruteforce\Capabilities::class);
854
+            });
855
+            return $manager;
856
+        });
857
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
858
+
859
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
860
+            $config = $c->getConfig();
861
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
862
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
863
+            $factory = new $factoryClass($this);
864
+            return $factory->getManager();
865
+        });
866
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
867
+
868
+        $this->registerService('ThemingDefaults', function (Server $c) {
869
+            /*
870 870
 			 * Dark magic for autoloader.
871 871
 			 * If we do a class_exists it will try to load the class which will
872 872
 			 * make composer cache the result. Resulting in errors when enabling
873 873
 			 * the theming app.
874 874
 			 */
875
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
876
-			if (isset($prefixes['OCA\\Theming\\'])) {
877
-				$classExists = true;
878
-			} else {
879
-				$classExists = false;
880
-			}
881
-
882
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
883
-				return new ThemingDefaults(
884
-					$c->getConfig(),
885
-					$c->getL10N('theming'),
886
-					$c->getURLGenerator(),
887
-					$c->getAppDataDir('theming'),
888
-					$c->getMemCacheFactory(),
889
-					new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming'))
890
-				);
891
-			}
892
-			return new \OC_Defaults();
893
-		});
894
-		$this->registerService(SCSSCacher::class, function (Server $c) {
895
-			/** @var Factory $cacheFactory */
896
-			$cacheFactory = $c->query(Factory::class);
897
-			return new SCSSCacher(
898
-				$c->getLogger(),
899
-				$c->query(\OC\Files\AppData\Factory::class),
900
-				$c->getURLGenerator(),
901
-				$c->getConfig(),
902
-				$c->getThemingDefaults(),
903
-				\OC::$SERVERROOT,
904
-				$cacheFactory->create('SCSS')
905
-			);
906
-		});
907
-		$this->registerService(EventDispatcher::class, function () {
908
-			return new EventDispatcher();
909
-		});
910
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
911
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
912
-
913
-		$this->registerService('CryptoWrapper', function (Server $c) {
914
-			// FIXME: Instantiiated here due to cyclic dependency
915
-			$request = new Request(
916
-				[
917
-					'get' => $_GET,
918
-					'post' => $_POST,
919
-					'files' => $_FILES,
920
-					'server' => $_SERVER,
921
-					'env' => $_ENV,
922
-					'cookies' => $_COOKIE,
923
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
924
-						? $_SERVER['REQUEST_METHOD']
925
-						: null,
926
-				],
927
-				$c->getSecureRandom(),
928
-				$c->getConfig()
929
-			);
930
-
931
-			return new CryptoWrapper(
932
-				$c->getConfig(),
933
-				$c->getCrypto(),
934
-				$c->getSecureRandom(),
935
-				$request
936
-			);
937
-		});
938
-		$this->registerService('CsrfTokenManager', function (Server $c) {
939
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
940
-
941
-			return new CsrfTokenManager(
942
-				$tokenGenerator,
943
-				$c->query(SessionStorage::class)
944
-			);
945
-		});
946
-		$this->registerService(SessionStorage::class, function (Server $c) {
947
-			return new SessionStorage($c->getSession());
948
-		});
949
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
950
-			return new ContentSecurityPolicyManager();
951
-		});
952
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
953
-
954
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
955
-			return new ContentSecurityPolicyNonceManager(
956
-				$c->getCsrfTokenManager(),
957
-				$c->getRequest()
958
-			);
959
-		});
960
-
961
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
962
-			$config = $c->getConfig();
963
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
964
-			/** @var \OCP\Share\IProviderFactory $factory */
965
-			$factory = new $factoryClass($this);
966
-
967
-			$manager = new \OC\Share20\Manager(
968
-				$c->getLogger(),
969
-				$c->getConfig(),
970
-				$c->getSecureRandom(),
971
-				$c->getHasher(),
972
-				$c->getMountManager(),
973
-				$c->getGroupManager(),
974
-				$c->getL10N('core'),
975
-				$factory,
976
-				$c->getUserManager(),
977
-				$c->getLazyRootFolder(),
978
-				$c->getEventDispatcher(),
979
-				$c->getMailer(),
980
-				$c->getURLGenerator(),
981
-				$c->getThemingDefaults()
982
-			);
983
-
984
-			return $manager;
985
-		});
986
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
987
-
988
-		$this->registerService('SettingsManager', function (Server $c) {
989
-			$manager = new \OC\Settings\Manager(
990
-				$c->getLogger(),
991
-				$c->getDatabaseConnection(),
992
-				$c->getL10N('lib'),
993
-				$c->getConfig(),
994
-				$c->getEncryptionManager(),
995
-				$c->getUserManager(),
996
-				$c->getLockingProvider(),
997
-				$c->getRequest(),
998
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
999
-				$c->getURLGenerator(),
1000
-				$c->query(AccountManager::class),
1001
-				$c->getGroupManager(),
1002
-				$c->getL10NFactory(),
1003
-				$c->getThemingDefaults(),
1004
-				$c->getAppManager()
1005
-			);
1006
-			return $manager;
1007
-		});
1008
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1009
-			return new \OC\Files\AppData\Factory(
1010
-				$c->getRootFolder(),
1011
-				$c->getSystemConfig()
1012
-			);
1013
-		});
1014
-
1015
-		$this->registerService('LockdownManager', function (Server $c) {
1016
-			return new LockdownManager(function () use ($c) {
1017
-				return $c->getSession();
1018
-			});
1019
-		});
1020
-
1021
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1022
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1023
-		});
1024
-
1025
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1026
-			return new CloudIdManager();
1027
-		});
1028
-
1029
-		/* To trick DI since we don't extend the DIContainer here */
1030
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1031
-			return new CleanPreviewsBackgroundJob(
1032
-				$c->getRootFolder(),
1033
-				$c->getLogger(),
1034
-				$c->getJobList(),
1035
-				new TimeFactory()
1036
-			);
1037
-		});
1038
-
1039
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1040
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1041
-
1042
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1043
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1044
-
1045
-		$this->registerService(Defaults::class, function (Server $c) {
1046
-			return new Defaults(
1047
-				$c->getThemingDefaults()
1048
-			);
1049
-		});
1050
-		$this->registerAlias('Defaults', \OCP\Defaults::class);
1051
-
1052
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1053
-			return $c->query(\OCP\IUserSession::class)->getSession();
1054
-		});
1055
-
1056
-		$this->registerService(IShareHelper::class, function (Server $c) {
1057
-			return new ShareHelper(
1058
-				$c->query(\OCP\Share\IManager::class)
1059
-			);
1060
-		});
1061
-	}
1062
-
1063
-	/**
1064
-	 * @return \OCP\Contacts\IManager
1065
-	 */
1066
-	public function getContactsManager() {
1067
-		return $this->query('ContactsManager');
1068
-	}
1069
-
1070
-	/**
1071
-	 * @return \OC\Encryption\Manager
1072
-	 */
1073
-	public function getEncryptionManager() {
1074
-		return $this->query('EncryptionManager');
1075
-	}
1076
-
1077
-	/**
1078
-	 * @return \OC\Encryption\File
1079
-	 */
1080
-	public function getEncryptionFilesHelper() {
1081
-		return $this->query('EncryptionFileHelper');
1082
-	}
1083
-
1084
-	/**
1085
-	 * @return \OCP\Encryption\Keys\IStorage
1086
-	 */
1087
-	public function getEncryptionKeyStorage() {
1088
-		return $this->query('EncryptionKeyStorage');
1089
-	}
1090
-
1091
-	/**
1092
-	 * The current request object holding all information about the request
1093
-	 * currently being processed is returned from this method.
1094
-	 * In case the current execution was not initiated by a web request null is returned
1095
-	 *
1096
-	 * @return \OCP\IRequest
1097
-	 */
1098
-	public function getRequest() {
1099
-		return $this->query('Request');
1100
-	}
1101
-
1102
-	/**
1103
-	 * Returns the preview manager which can create preview images for a given file
1104
-	 *
1105
-	 * @return \OCP\IPreview
1106
-	 */
1107
-	public function getPreviewManager() {
1108
-		return $this->query('PreviewManager');
1109
-	}
1110
-
1111
-	/**
1112
-	 * Returns the tag manager which can get and set tags for different object types
1113
-	 *
1114
-	 * @see \OCP\ITagManager::load()
1115
-	 * @return \OCP\ITagManager
1116
-	 */
1117
-	public function getTagManager() {
1118
-		return $this->query('TagManager');
1119
-	}
1120
-
1121
-	/**
1122
-	 * Returns the system-tag manager
1123
-	 *
1124
-	 * @return \OCP\SystemTag\ISystemTagManager
1125
-	 *
1126
-	 * @since 9.0.0
1127
-	 */
1128
-	public function getSystemTagManager() {
1129
-		return $this->query('SystemTagManager');
1130
-	}
1131
-
1132
-	/**
1133
-	 * Returns the system-tag object mapper
1134
-	 *
1135
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1136
-	 *
1137
-	 * @since 9.0.0
1138
-	 */
1139
-	public function getSystemTagObjectMapper() {
1140
-		return $this->query('SystemTagObjectMapper');
1141
-	}
1142
-
1143
-	/**
1144
-	 * Returns the avatar manager, used for avatar functionality
1145
-	 *
1146
-	 * @return \OCP\IAvatarManager
1147
-	 */
1148
-	public function getAvatarManager() {
1149
-		return $this->query('AvatarManager');
1150
-	}
1151
-
1152
-	/**
1153
-	 * Returns the root folder of ownCloud's data directory
1154
-	 *
1155
-	 * @return \OCP\Files\IRootFolder
1156
-	 */
1157
-	public function getRootFolder() {
1158
-		return $this->query('LazyRootFolder');
1159
-	}
1160
-
1161
-	/**
1162
-	 * Returns the root folder of ownCloud's data directory
1163
-	 * This is the lazy variant so this gets only initialized once it
1164
-	 * is actually used.
1165
-	 *
1166
-	 * @return \OCP\Files\IRootFolder
1167
-	 */
1168
-	public function getLazyRootFolder() {
1169
-		return $this->query('LazyRootFolder');
1170
-	}
1171
-
1172
-	/**
1173
-	 * Returns a view to ownCloud's files folder
1174
-	 *
1175
-	 * @param string $userId user ID
1176
-	 * @return \OCP\Files\Folder|null
1177
-	 */
1178
-	public function getUserFolder($userId = null) {
1179
-		if ($userId === null) {
1180
-			$user = $this->getUserSession()->getUser();
1181
-			if (!$user) {
1182
-				return null;
1183
-			}
1184
-			$userId = $user->getUID();
1185
-		}
1186
-		$root = $this->getRootFolder();
1187
-		return $root->getUserFolder($userId);
1188
-	}
1189
-
1190
-	/**
1191
-	 * Returns an app-specific view in ownClouds data directory
1192
-	 *
1193
-	 * @return \OCP\Files\Folder
1194
-	 * @deprecated since 9.2.0 use IAppData
1195
-	 */
1196
-	public function getAppFolder() {
1197
-		$dir = '/' . \OC_App::getCurrentApp();
1198
-		$root = $this->getRootFolder();
1199
-		if (!$root->nodeExists($dir)) {
1200
-			$folder = $root->newFolder($dir);
1201
-		} else {
1202
-			$folder = $root->get($dir);
1203
-		}
1204
-		return $folder;
1205
-	}
1206
-
1207
-	/**
1208
-	 * @return \OC\User\Manager
1209
-	 */
1210
-	public function getUserManager() {
1211
-		return $this->query('UserManager');
1212
-	}
1213
-
1214
-	/**
1215
-	 * @return \OC\Group\Manager
1216
-	 */
1217
-	public function getGroupManager() {
1218
-		return $this->query('GroupManager');
1219
-	}
1220
-
1221
-	/**
1222
-	 * @return \OC\User\Session
1223
-	 */
1224
-	public function getUserSession() {
1225
-		return $this->query('UserSession');
1226
-	}
1227
-
1228
-	/**
1229
-	 * @return \OCP\ISession
1230
-	 */
1231
-	public function getSession() {
1232
-		return $this->query('UserSession')->getSession();
1233
-	}
1234
-
1235
-	/**
1236
-	 * @param \OCP\ISession $session
1237
-	 */
1238
-	public function setSession(\OCP\ISession $session) {
1239
-		$this->query(SessionStorage::class)->setSession($session);
1240
-		$this->query('UserSession')->setSession($session);
1241
-		$this->query(Store::class)->setSession($session);
1242
-	}
1243
-
1244
-	/**
1245
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1246
-	 */
1247
-	public function getTwoFactorAuthManager() {
1248
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1249
-	}
1250
-
1251
-	/**
1252
-	 * @return \OC\NavigationManager
1253
-	 */
1254
-	public function getNavigationManager() {
1255
-		return $this->query('NavigationManager');
1256
-	}
1257
-
1258
-	/**
1259
-	 * @return \OCP\IConfig
1260
-	 */
1261
-	public function getConfig() {
1262
-		return $this->query('AllConfig');
1263
-	}
1264
-
1265
-	/**
1266
-	 * @return \OC\SystemConfig
1267
-	 */
1268
-	public function getSystemConfig() {
1269
-		return $this->query('SystemConfig');
1270
-	}
1271
-
1272
-	/**
1273
-	 * Returns the app config manager
1274
-	 *
1275
-	 * @return \OCP\IAppConfig
1276
-	 */
1277
-	public function getAppConfig() {
1278
-		return $this->query('AppConfig');
1279
-	}
1280
-
1281
-	/**
1282
-	 * @return \OCP\L10N\IFactory
1283
-	 */
1284
-	public function getL10NFactory() {
1285
-		return $this->query('L10NFactory');
1286
-	}
1287
-
1288
-	/**
1289
-	 * get an L10N instance
1290
-	 *
1291
-	 * @param string $app appid
1292
-	 * @param string $lang
1293
-	 * @return IL10N
1294
-	 */
1295
-	public function getL10N($app, $lang = null) {
1296
-		return $this->getL10NFactory()->get($app, $lang);
1297
-	}
1298
-
1299
-	/**
1300
-	 * @return \OCP\IURLGenerator
1301
-	 */
1302
-	public function getURLGenerator() {
1303
-		return $this->query('URLGenerator');
1304
-	}
1305
-
1306
-	/**
1307
-	 * @return \OCP\IHelper
1308
-	 */
1309
-	public function getHelper() {
1310
-		return $this->query('AppHelper');
1311
-	}
1312
-
1313
-	/**
1314
-	 * @return AppFetcher
1315
-	 */
1316
-	public function getAppFetcher() {
1317
-		return $this->query(AppFetcher::class);
1318
-	}
1319
-
1320
-	/**
1321
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1322
-	 * getMemCacheFactory() instead.
1323
-	 *
1324
-	 * @return \OCP\ICache
1325
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1326
-	 */
1327
-	public function getCache() {
1328
-		return $this->query('UserCache');
1329
-	}
1330
-
1331
-	/**
1332
-	 * Returns an \OCP\CacheFactory instance
1333
-	 *
1334
-	 * @return \OCP\ICacheFactory
1335
-	 */
1336
-	public function getMemCacheFactory() {
1337
-		return $this->query('MemCacheFactory');
1338
-	}
1339
-
1340
-	/**
1341
-	 * Returns an \OC\RedisFactory instance
1342
-	 *
1343
-	 * @return \OC\RedisFactory
1344
-	 */
1345
-	public function getGetRedisFactory() {
1346
-		return $this->query('RedisFactory');
1347
-	}
1348
-
1349
-
1350
-	/**
1351
-	 * Returns the current session
1352
-	 *
1353
-	 * @return \OCP\IDBConnection
1354
-	 */
1355
-	public function getDatabaseConnection() {
1356
-		return $this->query('DatabaseConnection');
1357
-	}
1358
-
1359
-	/**
1360
-	 * Returns the activity manager
1361
-	 *
1362
-	 * @return \OCP\Activity\IManager
1363
-	 */
1364
-	public function getActivityManager() {
1365
-		return $this->query('ActivityManager');
1366
-	}
1367
-
1368
-	/**
1369
-	 * Returns an job list for controlling background jobs
1370
-	 *
1371
-	 * @return \OCP\BackgroundJob\IJobList
1372
-	 */
1373
-	public function getJobList() {
1374
-		return $this->query('JobList');
1375
-	}
1376
-
1377
-	/**
1378
-	 * Returns a logger instance
1379
-	 *
1380
-	 * @return \OCP\ILogger
1381
-	 */
1382
-	public function getLogger() {
1383
-		return $this->query('Logger');
1384
-	}
1385
-
1386
-	/**
1387
-	 * Returns a router for generating and matching urls
1388
-	 *
1389
-	 * @return \OCP\Route\IRouter
1390
-	 */
1391
-	public function getRouter() {
1392
-		return $this->query('Router');
1393
-	}
1394
-
1395
-	/**
1396
-	 * Returns a search instance
1397
-	 *
1398
-	 * @return \OCP\ISearch
1399
-	 */
1400
-	public function getSearch() {
1401
-		return $this->query('Search');
1402
-	}
1403
-
1404
-	/**
1405
-	 * Returns a SecureRandom instance
1406
-	 *
1407
-	 * @return \OCP\Security\ISecureRandom
1408
-	 */
1409
-	public function getSecureRandom() {
1410
-		return $this->query('SecureRandom');
1411
-	}
1412
-
1413
-	/**
1414
-	 * Returns a Crypto instance
1415
-	 *
1416
-	 * @return \OCP\Security\ICrypto
1417
-	 */
1418
-	public function getCrypto() {
1419
-		return $this->query('Crypto');
1420
-	}
1421
-
1422
-	/**
1423
-	 * Returns a Hasher instance
1424
-	 *
1425
-	 * @return \OCP\Security\IHasher
1426
-	 */
1427
-	public function getHasher() {
1428
-		return $this->query('Hasher');
1429
-	}
1430
-
1431
-	/**
1432
-	 * Returns a CredentialsManager instance
1433
-	 *
1434
-	 * @return \OCP\Security\ICredentialsManager
1435
-	 */
1436
-	public function getCredentialsManager() {
1437
-		return $this->query('CredentialsManager');
1438
-	}
1439
-
1440
-	/**
1441
-	 * Returns an instance of the HTTP helper class
1442
-	 *
1443
-	 * @deprecated Use getHTTPClientService()
1444
-	 * @return \OC\HTTPHelper
1445
-	 */
1446
-	public function getHTTPHelper() {
1447
-		return $this->query('HTTPHelper');
1448
-	}
1449
-
1450
-	/**
1451
-	 * Get the certificate manager for the user
1452
-	 *
1453
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1454
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1455
-	 */
1456
-	public function getCertificateManager($userId = '') {
1457
-		if ($userId === '') {
1458
-			$userSession = $this->getUserSession();
1459
-			$user = $userSession->getUser();
1460
-			if (is_null($user)) {
1461
-				return null;
1462
-			}
1463
-			$userId = $user->getUID();
1464
-		}
1465
-		return new CertificateManager(
1466
-			$userId,
1467
-			new View(),
1468
-			$this->getConfig(),
1469
-			$this->getLogger(),
1470
-			$this->getSecureRandom()
1471
-		);
1472
-	}
1473
-
1474
-	/**
1475
-	 * Returns an instance of the HTTP client service
1476
-	 *
1477
-	 * @return \OCP\Http\Client\IClientService
1478
-	 */
1479
-	public function getHTTPClientService() {
1480
-		return $this->query('HttpClientService');
1481
-	}
1482
-
1483
-	/**
1484
-	 * Create a new event source
1485
-	 *
1486
-	 * @return \OCP\IEventSource
1487
-	 */
1488
-	public function createEventSource() {
1489
-		return new \OC_EventSource();
1490
-	}
1491
-
1492
-	/**
1493
-	 * Get the active event logger
1494
-	 *
1495
-	 * The returned logger only logs data when debug mode is enabled
1496
-	 *
1497
-	 * @return \OCP\Diagnostics\IEventLogger
1498
-	 */
1499
-	public function getEventLogger() {
1500
-		return $this->query('EventLogger');
1501
-	}
1502
-
1503
-	/**
1504
-	 * Get the active query logger
1505
-	 *
1506
-	 * The returned logger only logs data when debug mode is enabled
1507
-	 *
1508
-	 * @return \OCP\Diagnostics\IQueryLogger
1509
-	 */
1510
-	public function getQueryLogger() {
1511
-		return $this->query('QueryLogger');
1512
-	}
1513
-
1514
-	/**
1515
-	 * Get the manager for temporary files and folders
1516
-	 *
1517
-	 * @return \OCP\ITempManager
1518
-	 */
1519
-	public function getTempManager() {
1520
-		return $this->query('TempManager');
1521
-	}
1522
-
1523
-	/**
1524
-	 * Get the app manager
1525
-	 *
1526
-	 * @return \OCP\App\IAppManager
1527
-	 */
1528
-	public function getAppManager() {
1529
-		return $this->query('AppManager');
1530
-	}
1531
-
1532
-	/**
1533
-	 * Creates a new mailer
1534
-	 *
1535
-	 * @return \OCP\Mail\IMailer
1536
-	 */
1537
-	public function getMailer() {
1538
-		return $this->query('Mailer');
1539
-	}
1540
-
1541
-	/**
1542
-	 * Get the webroot
1543
-	 *
1544
-	 * @return string
1545
-	 */
1546
-	public function getWebRoot() {
1547
-		return $this->webRoot;
1548
-	}
1549
-
1550
-	/**
1551
-	 * @return \OC\OCSClient
1552
-	 */
1553
-	public function getOcsClient() {
1554
-		return $this->query('OcsClient');
1555
-	}
1556
-
1557
-	/**
1558
-	 * @return \OCP\IDateTimeZone
1559
-	 */
1560
-	public function getDateTimeZone() {
1561
-		return $this->query('DateTimeZone');
1562
-	}
1563
-
1564
-	/**
1565
-	 * @return \OCP\IDateTimeFormatter
1566
-	 */
1567
-	public function getDateTimeFormatter() {
1568
-		return $this->query('DateTimeFormatter');
1569
-	}
1570
-
1571
-	/**
1572
-	 * @return \OCP\Files\Config\IMountProviderCollection
1573
-	 */
1574
-	public function getMountProviderCollection() {
1575
-		return $this->query('MountConfigManager');
1576
-	}
1577
-
1578
-	/**
1579
-	 * Get the IniWrapper
1580
-	 *
1581
-	 * @return IniGetWrapper
1582
-	 */
1583
-	public function getIniWrapper() {
1584
-		return $this->query('IniWrapper');
1585
-	}
1586
-
1587
-	/**
1588
-	 * @return \OCP\Command\IBus
1589
-	 */
1590
-	public function getCommandBus() {
1591
-		return $this->query('AsyncCommandBus');
1592
-	}
1593
-
1594
-	/**
1595
-	 * Get the trusted domain helper
1596
-	 *
1597
-	 * @return TrustedDomainHelper
1598
-	 */
1599
-	public function getTrustedDomainHelper() {
1600
-		return $this->query('TrustedDomainHelper');
1601
-	}
1602
-
1603
-	/**
1604
-	 * Get the locking provider
1605
-	 *
1606
-	 * @return \OCP\Lock\ILockingProvider
1607
-	 * @since 8.1.0
1608
-	 */
1609
-	public function getLockingProvider() {
1610
-		return $this->query('LockingProvider');
1611
-	}
1612
-
1613
-	/**
1614
-	 * @return \OCP\Files\Mount\IMountManager
1615
-	 **/
1616
-	function getMountManager() {
1617
-		return $this->query('MountManager');
1618
-	}
1619
-
1620
-	/** @return \OCP\Files\Config\IUserMountCache */
1621
-	function getUserMountCache() {
1622
-		return $this->query('UserMountCache');
1623
-	}
1624
-
1625
-	/**
1626
-	 * Get the MimeTypeDetector
1627
-	 *
1628
-	 * @return \OCP\Files\IMimeTypeDetector
1629
-	 */
1630
-	public function getMimeTypeDetector() {
1631
-		return $this->query('MimeTypeDetector');
1632
-	}
1633
-
1634
-	/**
1635
-	 * Get the MimeTypeLoader
1636
-	 *
1637
-	 * @return \OCP\Files\IMimeTypeLoader
1638
-	 */
1639
-	public function getMimeTypeLoader() {
1640
-		return $this->query('MimeTypeLoader');
1641
-	}
1642
-
1643
-	/**
1644
-	 * Get the manager of all the capabilities
1645
-	 *
1646
-	 * @return \OC\CapabilitiesManager
1647
-	 */
1648
-	public function getCapabilitiesManager() {
1649
-		return $this->query('CapabilitiesManager');
1650
-	}
1651
-
1652
-	/**
1653
-	 * Get the EventDispatcher
1654
-	 *
1655
-	 * @return EventDispatcherInterface
1656
-	 * @since 8.2.0
1657
-	 */
1658
-	public function getEventDispatcher() {
1659
-		return $this->query('EventDispatcher');
1660
-	}
1661
-
1662
-	/**
1663
-	 * Get the Notification Manager
1664
-	 *
1665
-	 * @return \OCP\Notification\IManager
1666
-	 * @since 8.2.0
1667
-	 */
1668
-	public function getNotificationManager() {
1669
-		return $this->query('NotificationManager');
1670
-	}
1671
-
1672
-	/**
1673
-	 * @return \OCP\Comments\ICommentsManager
1674
-	 */
1675
-	public function getCommentsManager() {
1676
-		return $this->query('CommentsManager');
1677
-	}
1678
-
1679
-	/**
1680
-	 * @return \OCA\Theming\ThemingDefaults
1681
-	 */
1682
-	public function getThemingDefaults() {
1683
-		return $this->query('ThemingDefaults');
1684
-	}
1685
-
1686
-	/**
1687
-	 * @return \OC\IntegrityCheck\Checker
1688
-	 */
1689
-	public function getIntegrityCodeChecker() {
1690
-		return $this->query('IntegrityCodeChecker');
1691
-	}
1692
-
1693
-	/**
1694
-	 * @return \OC\Session\CryptoWrapper
1695
-	 */
1696
-	public function getSessionCryptoWrapper() {
1697
-		return $this->query('CryptoWrapper');
1698
-	}
1699
-
1700
-	/**
1701
-	 * @return CsrfTokenManager
1702
-	 */
1703
-	public function getCsrfTokenManager() {
1704
-		return $this->query('CsrfTokenManager');
1705
-	}
1706
-
1707
-	/**
1708
-	 * @return Throttler
1709
-	 */
1710
-	public function getBruteForceThrottler() {
1711
-		return $this->query('Throttler');
1712
-	}
1713
-
1714
-	/**
1715
-	 * @return IContentSecurityPolicyManager
1716
-	 */
1717
-	public function getContentSecurityPolicyManager() {
1718
-		return $this->query('ContentSecurityPolicyManager');
1719
-	}
1720
-
1721
-	/**
1722
-	 * @return ContentSecurityPolicyNonceManager
1723
-	 */
1724
-	public function getContentSecurityPolicyNonceManager() {
1725
-		return $this->query('ContentSecurityPolicyNonceManager');
1726
-	}
1727
-
1728
-	/**
1729
-	 * Not a public API as of 8.2, wait for 9.0
1730
-	 *
1731
-	 * @return \OCA\Files_External\Service\BackendService
1732
-	 */
1733
-	public function getStoragesBackendService() {
1734
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1735
-	}
1736
-
1737
-	/**
1738
-	 * Not a public API as of 8.2, wait for 9.0
1739
-	 *
1740
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1741
-	 */
1742
-	public function getGlobalStoragesService() {
1743
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1744
-	}
1745
-
1746
-	/**
1747
-	 * Not a public API as of 8.2, wait for 9.0
1748
-	 *
1749
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1750
-	 */
1751
-	public function getUserGlobalStoragesService() {
1752
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1753
-	}
1754
-
1755
-	/**
1756
-	 * Not a public API as of 8.2, wait for 9.0
1757
-	 *
1758
-	 * @return \OCA\Files_External\Service\UserStoragesService
1759
-	 */
1760
-	public function getUserStoragesService() {
1761
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1762
-	}
1763
-
1764
-	/**
1765
-	 * @return \OCP\Share\IManager
1766
-	 */
1767
-	public function getShareManager() {
1768
-		return $this->query('ShareManager');
1769
-	}
1770
-
1771
-	/**
1772
-	 * Returns the LDAP Provider
1773
-	 *
1774
-	 * @return \OCP\LDAP\ILDAPProvider
1775
-	 */
1776
-	public function getLDAPProvider() {
1777
-		return $this->query('LDAPProvider');
1778
-	}
1779
-
1780
-	/**
1781
-	 * @return \OCP\Settings\IManager
1782
-	 */
1783
-	public function getSettingsManager() {
1784
-		return $this->query('SettingsManager');
1785
-	}
1786
-
1787
-	/**
1788
-	 * @return \OCP\Files\IAppData
1789
-	 */
1790
-	public function getAppDataDir($app) {
1791
-		/** @var \OC\Files\AppData\Factory $factory */
1792
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1793
-		return $factory->get($app);
1794
-	}
1795
-
1796
-	/**
1797
-	 * @return \OCP\Lockdown\ILockdownManager
1798
-	 */
1799
-	public function getLockdownManager() {
1800
-		return $this->query('LockdownManager');
1801
-	}
1802
-
1803
-	/**
1804
-	 * @return \OCP\Federation\ICloudIdManager
1805
-	 */
1806
-	public function getCloudIdManager() {
1807
-		return $this->query(ICloudIdManager::class);
1808
-	}
875
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
876
+            if (isset($prefixes['OCA\\Theming\\'])) {
877
+                $classExists = true;
878
+            } else {
879
+                $classExists = false;
880
+            }
881
+
882
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
883
+                return new ThemingDefaults(
884
+                    $c->getConfig(),
885
+                    $c->getL10N('theming'),
886
+                    $c->getURLGenerator(),
887
+                    $c->getAppDataDir('theming'),
888
+                    $c->getMemCacheFactory(),
889
+                    new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming'))
890
+                );
891
+            }
892
+            return new \OC_Defaults();
893
+        });
894
+        $this->registerService(SCSSCacher::class, function (Server $c) {
895
+            /** @var Factory $cacheFactory */
896
+            $cacheFactory = $c->query(Factory::class);
897
+            return new SCSSCacher(
898
+                $c->getLogger(),
899
+                $c->query(\OC\Files\AppData\Factory::class),
900
+                $c->getURLGenerator(),
901
+                $c->getConfig(),
902
+                $c->getThemingDefaults(),
903
+                \OC::$SERVERROOT,
904
+                $cacheFactory->create('SCSS')
905
+            );
906
+        });
907
+        $this->registerService(EventDispatcher::class, function () {
908
+            return new EventDispatcher();
909
+        });
910
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
911
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
912
+
913
+        $this->registerService('CryptoWrapper', function (Server $c) {
914
+            // FIXME: Instantiiated here due to cyclic dependency
915
+            $request = new Request(
916
+                [
917
+                    'get' => $_GET,
918
+                    'post' => $_POST,
919
+                    'files' => $_FILES,
920
+                    'server' => $_SERVER,
921
+                    'env' => $_ENV,
922
+                    'cookies' => $_COOKIE,
923
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
924
+                        ? $_SERVER['REQUEST_METHOD']
925
+                        : null,
926
+                ],
927
+                $c->getSecureRandom(),
928
+                $c->getConfig()
929
+            );
930
+
931
+            return new CryptoWrapper(
932
+                $c->getConfig(),
933
+                $c->getCrypto(),
934
+                $c->getSecureRandom(),
935
+                $request
936
+            );
937
+        });
938
+        $this->registerService('CsrfTokenManager', function (Server $c) {
939
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
940
+
941
+            return new CsrfTokenManager(
942
+                $tokenGenerator,
943
+                $c->query(SessionStorage::class)
944
+            );
945
+        });
946
+        $this->registerService(SessionStorage::class, function (Server $c) {
947
+            return new SessionStorage($c->getSession());
948
+        });
949
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
950
+            return new ContentSecurityPolicyManager();
951
+        });
952
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
953
+
954
+        $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
955
+            return new ContentSecurityPolicyNonceManager(
956
+                $c->getCsrfTokenManager(),
957
+                $c->getRequest()
958
+            );
959
+        });
960
+
961
+        $this->registerService(\OCP\Share\IManager::class, function (Server $c) {
962
+            $config = $c->getConfig();
963
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
964
+            /** @var \OCP\Share\IProviderFactory $factory */
965
+            $factory = new $factoryClass($this);
966
+
967
+            $manager = new \OC\Share20\Manager(
968
+                $c->getLogger(),
969
+                $c->getConfig(),
970
+                $c->getSecureRandom(),
971
+                $c->getHasher(),
972
+                $c->getMountManager(),
973
+                $c->getGroupManager(),
974
+                $c->getL10N('core'),
975
+                $factory,
976
+                $c->getUserManager(),
977
+                $c->getLazyRootFolder(),
978
+                $c->getEventDispatcher(),
979
+                $c->getMailer(),
980
+                $c->getURLGenerator(),
981
+                $c->getThemingDefaults()
982
+            );
983
+
984
+            return $manager;
985
+        });
986
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
987
+
988
+        $this->registerService('SettingsManager', function (Server $c) {
989
+            $manager = new \OC\Settings\Manager(
990
+                $c->getLogger(),
991
+                $c->getDatabaseConnection(),
992
+                $c->getL10N('lib'),
993
+                $c->getConfig(),
994
+                $c->getEncryptionManager(),
995
+                $c->getUserManager(),
996
+                $c->getLockingProvider(),
997
+                $c->getRequest(),
998
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
999
+                $c->getURLGenerator(),
1000
+                $c->query(AccountManager::class),
1001
+                $c->getGroupManager(),
1002
+                $c->getL10NFactory(),
1003
+                $c->getThemingDefaults(),
1004
+                $c->getAppManager()
1005
+            );
1006
+            return $manager;
1007
+        });
1008
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1009
+            return new \OC\Files\AppData\Factory(
1010
+                $c->getRootFolder(),
1011
+                $c->getSystemConfig()
1012
+            );
1013
+        });
1014
+
1015
+        $this->registerService('LockdownManager', function (Server $c) {
1016
+            return new LockdownManager(function () use ($c) {
1017
+                return $c->getSession();
1018
+            });
1019
+        });
1020
+
1021
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1022
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1023
+        });
1024
+
1025
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
1026
+            return new CloudIdManager();
1027
+        });
1028
+
1029
+        /* To trick DI since we don't extend the DIContainer here */
1030
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1031
+            return new CleanPreviewsBackgroundJob(
1032
+                $c->getRootFolder(),
1033
+                $c->getLogger(),
1034
+                $c->getJobList(),
1035
+                new TimeFactory()
1036
+            );
1037
+        });
1038
+
1039
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1040
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1041
+
1042
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1043
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1044
+
1045
+        $this->registerService(Defaults::class, function (Server $c) {
1046
+            return new Defaults(
1047
+                $c->getThemingDefaults()
1048
+            );
1049
+        });
1050
+        $this->registerAlias('Defaults', \OCP\Defaults::class);
1051
+
1052
+        $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1053
+            return $c->query(\OCP\IUserSession::class)->getSession();
1054
+        });
1055
+
1056
+        $this->registerService(IShareHelper::class, function (Server $c) {
1057
+            return new ShareHelper(
1058
+                $c->query(\OCP\Share\IManager::class)
1059
+            );
1060
+        });
1061
+    }
1062
+
1063
+    /**
1064
+     * @return \OCP\Contacts\IManager
1065
+     */
1066
+    public function getContactsManager() {
1067
+        return $this->query('ContactsManager');
1068
+    }
1069
+
1070
+    /**
1071
+     * @return \OC\Encryption\Manager
1072
+     */
1073
+    public function getEncryptionManager() {
1074
+        return $this->query('EncryptionManager');
1075
+    }
1076
+
1077
+    /**
1078
+     * @return \OC\Encryption\File
1079
+     */
1080
+    public function getEncryptionFilesHelper() {
1081
+        return $this->query('EncryptionFileHelper');
1082
+    }
1083
+
1084
+    /**
1085
+     * @return \OCP\Encryption\Keys\IStorage
1086
+     */
1087
+    public function getEncryptionKeyStorage() {
1088
+        return $this->query('EncryptionKeyStorage');
1089
+    }
1090
+
1091
+    /**
1092
+     * The current request object holding all information about the request
1093
+     * currently being processed is returned from this method.
1094
+     * In case the current execution was not initiated by a web request null is returned
1095
+     *
1096
+     * @return \OCP\IRequest
1097
+     */
1098
+    public function getRequest() {
1099
+        return $this->query('Request');
1100
+    }
1101
+
1102
+    /**
1103
+     * Returns the preview manager which can create preview images for a given file
1104
+     *
1105
+     * @return \OCP\IPreview
1106
+     */
1107
+    public function getPreviewManager() {
1108
+        return $this->query('PreviewManager');
1109
+    }
1110
+
1111
+    /**
1112
+     * Returns the tag manager which can get and set tags for different object types
1113
+     *
1114
+     * @see \OCP\ITagManager::load()
1115
+     * @return \OCP\ITagManager
1116
+     */
1117
+    public function getTagManager() {
1118
+        return $this->query('TagManager');
1119
+    }
1120
+
1121
+    /**
1122
+     * Returns the system-tag manager
1123
+     *
1124
+     * @return \OCP\SystemTag\ISystemTagManager
1125
+     *
1126
+     * @since 9.0.0
1127
+     */
1128
+    public function getSystemTagManager() {
1129
+        return $this->query('SystemTagManager');
1130
+    }
1131
+
1132
+    /**
1133
+     * Returns the system-tag object mapper
1134
+     *
1135
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1136
+     *
1137
+     * @since 9.0.0
1138
+     */
1139
+    public function getSystemTagObjectMapper() {
1140
+        return $this->query('SystemTagObjectMapper');
1141
+    }
1142
+
1143
+    /**
1144
+     * Returns the avatar manager, used for avatar functionality
1145
+     *
1146
+     * @return \OCP\IAvatarManager
1147
+     */
1148
+    public function getAvatarManager() {
1149
+        return $this->query('AvatarManager');
1150
+    }
1151
+
1152
+    /**
1153
+     * Returns the root folder of ownCloud's data directory
1154
+     *
1155
+     * @return \OCP\Files\IRootFolder
1156
+     */
1157
+    public function getRootFolder() {
1158
+        return $this->query('LazyRootFolder');
1159
+    }
1160
+
1161
+    /**
1162
+     * Returns the root folder of ownCloud's data directory
1163
+     * This is the lazy variant so this gets only initialized once it
1164
+     * is actually used.
1165
+     *
1166
+     * @return \OCP\Files\IRootFolder
1167
+     */
1168
+    public function getLazyRootFolder() {
1169
+        return $this->query('LazyRootFolder');
1170
+    }
1171
+
1172
+    /**
1173
+     * Returns a view to ownCloud's files folder
1174
+     *
1175
+     * @param string $userId user ID
1176
+     * @return \OCP\Files\Folder|null
1177
+     */
1178
+    public function getUserFolder($userId = null) {
1179
+        if ($userId === null) {
1180
+            $user = $this->getUserSession()->getUser();
1181
+            if (!$user) {
1182
+                return null;
1183
+            }
1184
+            $userId = $user->getUID();
1185
+        }
1186
+        $root = $this->getRootFolder();
1187
+        return $root->getUserFolder($userId);
1188
+    }
1189
+
1190
+    /**
1191
+     * Returns an app-specific view in ownClouds data directory
1192
+     *
1193
+     * @return \OCP\Files\Folder
1194
+     * @deprecated since 9.2.0 use IAppData
1195
+     */
1196
+    public function getAppFolder() {
1197
+        $dir = '/' . \OC_App::getCurrentApp();
1198
+        $root = $this->getRootFolder();
1199
+        if (!$root->nodeExists($dir)) {
1200
+            $folder = $root->newFolder($dir);
1201
+        } else {
1202
+            $folder = $root->get($dir);
1203
+        }
1204
+        return $folder;
1205
+    }
1206
+
1207
+    /**
1208
+     * @return \OC\User\Manager
1209
+     */
1210
+    public function getUserManager() {
1211
+        return $this->query('UserManager');
1212
+    }
1213
+
1214
+    /**
1215
+     * @return \OC\Group\Manager
1216
+     */
1217
+    public function getGroupManager() {
1218
+        return $this->query('GroupManager');
1219
+    }
1220
+
1221
+    /**
1222
+     * @return \OC\User\Session
1223
+     */
1224
+    public function getUserSession() {
1225
+        return $this->query('UserSession');
1226
+    }
1227
+
1228
+    /**
1229
+     * @return \OCP\ISession
1230
+     */
1231
+    public function getSession() {
1232
+        return $this->query('UserSession')->getSession();
1233
+    }
1234
+
1235
+    /**
1236
+     * @param \OCP\ISession $session
1237
+     */
1238
+    public function setSession(\OCP\ISession $session) {
1239
+        $this->query(SessionStorage::class)->setSession($session);
1240
+        $this->query('UserSession')->setSession($session);
1241
+        $this->query(Store::class)->setSession($session);
1242
+    }
1243
+
1244
+    /**
1245
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1246
+     */
1247
+    public function getTwoFactorAuthManager() {
1248
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1249
+    }
1250
+
1251
+    /**
1252
+     * @return \OC\NavigationManager
1253
+     */
1254
+    public function getNavigationManager() {
1255
+        return $this->query('NavigationManager');
1256
+    }
1257
+
1258
+    /**
1259
+     * @return \OCP\IConfig
1260
+     */
1261
+    public function getConfig() {
1262
+        return $this->query('AllConfig');
1263
+    }
1264
+
1265
+    /**
1266
+     * @return \OC\SystemConfig
1267
+     */
1268
+    public function getSystemConfig() {
1269
+        return $this->query('SystemConfig');
1270
+    }
1271
+
1272
+    /**
1273
+     * Returns the app config manager
1274
+     *
1275
+     * @return \OCP\IAppConfig
1276
+     */
1277
+    public function getAppConfig() {
1278
+        return $this->query('AppConfig');
1279
+    }
1280
+
1281
+    /**
1282
+     * @return \OCP\L10N\IFactory
1283
+     */
1284
+    public function getL10NFactory() {
1285
+        return $this->query('L10NFactory');
1286
+    }
1287
+
1288
+    /**
1289
+     * get an L10N instance
1290
+     *
1291
+     * @param string $app appid
1292
+     * @param string $lang
1293
+     * @return IL10N
1294
+     */
1295
+    public function getL10N($app, $lang = null) {
1296
+        return $this->getL10NFactory()->get($app, $lang);
1297
+    }
1298
+
1299
+    /**
1300
+     * @return \OCP\IURLGenerator
1301
+     */
1302
+    public function getURLGenerator() {
1303
+        return $this->query('URLGenerator');
1304
+    }
1305
+
1306
+    /**
1307
+     * @return \OCP\IHelper
1308
+     */
1309
+    public function getHelper() {
1310
+        return $this->query('AppHelper');
1311
+    }
1312
+
1313
+    /**
1314
+     * @return AppFetcher
1315
+     */
1316
+    public function getAppFetcher() {
1317
+        return $this->query(AppFetcher::class);
1318
+    }
1319
+
1320
+    /**
1321
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1322
+     * getMemCacheFactory() instead.
1323
+     *
1324
+     * @return \OCP\ICache
1325
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1326
+     */
1327
+    public function getCache() {
1328
+        return $this->query('UserCache');
1329
+    }
1330
+
1331
+    /**
1332
+     * Returns an \OCP\CacheFactory instance
1333
+     *
1334
+     * @return \OCP\ICacheFactory
1335
+     */
1336
+    public function getMemCacheFactory() {
1337
+        return $this->query('MemCacheFactory');
1338
+    }
1339
+
1340
+    /**
1341
+     * Returns an \OC\RedisFactory instance
1342
+     *
1343
+     * @return \OC\RedisFactory
1344
+     */
1345
+    public function getGetRedisFactory() {
1346
+        return $this->query('RedisFactory');
1347
+    }
1348
+
1349
+
1350
+    /**
1351
+     * Returns the current session
1352
+     *
1353
+     * @return \OCP\IDBConnection
1354
+     */
1355
+    public function getDatabaseConnection() {
1356
+        return $this->query('DatabaseConnection');
1357
+    }
1358
+
1359
+    /**
1360
+     * Returns the activity manager
1361
+     *
1362
+     * @return \OCP\Activity\IManager
1363
+     */
1364
+    public function getActivityManager() {
1365
+        return $this->query('ActivityManager');
1366
+    }
1367
+
1368
+    /**
1369
+     * Returns an job list for controlling background jobs
1370
+     *
1371
+     * @return \OCP\BackgroundJob\IJobList
1372
+     */
1373
+    public function getJobList() {
1374
+        return $this->query('JobList');
1375
+    }
1376
+
1377
+    /**
1378
+     * Returns a logger instance
1379
+     *
1380
+     * @return \OCP\ILogger
1381
+     */
1382
+    public function getLogger() {
1383
+        return $this->query('Logger');
1384
+    }
1385
+
1386
+    /**
1387
+     * Returns a router for generating and matching urls
1388
+     *
1389
+     * @return \OCP\Route\IRouter
1390
+     */
1391
+    public function getRouter() {
1392
+        return $this->query('Router');
1393
+    }
1394
+
1395
+    /**
1396
+     * Returns a search instance
1397
+     *
1398
+     * @return \OCP\ISearch
1399
+     */
1400
+    public function getSearch() {
1401
+        return $this->query('Search');
1402
+    }
1403
+
1404
+    /**
1405
+     * Returns a SecureRandom instance
1406
+     *
1407
+     * @return \OCP\Security\ISecureRandom
1408
+     */
1409
+    public function getSecureRandom() {
1410
+        return $this->query('SecureRandom');
1411
+    }
1412
+
1413
+    /**
1414
+     * Returns a Crypto instance
1415
+     *
1416
+     * @return \OCP\Security\ICrypto
1417
+     */
1418
+    public function getCrypto() {
1419
+        return $this->query('Crypto');
1420
+    }
1421
+
1422
+    /**
1423
+     * Returns a Hasher instance
1424
+     *
1425
+     * @return \OCP\Security\IHasher
1426
+     */
1427
+    public function getHasher() {
1428
+        return $this->query('Hasher');
1429
+    }
1430
+
1431
+    /**
1432
+     * Returns a CredentialsManager instance
1433
+     *
1434
+     * @return \OCP\Security\ICredentialsManager
1435
+     */
1436
+    public function getCredentialsManager() {
1437
+        return $this->query('CredentialsManager');
1438
+    }
1439
+
1440
+    /**
1441
+     * Returns an instance of the HTTP helper class
1442
+     *
1443
+     * @deprecated Use getHTTPClientService()
1444
+     * @return \OC\HTTPHelper
1445
+     */
1446
+    public function getHTTPHelper() {
1447
+        return $this->query('HTTPHelper');
1448
+    }
1449
+
1450
+    /**
1451
+     * Get the certificate manager for the user
1452
+     *
1453
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1454
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1455
+     */
1456
+    public function getCertificateManager($userId = '') {
1457
+        if ($userId === '') {
1458
+            $userSession = $this->getUserSession();
1459
+            $user = $userSession->getUser();
1460
+            if (is_null($user)) {
1461
+                return null;
1462
+            }
1463
+            $userId = $user->getUID();
1464
+        }
1465
+        return new CertificateManager(
1466
+            $userId,
1467
+            new View(),
1468
+            $this->getConfig(),
1469
+            $this->getLogger(),
1470
+            $this->getSecureRandom()
1471
+        );
1472
+    }
1473
+
1474
+    /**
1475
+     * Returns an instance of the HTTP client service
1476
+     *
1477
+     * @return \OCP\Http\Client\IClientService
1478
+     */
1479
+    public function getHTTPClientService() {
1480
+        return $this->query('HttpClientService');
1481
+    }
1482
+
1483
+    /**
1484
+     * Create a new event source
1485
+     *
1486
+     * @return \OCP\IEventSource
1487
+     */
1488
+    public function createEventSource() {
1489
+        return new \OC_EventSource();
1490
+    }
1491
+
1492
+    /**
1493
+     * Get the active event logger
1494
+     *
1495
+     * The returned logger only logs data when debug mode is enabled
1496
+     *
1497
+     * @return \OCP\Diagnostics\IEventLogger
1498
+     */
1499
+    public function getEventLogger() {
1500
+        return $this->query('EventLogger');
1501
+    }
1502
+
1503
+    /**
1504
+     * Get the active query logger
1505
+     *
1506
+     * The returned logger only logs data when debug mode is enabled
1507
+     *
1508
+     * @return \OCP\Diagnostics\IQueryLogger
1509
+     */
1510
+    public function getQueryLogger() {
1511
+        return $this->query('QueryLogger');
1512
+    }
1513
+
1514
+    /**
1515
+     * Get the manager for temporary files and folders
1516
+     *
1517
+     * @return \OCP\ITempManager
1518
+     */
1519
+    public function getTempManager() {
1520
+        return $this->query('TempManager');
1521
+    }
1522
+
1523
+    /**
1524
+     * Get the app manager
1525
+     *
1526
+     * @return \OCP\App\IAppManager
1527
+     */
1528
+    public function getAppManager() {
1529
+        return $this->query('AppManager');
1530
+    }
1531
+
1532
+    /**
1533
+     * Creates a new mailer
1534
+     *
1535
+     * @return \OCP\Mail\IMailer
1536
+     */
1537
+    public function getMailer() {
1538
+        return $this->query('Mailer');
1539
+    }
1540
+
1541
+    /**
1542
+     * Get the webroot
1543
+     *
1544
+     * @return string
1545
+     */
1546
+    public function getWebRoot() {
1547
+        return $this->webRoot;
1548
+    }
1549
+
1550
+    /**
1551
+     * @return \OC\OCSClient
1552
+     */
1553
+    public function getOcsClient() {
1554
+        return $this->query('OcsClient');
1555
+    }
1556
+
1557
+    /**
1558
+     * @return \OCP\IDateTimeZone
1559
+     */
1560
+    public function getDateTimeZone() {
1561
+        return $this->query('DateTimeZone');
1562
+    }
1563
+
1564
+    /**
1565
+     * @return \OCP\IDateTimeFormatter
1566
+     */
1567
+    public function getDateTimeFormatter() {
1568
+        return $this->query('DateTimeFormatter');
1569
+    }
1570
+
1571
+    /**
1572
+     * @return \OCP\Files\Config\IMountProviderCollection
1573
+     */
1574
+    public function getMountProviderCollection() {
1575
+        return $this->query('MountConfigManager');
1576
+    }
1577
+
1578
+    /**
1579
+     * Get the IniWrapper
1580
+     *
1581
+     * @return IniGetWrapper
1582
+     */
1583
+    public function getIniWrapper() {
1584
+        return $this->query('IniWrapper');
1585
+    }
1586
+
1587
+    /**
1588
+     * @return \OCP\Command\IBus
1589
+     */
1590
+    public function getCommandBus() {
1591
+        return $this->query('AsyncCommandBus');
1592
+    }
1593
+
1594
+    /**
1595
+     * Get the trusted domain helper
1596
+     *
1597
+     * @return TrustedDomainHelper
1598
+     */
1599
+    public function getTrustedDomainHelper() {
1600
+        return $this->query('TrustedDomainHelper');
1601
+    }
1602
+
1603
+    /**
1604
+     * Get the locking provider
1605
+     *
1606
+     * @return \OCP\Lock\ILockingProvider
1607
+     * @since 8.1.0
1608
+     */
1609
+    public function getLockingProvider() {
1610
+        return $this->query('LockingProvider');
1611
+    }
1612
+
1613
+    /**
1614
+     * @return \OCP\Files\Mount\IMountManager
1615
+     **/
1616
+    function getMountManager() {
1617
+        return $this->query('MountManager');
1618
+    }
1619
+
1620
+    /** @return \OCP\Files\Config\IUserMountCache */
1621
+    function getUserMountCache() {
1622
+        return $this->query('UserMountCache');
1623
+    }
1624
+
1625
+    /**
1626
+     * Get the MimeTypeDetector
1627
+     *
1628
+     * @return \OCP\Files\IMimeTypeDetector
1629
+     */
1630
+    public function getMimeTypeDetector() {
1631
+        return $this->query('MimeTypeDetector');
1632
+    }
1633
+
1634
+    /**
1635
+     * Get the MimeTypeLoader
1636
+     *
1637
+     * @return \OCP\Files\IMimeTypeLoader
1638
+     */
1639
+    public function getMimeTypeLoader() {
1640
+        return $this->query('MimeTypeLoader');
1641
+    }
1642
+
1643
+    /**
1644
+     * Get the manager of all the capabilities
1645
+     *
1646
+     * @return \OC\CapabilitiesManager
1647
+     */
1648
+    public function getCapabilitiesManager() {
1649
+        return $this->query('CapabilitiesManager');
1650
+    }
1651
+
1652
+    /**
1653
+     * Get the EventDispatcher
1654
+     *
1655
+     * @return EventDispatcherInterface
1656
+     * @since 8.2.0
1657
+     */
1658
+    public function getEventDispatcher() {
1659
+        return $this->query('EventDispatcher');
1660
+    }
1661
+
1662
+    /**
1663
+     * Get the Notification Manager
1664
+     *
1665
+     * @return \OCP\Notification\IManager
1666
+     * @since 8.2.0
1667
+     */
1668
+    public function getNotificationManager() {
1669
+        return $this->query('NotificationManager');
1670
+    }
1671
+
1672
+    /**
1673
+     * @return \OCP\Comments\ICommentsManager
1674
+     */
1675
+    public function getCommentsManager() {
1676
+        return $this->query('CommentsManager');
1677
+    }
1678
+
1679
+    /**
1680
+     * @return \OCA\Theming\ThemingDefaults
1681
+     */
1682
+    public function getThemingDefaults() {
1683
+        return $this->query('ThemingDefaults');
1684
+    }
1685
+
1686
+    /**
1687
+     * @return \OC\IntegrityCheck\Checker
1688
+     */
1689
+    public function getIntegrityCodeChecker() {
1690
+        return $this->query('IntegrityCodeChecker');
1691
+    }
1692
+
1693
+    /**
1694
+     * @return \OC\Session\CryptoWrapper
1695
+     */
1696
+    public function getSessionCryptoWrapper() {
1697
+        return $this->query('CryptoWrapper');
1698
+    }
1699
+
1700
+    /**
1701
+     * @return CsrfTokenManager
1702
+     */
1703
+    public function getCsrfTokenManager() {
1704
+        return $this->query('CsrfTokenManager');
1705
+    }
1706
+
1707
+    /**
1708
+     * @return Throttler
1709
+     */
1710
+    public function getBruteForceThrottler() {
1711
+        return $this->query('Throttler');
1712
+    }
1713
+
1714
+    /**
1715
+     * @return IContentSecurityPolicyManager
1716
+     */
1717
+    public function getContentSecurityPolicyManager() {
1718
+        return $this->query('ContentSecurityPolicyManager');
1719
+    }
1720
+
1721
+    /**
1722
+     * @return ContentSecurityPolicyNonceManager
1723
+     */
1724
+    public function getContentSecurityPolicyNonceManager() {
1725
+        return $this->query('ContentSecurityPolicyNonceManager');
1726
+    }
1727
+
1728
+    /**
1729
+     * Not a public API as of 8.2, wait for 9.0
1730
+     *
1731
+     * @return \OCA\Files_External\Service\BackendService
1732
+     */
1733
+    public function getStoragesBackendService() {
1734
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1735
+    }
1736
+
1737
+    /**
1738
+     * Not a public API as of 8.2, wait for 9.0
1739
+     *
1740
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1741
+     */
1742
+    public function getGlobalStoragesService() {
1743
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1744
+    }
1745
+
1746
+    /**
1747
+     * Not a public API as of 8.2, wait for 9.0
1748
+     *
1749
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1750
+     */
1751
+    public function getUserGlobalStoragesService() {
1752
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1753
+    }
1754
+
1755
+    /**
1756
+     * Not a public API as of 8.2, wait for 9.0
1757
+     *
1758
+     * @return \OCA\Files_External\Service\UserStoragesService
1759
+     */
1760
+    public function getUserStoragesService() {
1761
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1762
+    }
1763
+
1764
+    /**
1765
+     * @return \OCP\Share\IManager
1766
+     */
1767
+    public function getShareManager() {
1768
+        return $this->query('ShareManager');
1769
+    }
1770
+
1771
+    /**
1772
+     * Returns the LDAP Provider
1773
+     *
1774
+     * @return \OCP\LDAP\ILDAPProvider
1775
+     */
1776
+    public function getLDAPProvider() {
1777
+        return $this->query('LDAPProvider');
1778
+    }
1779
+
1780
+    /**
1781
+     * @return \OCP\Settings\IManager
1782
+     */
1783
+    public function getSettingsManager() {
1784
+        return $this->query('SettingsManager');
1785
+    }
1786
+
1787
+    /**
1788
+     * @return \OCP\Files\IAppData
1789
+     */
1790
+    public function getAppDataDir($app) {
1791
+        /** @var \OC\Files\AppData\Factory $factory */
1792
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1793
+        return $factory->get($app);
1794
+    }
1795
+
1796
+    /**
1797
+     * @return \OCP\Lockdown\ILockdownManager
1798
+     */
1799
+    public function getLockdownManager() {
1800
+        return $this->query('LockdownManager');
1801
+    }
1802
+
1803
+    /**
1804
+     * @return \OCP\Federation\ICloudIdManager
1805
+     */
1806
+    public function getCloudIdManager() {
1807
+        return $this->query(ICloudIdManager::class);
1808
+    }
1809 1809
 }
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		parent::__construct();
141 141
 		$this->webRoot = $webRoot;
142 142
 
143
-		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
143
+		$this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) {
144 144
 			return $c;
145 145
 		});
146 146
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		$this->registerAlias(IActionFactory::class, ActionFactory::class);
151 151
 
152 152
 
153
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
153
+		$this->registerService(\OCP\IPreview::class, function(Server $c) {
154 154
 			return new PreviewManager(
155 155
 				$c->getConfig(),
156 156
 				$c->getRootFolder(),
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 		});
162 162
 		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
163 163
 
164
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
164
+		$this->registerService(\OC\Preview\Watcher::class, function(Server $c) {
165 165
 			return new \OC\Preview\Watcher(
166 166
 				$c->getAppDataDir('preview')
167 167
 			);
168 168
 		});
169 169
 
170
-		$this->registerService('EncryptionManager', function (Server $c) {
170
+		$this->registerService('EncryptionManager', function(Server $c) {
171 171
 			$view = new View();
172 172
 			$util = new Encryption\Util(
173 173
 				$view,
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			);
186 186
 		});
187 187
 
188
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
188
+		$this->registerService('EncryptionFileHelper', function(Server $c) {
189 189
 			$util = new Encryption\Util(
190 190
 				new View(),
191 191
 				$c->getUserManager(),
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			);
200 200
 		});
201 201
 
202
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
202
+		$this->registerService('EncryptionKeyStorage', function(Server $c) {
203 203
 			$view = new View();
204 204
 			$util = new Encryption\Util(
205 205
 				$view,
@@ -210,32 +210,32 @@  discard block
 block discarded – undo
210 210
 
211 211
 			return new Encryption\Keys\Storage($view, $util);
212 212
 		});
213
-		$this->registerService('TagMapper', function (Server $c) {
213
+		$this->registerService('TagMapper', function(Server $c) {
214 214
 			return new TagMapper($c->getDatabaseConnection());
215 215
 		});
216 216
 
217
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
217
+		$this->registerService(\OCP\ITagManager::class, function(Server $c) {
218 218
 			$tagMapper = $c->query('TagMapper');
219 219
 			return new TagManager($tagMapper, $c->getUserSession());
220 220
 		});
221 221
 		$this->registerAlias('TagManager', \OCP\ITagManager::class);
222 222
 
223
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
223
+		$this->registerService('SystemTagManagerFactory', function(Server $c) {
224 224
 			$config = $c->getConfig();
225 225
 			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
226 226
 			/** @var \OC\SystemTag\ManagerFactory $factory */
227 227
 			$factory = new $factoryClass($this);
228 228
 			return $factory;
229 229
 		});
230
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
230
+		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) {
231 231
 			return $c->query('SystemTagManagerFactory')->getManager();
232 232
 		});
233 233
 		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
234 234
 
235
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
235
+		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) {
236 236
 			return $c->query('SystemTagManagerFactory')->getObjectMapper();
237 237
 		});
238
-		$this->registerService('RootFolder', function (Server $c) {
238
+		$this->registerService('RootFolder', function(Server $c) {
239 239
 			$manager = \OC\Files\Filesystem::getMountManager(null);
240 240
 			$view = new View();
241 241
 			$root = new Root(
@@ -256,37 +256,37 @@  discard block
 block discarded – undo
256 256
 		});
257 257
 		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
258 258
 
259
-		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
260
-			return new LazyRoot(function () use ($c) {
259
+		$this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
260
+			return new LazyRoot(function() use ($c) {
261 261
 				return $c->query('RootFolder');
262 262
 			});
263 263
 		});
264 264
 		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
265 265
 
266
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
266
+		$this->registerService(\OCP\IUserManager::class, function(Server $c) {
267 267
 			$config = $c->getConfig();
268 268
 			return new \OC\User\Manager($config);
269 269
 		});
270 270
 		$this->registerAlias('UserManager', \OCP\IUserManager::class);
271 271
 
272
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
272
+		$this->registerService(\OCP\IGroupManager::class, function(Server $c) {
273 273
 			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
274
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
274
+			$groupManager->listen('\OC\Group', 'preCreate', function($gid) {
275 275
 				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
276 276
 			});
277
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
277
+			$groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) {
278 278
 				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
279 279
 			});
280
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
280
+			$groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) {
281 281
 				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
282 282
 			});
283
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
283
+			$groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) {
284 284
 				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
285 285
 			});
286
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
286
+			$groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
287 287
 				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
288 288
 			});
289
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
289
+			$groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
290 290
 				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
291 291
 				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
292 292
 				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		});
296 296
 		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
297 297
 
298
-		$this->registerService(Store::class, function (Server $c) {
298
+		$this->registerService(Store::class, function(Server $c) {
299 299
 			$session = $c->getSession();
300 300
 			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
301 301
 				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 			return new Store($session, $logger, $tokenProvider);
307 307
 		});
308 308
 		$this->registerAlias(IStore::class, Store::class);
309
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
309
+		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) {
310 310
 			$dbConnection = $c->getDatabaseConnection();
311 311
 			return new Authentication\Token\DefaultTokenMapper($dbConnection);
312 312
 		});
313
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
313
+		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) {
314 314
 			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
315 315
 			$crypto = $c->getCrypto();
316 316
 			$config = $c->getConfig();
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 		});
321 321
 		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
322 322
 
323
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
323
+		$this->registerService(\OCP\IUserSession::class, function(Server $c) {
324 324
 			$manager = $c->getUserManager();
325 325
 			$session = new \OC\Session\Memory('');
326 326
 			$timeFactory = new TimeFactory();
@@ -333,44 +333,44 @@  discard block
 block discarded – undo
333 333
 			}
334 334
 
335 335
 			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
336
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
336
+			$userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) {
337 337
 				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
338 338
 			});
339
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
339
+			$userSession->listen('\OC\User', 'postCreateUser', function($user, $password) {
340 340
 				/** @var $user \OC\User\User */
341 341
 				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
342 342
 			});
343
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
343
+			$userSession->listen('\OC\User', 'preDelete', function($user) {
344 344
 				/** @var $user \OC\User\User */
345 345
 				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
346 346
 			});
347
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
347
+			$userSession->listen('\OC\User', 'postDelete', function($user) {
348 348
 				/** @var $user \OC\User\User */
349 349
 				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
350 350
 			});
351
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
351
+			$userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) {
352 352
 				/** @var $user \OC\User\User */
353 353
 				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
354 354
 			});
355
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
355
+			$userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) {
356 356
 				/** @var $user \OC\User\User */
357 357
 				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
358 358
 			});
359
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
359
+			$userSession->listen('\OC\User', 'preLogin', function($uid, $password) {
360 360
 				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
361 361
 			});
362
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
362
+			$userSession->listen('\OC\User', 'postLogin', function($user, $password) {
363 363
 				/** @var $user \OC\User\User */
364 364
 				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
365 365
 			});
366
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
366
+			$userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) {
367 367
 				/** @var $user \OC\User\User */
368 368
 				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
369 369
 			});
370
-			$userSession->listen('\OC\User', 'logout', function () {
370
+			$userSession->listen('\OC\User', 'logout', function() {
371 371
 				\OC_Hook::emit('OC_User', 'logout', array());
372 372
 			});
373
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
373
+			$userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) {
374 374
 				/** @var $user \OC\User\User */
375 375
 				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
376 376
 			});
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
 		});
379 379
 		$this->registerAlias('UserSession', \OCP\IUserSession::class);
380 380
 
381
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
381
+		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) {
382 382
 			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
383 383
 		});
384 384
 
385 385
 		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
386 386
 		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
387 387
 
388
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
388
+		$this->registerService(\OC\AllConfig::class, function(Server $c) {
389 389
 			return new \OC\AllConfig(
390 390
 				$c->getSystemConfig()
391 391
 			);
@@ -393,17 +393,17 @@  discard block
 block discarded – undo
393 393
 		$this->registerAlias('AllConfig', \OC\AllConfig::class);
394 394
 		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
395 395
 
396
-		$this->registerService('SystemConfig', function ($c) use ($config) {
396
+		$this->registerService('SystemConfig', function($c) use ($config) {
397 397
 			return new \OC\SystemConfig($config);
398 398
 		});
399 399
 
400
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
400
+		$this->registerService(\OC\AppConfig::class, function(Server $c) {
401 401
 			return new \OC\AppConfig($c->getDatabaseConnection());
402 402
 		});
403 403
 		$this->registerAlias('AppConfig', \OC\AppConfig::class);
404 404
 		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
405 405
 
406
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
406
+		$this->registerService(\OCP\L10N\IFactory::class, function(Server $c) {
407 407
 			return new \OC\L10N\Factory(
408 408
 				$c->getConfig(),
409 409
 				$c->getRequest(),
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 		});
414 414
 		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
415 415
 
416
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
416
+		$this->registerService(\OCP\IURLGenerator::class, function(Server $c) {
417 417
 			$config = $c->getConfig();
418 418
 			$cacheFactory = $c->getMemCacheFactory();
419 419
 			$request = $c->getRequest();
@@ -425,18 +425,18 @@  discard block
 block discarded – undo
425 425
 		});
426 426
 		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
427 427
 
428
-		$this->registerService('AppHelper', function ($c) {
428
+		$this->registerService('AppHelper', function($c) {
429 429
 			return new \OC\AppHelper();
430 430
 		});
431 431
 		$this->registerAlias('AppFetcher', AppFetcher::class);
432 432
 		$this->registerAlias('CategoryFetcher', CategoryFetcher::class);
433 433
 
434
-		$this->registerService(\OCP\ICache::class, function ($c) {
434
+		$this->registerService(\OCP\ICache::class, function($c) {
435 435
 			return new Cache\File();
436 436
 		});
437 437
 		$this->registerAlias('UserCache', \OCP\ICache::class);
438 438
 
439
-		$this->registerService(Factory::class, function (Server $c) {
439
+		$this->registerService(Factory::class, function(Server $c) {
440 440
 
441 441
 			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
442 442
 				'\\OC\\Memcache\\ArrayCache',
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				$version = implode(',', $v);
454 454
 				$instanceId = \OC_Util::getInstanceId();
455 455
 				$path = \OC::$SERVERROOT;
456
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
456
+				$prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.$urlGenerator->getBaseUrl());
457 457
 				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
458 458
 					$config->getSystemValue('memcache.local', null),
459 459
 					$config->getSystemValue('memcache.distributed', null),
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
 		$this->registerAlias('MemCacheFactory', Factory::class);
467 467
 		$this->registerAlias(ICacheFactory::class, Factory::class);
468 468
 
469
-		$this->registerService('RedisFactory', function (Server $c) {
469
+		$this->registerService('RedisFactory', function(Server $c) {
470 470
 			$systemConfig = $c->getSystemConfig();
471 471
 			return new RedisFactory($systemConfig);
472 472
 		});
473 473
 
474
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
474
+		$this->registerService(\OCP\Activity\IManager::class, function(Server $c) {
475 475
 			return new \OC\Activity\Manager(
476 476
 				$c->getRequest(),
477 477
 				$c->getUserSession(),
@@ -481,14 +481,14 @@  discard block
 block discarded – undo
481 481
 		});
482 482
 		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
483 483
 
484
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
484
+		$this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) {
485 485
 			return new \OC\Activity\EventMerger(
486 486
 				$c->getL10N('lib')
487 487
 			);
488 488
 		});
489 489
 		$this->registerAlias(IValidator::class, Validator::class);
490 490
 
491
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
491
+		$this->registerService(\OCP\IAvatarManager::class, function(Server $c) {
492 492
 			return new AvatarManager(
493 493
 				$c->getUserManager(),
494 494
 				$c->getAppDataDir('avatar'),
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 		});
500 500
 		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
501 501
 
502
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
502
+		$this->registerService(\OCP\ILogger::class, function(Server $c) {
503 503
 			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
504 504
 			$logger = Log::getLogClass($logType);
505 505
 			call_user_func(array($logger, 'init'));
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		});
509 509
 		$this->registerAlias('Logger', \OCP\ILogger::class);
510 510
 
511
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
511
+		$this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) {
512 512
 			$config = $c->getConfig();
513 513
 			return new \OC\BackgroundJob\JobList(
514 514
 				$c->getDatabaseConnection(),
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 		});
519 519
 		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
520 520
 
521
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
521
+		$this->registerService(\OCP\Route\IRouter::class, function(Server $c) {
522 522
 			$cacheFactory = $c->getMemCacheFactory();
523 523
 			$logger = $c->getLogger();
524 524
 			if ($cacheFactory->isAvailable()) {
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
 		});
531 531
 		$this->registerAlias('Router', \OCP\Route\IRouter::class);
532 532
 
533
-		$this->registerService(\OCP\ISearch::class, function ($c) {
533
+		$this->registerService(\OCP\ISearch::class, function($c) {
534 534
 			return new Search();
535 535
 		});
536 536
 		$this->registerAlias('Search', \OCP\ISearch::class);
537 537
 
538
-		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) {
538
+		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) {
539 539
 			return new \OC\Security\RateLimiting\Limiter(
540 540
 				$this->getUserSession(),
541 541
 				$this->getRequest(),
@@ -543,34 +543,34 @@  discard block
 block discarded – undo
543 543
 				$c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
544 544
 			);
545 545
 		});
546
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
546
+		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
547 547
 			return new \OC\Security\RateLimiting\Backend\MemoryCache(
548 548
 				$this->getMemCacheFactory(),
549 549
 				new \OC\AppFramework\Utility\TimeFactory()
550 550
 			);
551 551
 		});
552 552
 
553
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
553
+		$this->registerService(\OCP\Security\ISecureRandom::class, function($c) {
554 554
 			return new SecureRandom();
555 555
 		});
556 556
 		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
557 557
 
558
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
558
+		$this->registerService(\OCP\Security\ICrypto::class, function(Server $c) {
559 559
 			return new Crypto($c->getConfig(), $c->getSecureRandom());
560 560
 		});
561 561
 		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
562 562
 
563
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
563
+		$this->registerService(\OCP\Security\IHasher::class, function(Server $c) {
564 564
 			return new Hasher($c->getConfig());
565 565
 		});
566 566
 		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
567 567
 
568
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
568
+		$this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) {
569 569
 			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
570 570
 		});
571 571
 		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
572 572
 
573
-		$this->registerService(IDBConnection::class, function (Server $c) {
573
+		$this->registerService(IDBConnection::class, function(Server $c) {
574 574
 			$systemConfig = $c->getSystemConfig();
575 575
 			$factory = new \OC\DB\ConnectionFactory($systemConfig);
576 576
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		});
585 585
 		$this->registerAlias('DatabaseConnection', IDBConnection::class);
586 586
 
587
-		$this->registerService('HTTPHelper', function (Server $c) {
587
+		$this->registerService('HTTPHelper', function(Server $c) {
588 588
 			$config = $c->getConfig();
589 589
 			return new HTTPHelper(
590 590
 				$config,
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 			);
593 593
 		});
594 594
 
595
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
595
+		$this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) {
596 596
 			$user = \OC_User::getUser();
597 597
 			$uid = $user ? $user : null;
598 598
 			return new ClientService(
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			);
608 608
 		});
609 609
 		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
610
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
610
+		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) {
611 611
 			$eventLogger = new EventLogger();
612 612
 			if ($c->getSystemConfig()->getValue('debug', false)) {
613 613
 				// In debug mode, module is being activated by default
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 		});
618 618
 		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
619 619
 
620
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
620
+		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) {
621 621
 			$queryLogger = new QueryLogger();
622 622
 			if ($c->getSystemConfig()->getValue('debug', false)) {
623 623
 				// In debug mode, module is being activated by default
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 		});
628 628
 		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
629 629
 
630
-		$this->registerService(TempManager::class, function (Server $c) {
630
+		$this->registerService(TempManager::class, function(Server $c) {
631 631
 			return new TempManager(
632 632
 				$c->getLogger(),
633 633
 				$c->getConfig()
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 		$this->registerAlias('TempManager', TempManager::class);
637 637
 		$this->registerAlias(ITempManager::class, TempManager::class);
638 638
 
639
-		$this->registerService(AppManager::class, function (Server $c) {
639
+		$this->registerService(AppManager::class, function(Server $c) {
640 640
 			return new \OC\App\AppManager(
641 641
 				$c->getUserSession(),
642 642
 				$c->getAppConfig(),
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 		$this->registerAlias('AppManager', AppManager::class);
649 649
 		$this->registerAlias(IAppManager::class, AppManager::class);
650 650
 
651
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
651
+		$this->registerService(\OCP\IDateTimeZone::class, function(Server $c) {
652 652
 			return new DateTimeZone(
653 653
 				$c->getConfig(),
654 654
 				$c->getSession()
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 		});
657 657
 		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
658 658
 
659
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
659
+		$this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) {
660 660
 			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
661 661
 
662 662
 			return new DateTimeFormatter(
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 		});
667 667
 		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
668 668
 
669
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
669
+		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) {
670 670
 			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
671 671
 			$listener = new UserMountCacheListener($mountCache);
672 672
 			$listener->listen($c->getUserManager());
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		});
675 675
 		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
676 676
 
677
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
677
+		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) {
678 678
 			$loader = \OC\Files\Filesystem::getLoader();
679 679
 			$mountCache = $c->query('UserMountCache');
680 680
 			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
@@ -690,10 +690,10 @@  discard block
 block discarded – undo
690 690
 		});
691 691
 		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
692 692
 
693
-		$this->registerService('IniWrapper', function ($c) {
693
+		$this->registerService('IniWrapper', function($c) {
694 694
 			return new IniGetWrapper();
695 695
 		});
696
-		$this->registerService('AsyncCommandBus', function (Server $c) {
696
+		$this->registerService('AsyncCommandBus', function(Server $c) {
697 697
 			$busClass = $c->getConfig()->getSystemValue('commandbus');
698 698
 			if ($busClass) {
699 699
 				list($app, $class) = explode('::', $busClass, 2);
@@ -708,10 +708,10 @@  discard block
 block discarded – undo
708 708
 				return new CronBus($jobList);
709 709
 			}
710 710
 		});
711
-		$this->registerService('TrustedDomainHelper', function ($c) {
711
+		$this->registerService('TrustedDomainHelper', function($c) {
712 712
 			return new TrustedDomainHelper($this->getConfig());
713 713
 		});
714
-		$this->registerService('Throttler', function (Server $c) {
714
+		$this->registerService('Throttler', function(Server $c) {
715 715
 			return new Throttler(
716 716
 				$c->getDatabaseConnection(),
717 717
 				new TimeFactory(),
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 				$c->getConfig()
720 720
 			);
721 721
 		});
722
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
722
+		$this->registerService('IntegrityCodeChecker', function(Server $c) {
723 723
 			// IConfig and IAppManager requires a working database. This code
724 724
 			// might however be called when ownCloud is not yet setup.
725 725
 			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 				$c->getTempManager()
741 741
 			);
742 742
 		});
743
-		$this->registerService(\OCP\IRequest::class, function ($c) {
743
+		$this->registerService(\OCP\IRequest::class, function($c) {
744 744
 			if (isset($this['urlParams'])) {
745 745
 				$urlParams = $this['urlParams'];
746 746
 			} else {
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		});
777 777
 		$this->registerAlias('Request', \OCP\IRequest::class);
778 778
 
779
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
779
+		$this->registerService(\OCP\Mail\IMailer::class, function(Server $c) {
780 780
 			return new Mailer(
781 781
 				$c->getConfig(),
782 782
 				$c->getLogger(),
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		});
788 788
 		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
789 789
 
790
-		$this->registerService('LDAPProvider', function (Server $c) {
790
+		$this->registerService('LDAPProvider', function(Server $c) {
791 791
 			$config = $c->getConfig();
792 792
 			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
793 793
 			if (is_null($factoryClass)) {
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 			$factory = new $factoryClass($this);
798 798
 			return $factory->getLDAPProvider();
799 799
 		});
800
-		$this->registerService(ILockingProvider::class, function (Server $c) {
800
+		$this->registerService(ILockingProvider::class, function(Server $c) {
801 801
 			$ini = $c->getIniWrapper();
802 802
 			$config = $c->getConfig();
803 803
 			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
@@ -814,49 +814,49 @@  discard block
 block discarded – undo
814 814
 		});
815 815
 		$this->registerAlias('LockingProvider', ILockingProvider::class);
816 816
 
817
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
817
+		$this->registerService(\OCP\Files\Mount\IMountManager::class, function() {
818 818
 			return new \OC\Files\Mount\Manager();
819 819
 		});
820 820
 		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
821 821
 
822
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
822
+		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) {
823 823
 			return new \OC\Files\Type\Detection(
824 824
 				$c->getURLGenerator(),
825 825
 				\OC::$configDir,
826
-				\OC::$SERVERROOT . '/resources/config/'
826
+				\OC::$SERVERROOT.'/resources/config/'
827 827
 			);
828 828
 		});
829 829
 		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
830 830
 
831
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
831
+		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) {
832 832
 			return new \OC\Files\Type\Loader(
833 833
 				$c->getDatabaseConnection()
834 834
 			);
835 835
 		});
836 836
 		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
837
-		$this->registerService(BundleFetcher::class, function () {
837
+		$this->registerService(BundleFetcher::class, function() {
838 838
 			return new BundleFetcher($this->getL10N('lib'));
839 839
 		});
840
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
840
+		$this->registerService(\OCP\Notification\IManager::class, function(Server $c) {
841 841
 			return new Manager(
842 842
 				$c->query(IValidator::class)
843 843
 			);
844 844
 		});
845 845
 		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
846 846
 
847
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
847
+		$this->registerService(\OC\CapabilitiesManager::class, function(Server $c) {
848 848
 			$manager = new \OC\CapabilitiesManager($c->getLogger());
849
-			$manager->registerCapability(function () use ($c) {
849
+			$manager->registerCapability(function() use ($c) {
850 850
 				return new \OC\OCS\CoreCapabilities($c->getConfig());
851 851
 			});
852
-			$manager->registerCapability(function () use ($c) {
852
+			$manager->registerCapability(function() use ($c) {
853 853
 				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
854 854
 			});
855 855
 			return $manager;
856 856
 		});
857 857
 		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
858 858
 
859
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
859
+		$this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
860 860
 			$config = $c->getConfig();
861 861
 			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
862 862
 			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		});
866 866
 		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
867 867
 
868
-		$this->registerService('ThemingDefaults', function (Server $c) {
868
+		$this->registerService('ThemingDefaults', function(Server $c) {
869 869
 			/*
870 870
 			 * Dark magic for autoloader.
871 871
 			 * If we do a class_exists it will try to load the class which will
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 			}
892 892
 			return new \OC_Defaults();
893 893
 		});
894
-		$this->registerService(SCSSCacher::class, function (Server $c) {
894
+		$this->registerService(SCSSCacher::class, function(Server $c) {
895 895
 			/** @var Factory $cacheFactory */
896 896
 			$cacheFactory = $c->query(Factory::class);
897 897
 			return new SCSSCacher(
@@ -904,13 +904,13 @@  discard block
 block discarded – undo
904 904
 				$cacheFactory->create('SCSS')
905 905
 			);
906 906
 		});
907
-		$this->registerService(EventDispatcher::class, function () {
907
+		$this->registerService(EventDispatcher::class, function() {
908 908
 			return new EventDispatcher();
909 909
 		});
910 910
 		$this->registerAlias('EventDispatcher', EventDispatcher::class);
911 911
 		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
912 912
 
913
-		$this->registerService('CryptoWrapper', function (Server $c) {
913
+		$this->registerService('CryptoWrapper', function(Server $c) {
914 914
 			// FIXME: Instantiiated here due to cyclic dependency
915 915
 			$request = new Request(
916 916
 				[
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 				$request
936 936
 			);
937 937
 		});
938
-		$this->registerService('CsrfTokenManager', function (Server $c) {
938
+		$this->registerService('CsrfTokenManager', function(Server $c) {
939 939
 			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
940 940
 
941 941
 			return new CsrfTokenManager(
@@ -943,22 +943,22 @@  discard block
 block discarded – undo
943 943
 				$c->query(SessionStorage::class)
944 944
 			);
945 945
 		});
946
-		$this->registerService(SessionStorage::class, function (Server $c) {
946
+		$this->registerService(SessionStorage::class, function(Server $c) {
947 947
 			return new SessionStorage($c->getSession());
948 948
 		});
949
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
949
+		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) {
950 950
 			return new ContentSecurityPolicyManager();
951 951
 		});
952 952
 		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
953 953
 
954
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
954
+		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
955 955
 			return new ContentSecurityPolicyNonceManager(
956 956
 				$c->getCsrfTokenManager(),
957 957
 				$c->getRequest()
958 958
 			);
959 959
 		});
960 960
 
961
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
961
+		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
962 962
 			$config = $c->getConfig();
963 963
 			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
964 964
 			/** @var \OCP\Share\IProviderFactory $factory */
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 		});
986 986
 		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
987 987
 
988
-		$this->registerService('SettingsManager', function (Server $c) {
988
+		$this->registerService('SettingsManager', function(Server $c) {
989 989
 			$manager = new \OC\Settings\Manager(
990 990
 				$c->getLogger(),
991 991
 				$c->getDatabaseConnection(),
@@ -1005,29 +1005,29 @@  discard block
 block discarded – undo
1005 1005
 			);
1006 1006
 			return $manager;
1007 1007
 		});
1008
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1008
+		$this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) {
1009 1009
 			return new \OC\Files\AppData\Factory(
1010 1010
 				$c->getRootFolder(),
1011 1011
 				$c->getSystemConfig()
1012 1012
 			);
1013 1013
 		});
1014 1014
 
1015
-		$this->registerService('LockdownManager', function (Server $c) {
1016
-			return new LockdownManager(function () use ($c) {
1015
+		$this->registerService('LockdownManager', function(Server $c) {
1016
+			return new LockdownManager(function() use ($c) {
1017 1017
 				return $c->getSession();
1018 1018
 			});
1019 1019
 		});
1020 1020
 
1021
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1021
+		$this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) {
1022 1022
 			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1023 1023
 		});
1024 1024
 
1025
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1025
+		$this->registerService(ICloudIdManager::class, function(Server $c) {
1026 1026
 			return new CloudIdManager();
1027 1027
 		});
1028 1028
 
1029 1029
 		/* To trick DI since we don't extend the DIContainer here */
1030
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1030
+		$this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) {
1031 1031
 			return new CleanPreviewsBackgroundJob(
1032 1032
 				$c->getRootFolder(),
1033 1033
 				$c->getLogger(),
@@ -1042,18 +1042,18 @@  discard block
 block discarded – undo
1042 1042
 		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1043 1043
 		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1044 1044
 
1045
-		$this->registerService(Defaults::class, function (Server $c) {
1045
+		$this->registerService(Defaults::class, function(Server $c) {
1046 1046
 			return new Defaults(
1047 1047
 				$c->getThemingDefaults()
1048 1048
 			);
1049 1049
 		});
1050 1050
 		$this->registerAlias('Defaults', \OCP\Defaults::class);
1051 1051
 
1052
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1052
+		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
1053 1053
 			return $c->query(\OCP\IUserSession::class)->getSession();
1054 1054
 		});
1055 1055
 
1056
-		$this->registerService(IShareHelper::class, function (Server $c) {
1056
+		$this->registerService(IShareHelper::class, function(Server $c) {
1057 1057
 			return new ShareHelper(
1058 1058
 				$c->query(\OCP\Share\IManager::class)
1059 1059
 			);
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 	 * @deprecated since 9.2.0 use IAppData
1195 1195
 	 */
1196 1196
 	public function getAppFolder() {
1197
-		$dir = '/' . \OC_App::getCurrentApp();
1197
+		$dir = '/'.\OC_App::getCurrentApp();
1198 1198
 		$root = $this->getRootFolder();
1199 1199
 		if (!$root->nodeExists($dir)) {
1200 1200
 			$folder = $root->newFolder($dir);
Please login to merge, or discard this patch.
lib/private/Command/CronBus.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -25,51 +25,51 @@
 block discarded – undo
25 25
 use SuperClosure\Serializer;
26 26
 
27 27
 class CronBus extends AsyncBus {
28
-	/**
29
-	 * @var \OCP\BackgroundJob\IJobList
30
-	 */
31
-	private $jobList;
28
+    /**
29
+     * @var \OCP\BackgroundJob\IJobList
30
+     */
31
+    private $jobList;
32 32
 
33 33
 
34
-	/**
35
-	 * @param \OCP\BackgroundJob\IJobList $jobList
36
-	 */
37
-	public function __construct($jobList) {
38
-		$this->jobList = $jobList;
39
-	}
34
+    /**
35
+     * @param \OCP\BackgroundJob\IJobList $jobList
36
+     */
37
+    public function __construct($jobList) {
38
+        $this->jobList = $jobList;
39
+    }
40 40
 
41
-	protected function queueCommand($command) {
42
-		$this->jobList->add($this->getJobClass($command), $this->serializeCommand($command));
43
-	}
41
+    protected function queueCommand($command) {
42
+        $this->jobList->add($this->getJobClass($command), $this->serializeCommand($command));
43
+    }
44 44
 
45
-	/**
46
-	 * @param \OCP\Command\ICommand | callable $command
47
-	 * @return string
48
-	 */
49
-	private function getJobClass($command) {
50
-		if ($command instanceof \Closure) {
51
-			return 'OC\Command\ClosureJob';
52
-		} else if (is_callable($command)) {
53
-			return 'OC\Command\CallableJob';
54
-		} else if ($command instanceof ICommand) {
55
-			return 'OC\Command\CommandJob';
56
-		} else {
57
-			throw new \InvalidArgumentException('Invalid command');
58
-		}
59
-	}
45
+    /**
46
+     * @param \OCP\Command\ICommand | callable $command
47
+     * @return string
48
+     */
49
+    private function getJobClass($command) {
50
+        if ($command instanceof \Closure) {
51
+            return 'OC\Command\ClosureJob';
52
+        } else if (is_callable($command)) {
53
+            return 'OC\Command\CallableJob';
54
+        } else if ($command instanceof ICommand) {
55
+            return 'OC\Command\CommandJob';
56
+        } else {
57
+            throw new \InvalidArgumentException('Invalid command');
58
+        }
59
+    }
60 60
 
61
-	/**
62
-	 * @param \OCP\Command\ICommand | callable $command
63
-	 * @return string
64
-	 */
65
-	private function serializeCommand($command) {
66
-		if ($command instanceof \Closure) {
67
-			$serializer = new Serializer();
68
-			return $serializer->serialize($command);
69
-		} else if (is_callable($command) or $command instanceof ICommand) {
70
-			return serialize($command);
71
-		} else {
72
-			throw new \InvalidArgumentException('Invalid command');
73
-		}
74
-	}
61
+    /**
62
+     * @param \OCP\Command\ICommand | callable $command
63
+     * @return string
64
+     */
65
+    private function serializeCommand($command) {
66
+        if ($command instanceof \Closure) {
67
+            $serializer = new Serializer();
68
+            return $serializer->serialize($command);
69
+        } else if (is_callable($command) or $command instanceof ICommand) {
70
+            return serialize($command);
71
+        } else {
72
+            throw new \InvalidArgumentException('Invalid command');
73
+        }
74
+    }
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
lib/private/Command/AsyncBus.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -29,76 +29,76 @@
 block discarded – undo
29 29
  * Asynchronous command bus that uses the background job system as backend
30 30
  */
31 31
 abstract class AsyncBus implements IBus {
32
-	/**
33
-	 * List of traits for command which require sync execution
34
-	 *
35
-	 * @var string[]
36
-	 */
37
-	private $syncTraits = [];
32
+    /**
33
+     * List of traits for command which require sync execution
34
+     *
35
+     * @var string[]
36
+     */
37
+    private $syncTraits = [];
38 38
 
39
-	/**
40
-	 * Schedule a command to be fired
41
-	 *
42
-	 * @param \OCP\Command\ICommand | callable $command
43
-	 */
44
-	public function push($command) {
45
-		if ($this->canRunAsync($command)) {
46
-			$this->queueCommand($command);
47
-		} else {
48
-			$this->runCommand($command);
49
-		}
50
-	}
39
+    /**
40
+     * Schedule a command to be fired
41
+     *
42
+     * @param \OCP\Command\ICommand | callable $command
43
+     */
44
+    public function push($command) {
45
+        if ($this->canRunAsync($command)) {
46
+            $this->queueCommand($command);
47
+        } else {
48
+            $this->runCommand($command);
49
+        }
50
+    }
51 51
 
52
-	/**
53
-	 * Queue a command in the bus
54
-	 *
55
-	 * @param \OCP\Command\ICommand | callable $command
56
-	 */
57
-	abstract protected function queueCommand($command);
52
+    /**
53
+     * Queue a command in the bus
54
+     *
55
+     * @param \OCP\Command\ICommand | callable $command
56
+     */
57
+    abstract protected function queueCommand($command);
58 58
 
59
-	/**
60
-	 * Require all commands using a trait to be run synchronous
61
-	 *
62
-	 * @param string $trait
63
-	 */
64
-	public function requireSync($trait) {
65
-		$this->syncTraits[] = trim($trait, '\\');
66
-	}
59
+    /**
60
+     * Require all commands using a trait to be run synchronous
61
+     *
62
+     * @param string $trait
63
+     */
64
+    public function requireSync($trait) {
65
+        $this->syncTraits[] = trim($trait, '\\');
66
+    }
67 67
 
68
-	/**
69
-	 * @param \OCP\Command\ICommand | callable $command
70
-	 */
71
-	private function runCommand($command) {
72
-		if ($command instanceof ICommand) {
73
-			$command->handle();
74
-		} else {
75
-			$command();
76
-		}
77
-	}
68
+    /**
69
+     * @param \OCP\Command\ICommand | callable $command
70
+     */
71
+    private function runCommand($command) {
72
+        if ($command instanceof ICommand) {
73
+            $command->handle();
74
+        } else {
75
+            $command();
76
+        }
77
+    }
78 78
 
79
-	/**
80
-	 * @param \OCP\Command\ICommand | callable $command
81
-	 * @return bool
82
-	 */
83
-	private function canRunAsync($command) {
84
-		$traits = $this->getTraits($command);
85
-		foreach ($traits as $trait) {
86
-			if (array_search($trait, $this->syncTraits) !== false) {
87
-				return false;
88
-			}
89
-		}
90
-		return true;
91
-	}
79
+    /**
80
+     * @param \OCP\Command\ICommand | callable $command
81
+     * @return bool
82
+     */
83
+    private function canRunAsync($command) {
84
+        $traits = $this->getTraits($command);
85
+        foreach ($traits as $trait) {
86
+            if (array_search($trait, $this->syncTraits) !== false) {
87
+                return false;
88
+            }
89
+        }
90
+        return true;
91
+    }
92 92
 
93
-	/**
94
-	 * @param \OCP\Command\ICommand | callable $command
95
-	 * @return string[]
96
-	 */
97
-	private function getTraits($command) {
98
-		if ($command instanceof ICommand) {
99
-			return class_uses($command);
100
-		} else {
101
-			return [];
102
-		}
103
-	}
93
+    /**
94
+     * @param \OCP\Command\ICommand | callable $command
95
+     * @return string[]
96
+     */
97
+    private function getTraits($command) {
98
+        if ($command instanceof ICommand) {
99
+            return class_uses($command);
100
+        } else {
101
+            return [];
102
+        }
103
+    }
104 104
 }
Please login to merge, or discard this patch.