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