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