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