Passed
Push — master ( 1000b4...c5339f )
by Joas
16:48 queued 12s
created
lib/private/Security/RateLimiting/Backend/MemoryCacheBackend.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -42,94 +42,94 @@
 block discarded – undo
42 42
  * @package OC\Security\RateLimiting\Backend
43 43
  */
44 44
 class MemoryCacheBackend implements IBackend {
45
-	/** @var IConfig */
46
-	private $config;
47
-	/** @var ICache */
48
-	private $cache;
49
-	/** @var ITimeFactory */
50
-	private $timeFactory;
51
-
52
-	public function __construct(
53
-		IConfig $config,
54
-		ICacheFactory $cacheFactory,
55
-		ITimeFactory $timeFactory) {
56
-		$this->config = $config;
57
-		$this->cache = $cacheFactory->createDistributed(__CLASS__);
58
-		$this->timeFactory = $timeFactory;
59
-	}
60
-
61
-	/**
62
-	 * @param string $methodIdentifier
63
-	 * @param string $userIdentifier
64
-	 * @return string
65
-	 */
66
-	private function hash(string $methodIdentifier,
67
-						  string $userIdentifier): string {
68
-		return hash('sha512', $methodIdentifier . $userIdentifier);
69
-	}
70
-
71
-	/**
72
-	 * @param string $identifier
73
-	 * @return array
74
-	 */
75
-	private function getExistingAttempts(string $identifier): array {
76
-		$cachedAttempts = $this->cache->get($identifier);
77
-		if ($cachedAttempts === null) {
78
-			return [];
79
-		}
80
-
81
-		$cachedAttempts = json_decode($cachedAttempts, true);
82
-		if (\is_array($cachedAttempts)) {
83
-			return $cachedAttempts;
84
-		}
85
-
86
-		return [];
87
-	}
88
-
89
-	/**
90
-	 * {@inheritDoc}
91
-	 */
92
-	public function getAttempts(string $methodIdentifier,
93
-								string $userIdentifier): int {
94
-		$identifier = $this->hash($methodIdentifier, $userIdentifier);
95
-		$existingAttempts = $this->getExistingAttempts($identifier);
96
-
97
-		$count = 0;
98
-		$currentTime = $this->timeFactory->getTime();
99
-		foreach ($existingAttempts as $expirationTime) {
100
-			if ($expirationTime > $currentTime) {
101
-				$count++;
102
-			}
103
-		}
104
-
105
-		return $count;
106
-	}
107
-
108
-	/**
109
-	 * {@inheritDoc}
110
-	 */
111
-	public function registerAttempt(string $methodIdentifier,
112
-									string $userIdentifier,
113
-									int $period) {
114
-		$identifier = $this->hash($methodIdentifier, $userIdentifier);
115
-		$existingAttempts = $this->getExistingAttempts($identifier);
116
-		$currentTime = $this->timeFactory->getTime();
117
-
118
-		// Unset all attempts that are already expired
119
-		foreach ($existingAttempts as $key => $expirationTime) {
120
-			if ($expirationTime < $currentTime) {
121
-				unset($existingAttempts[$key]);
122
-			}
123
-		}
124
-		$existingAttempts = array_values($existingAttempts);
125
-
126
-		// Store the new attempt
127
-		$existingAttempts[] = (string)($currentTime + $period);
128
-
129
-		if (!$this->config->getSystemValueBool('ratelimit.protection.enabled', true)) {
130
-			return;
131
-		}
132
-
133
-		$this->cache->set($identifier, json_encode($existingAttempts));
134
-	}
45
+    /** @var IConfig */
46
+    private $config;
47
+    /** @var ICache */
48
+    private $cache;
49
+    /** @var ITimeFactory */
50
+    private $timeFactory;
51
+
52
+    public function __construct(
53
+        IConfig $config,
54
+        ICacheFactory $cacheFactory,
55
+        ITimeFactory $timeFactory) {
56
+        $this->config = $config;
57
+        $this->cache = $cacheFactory->createDistributed(__CLASS__);
58
+        $this->timeFactory = $timeFactory;
59
+    }
60
+
61
+    /**
62
+     * @param string $methodIdentifier
63
+     * @param string $userIdentifier
64
+     * @return string
65
+     */
66
+    private function hash(string $methodIdentifier,
67
+                            string $userIdentifier): string {
68
+        return hash('sha512', $methodIdentifier . $userIdentifier);
69
+    }
70
+
71
+    /**
72
+     * @param string $identifier
73
+     * @return array
74
+     */
75
+    private function getExistingAttempts(string $identifier): array {
76
+        $cachedAttempts = $this->cache->get($identifier);
77
+        if ($cachedAttempts === null) {
78
+            return [];
79
+        }
80
+
81
+        $cachedAttempts = json_decode($cachedAttempts, true);
82
+        if (\is_array($cachedAttempts)) {
83
+            return $cachedAttempts;
84
+        }
85
+
86
+        return [];
87
+    }
88
+
89
+    /**
90
+     * {@inheritDoc}
91
+     */
92
+    public function getAttempts(string $methodIdentifier,
93
+                                string $userIdentifier): int {
94
+        $identifier = $this->hash($methodIdentifier, $userIdentifier);
95
+        $existingAttempts = $this->getExistingAttempts($identifier);
96
+
97
+        $count = 0;
98
+        $currentTime = $this->timeFactory->getTime();
99
+        foreach ($existingAttempts as $expirationTime) {
100
+            if ($expirationTime > $currentTime) {
101
+                $count++;
102
+            }
103
+        }
104
+
105
+        return $count;
106
+    }
107
+
108
+    /**
109
+     * {@inheritDoc}
110
+     */
111
+    public function registerAttempt(string $methodIdentifier,
112
+                                    string $userIdentifier,
113
+                                    int $period) {
114
+        $identifier = $this->hash($methodIdentifier, $userIdentifier);
115
+        $existingAttempts = $this->getExistingAttempts($identifier);
116
+        $currentTime = $this->timeFactory->getTime();
117
+
118
+        // Unset all attempts that are already expired
119
+        foreach ($existingAttempts as $key => $expirationTime) {
120
+            if ($expirationTime < $currentTime) {
121
+                unset($existingAttempts[$key]);
122
+            }
123
+        }
124
+        $existingAttempts = array_values($existingAttempts);
125
+
126
+        // Store the new attempt
127
+        $existingAttempts[] = (string)($currentTime + $period);
128
+
129
+        if (!$this->config->getSystemValueBool('ratelimit.protection.enabled', true)) {
130
+            return;
131
+        }
132
+
133
+        $this->cache->set($identifier, json_encode($existingAttempts));
134
+    }
135 135
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	private function hash(string $methodIdentifier,
67 67
 						  string $userIdentifier): string {
68
-		return hash('sha512', $methodIdentifier . $userIdentifier);
68
+		return hash('sha512', $methodIdentifier.$userIdentifier);
69 69
 	}
70 70
 
71 71
 	/**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		$existingAttempts = array_values($existingAttempts);
125 125
 
126 126
 		// Store the new attempt
127
-		$existingAttempts[] = (string)($currentTime + $period);
127
+		$existingAttempts[] = (string) ($currentTime + $period);
128 128
 
129 129
 		if (!$this->config->getSystemValueBool('ratelimit.protection.enabled', true)) {
130 130
 			return;
Please login to merge, or discard this patch.
lib/private/Security/RateLimiting/Backend/DatabaseBackend.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -33,97 +33,97 @@
 block discarded – undo
33 33
 use OCP\IDBConnection;
34 34
 
35 35
 class DatabaseBackend implements IBackend {
36
-	private const TABLE_NAME = 'ratelimit_entries';
37
-
38
-	/** @var IConfig */
39
-	private $config;
40
-	/** @var IDBConnection */
41
-	private $dbConnection;
42
-	/** @var ITimeFactory */
43
-	private $timeFactory;
44
-
45
-	public function __construct(
46
-		IConfig $config,
47
-		IDBConnection $dbConnection,
48
-		ITimeFactory $timeFactory
49
-	) {
50
-		$this->config = $config;
51
-		$this->dbConnection = $dbConnection;
52
-		$this->timeFactory = $timeFactory;
53
-	}
54
-
55
-	/**
56
-	 * @param string $methodIdentifier
57
-	 * @param string $userIdentifier
58
-	 * @return string
59
-	 */
60
-	private function hash(string $methodIdentifier,
61
-						  string $userIdentifier): string {
62
-		return hash('sha512', $methodIdentifier . $userIdentifier);
63
-	}
64
-
65
-	/**
66
-	 * @param string $identifier
67
-	 * @param int $seconds
68
-	 * @return int
69
-	 * @throws \OCP\DB\Exception
70
-	 */
71
-	private function getExistingAttemptCount(
72
-		string $identifier
73
-	): int {
74
-		$currentTime = $this->timeFactory->getDateTime();
75
-
76
-		$qb = $this->dbConnection->getQueryBuilder();
77
-		$qb->delete(self::TABLE_NAME)
78
-			->where(
79
-				$qb->expr()->lte('delete_after', $qb->createNamedParameter($currentTime, IQueryBuilder::PARAM_DATE))
80
-			)
81
-			->executeStatement();
82
-
83
-		$qb = $this->dbConnection->getQueryBuilder();
84
-		$qb->select($qb->func()->count())
85
-			->from(self::TABLE_NAME)
86
-			->where(
87
-				$qb->expr()->eq('hash', $qb->createNamedParameter($identifier, IQueryBuilder::PARAM_STR))
88
-			);
89
-
90
-		$cursor = $qb->executeQuery();
91
-		$row = $cursor->fetchOne();
92
-		$cursor->closeCursor();
93
-
94
-		return (int)$row;
95
-	}
96
-
97
-	/**
98
-	 * {@inheritDoc}
99
-	 */
100
-	public function getAttempts(string $methodIdentifier,
101
-								string $userIdentifier): int {
102
-		$identifier = $this->hash($methodIdentifier, $userIdentifier);
103
-		return $this->getExistingAttemptCount($identifier);
104
-	}
105
-
106
-	/**
107
-	 * {@inheritDoc}
108
-	 */
109
-	public function registerAttempt(string $methodIdentifier,
110
-									string $userIdentifier,
111
-									int $period) {
112
-		$identifier = $this->hash($methodIdentifier, $userIdentifier);
113
-		$deleteAfter = $this->timeFactory->getDateTime()->add(new \DateInterval("PT{$period}S"));
114
-
115
-		$qb = $this->dbConnection->getQueryBuilder();
116
-
117
-		$qb->insert(self::TABLE_NAME)
118
-			->values([
119
-				'hash' => $qb->createNamedParameter($identifier, IQueryBuilder::PARAM_STR),
120
-				'delete_after' => $qb->createNamedParameter($deleteAfter, IQueryBuilder::PARAM_DATE),
121
-			]);
122
-
123
-		if (!$this->config->getSystemValueBool('ratelimit.protection.enabled', true)) {
124
-			return;
125
-		}
126
-
127
-		$qb->executeStatement();
128
-	}
36
+    private const TABLE_NAME = 'ratelimit_entries';
37
+
38
+    /** @var IConfig */
39
+    private $config;
40
+    /** @var IDBConnection */
41
+    private $dbConnection;
42
+    /** @var ITimeFactory */
43
+    private $timeFactory;
44
+
45
+    public function __construct(
46
+        IConfig $config,
47
+        IDBConnection $dbConnection,
48
+        ITimeFactory $timeFactory
49
+    ) {
50
+        $this->config = $config;
51
+        $this->dbConnection = $dbConnection;
52
+        $this->timeFactory = $timeFactory;
53
+    }
54
+
55
+    /**
56
+     * @param string $methodIdentifier
57
+     * @param string $userIdentifier
58
+     * @return string
59
+     */
60
+    private function hash(string $methodIdentifier,
61
+                            string $userIdentifier): string {
62
+        return hash('sha512', $methodIdentifier . $userIdentifier);
63
+    }
64
+
65
+    /**
66
+     * @param string $identifier
67
+     * @param int $seconds
68
+     * @return int
69
+     * @throws \OCP\DB\Exception
70
+     */
71
+    private function getExistingAttemptCount(
72
+        string $identifier
73
+    ): int {
74
+        $currentTime = $this->timeFactory->getDateTime();
75
+
76
+        $qb = $this->dbConnection->getQueryBuilder();
77
+        $qb->delete(self::TABLE_NAME)
78
+            ->where(
79
+                $qb->expr()->lte('delete_after', $qb->createNamedParameter($currentTime, IQueryBuilder::PARAM_DATE))
80
+            )
81
+            ->executeStatement();
82
+
83
+        $qb = $this->dbConnection->getQueryBuilder();
84
+        $qb->select($qb->func()->count())
85
+            ->from(self::TABLE_NAME)
86
+            ->where(
87
+                $qb->expr()->eq('hash', $qb->createNamedParameter($identifier, IQueryBuilder::PARAM_STR))
88
+            );
89
+
90
+        $cursor = $qb->executeQuery();
91
+        $row = $cursor->fetchOne();
92
+        $cursor->closeCursor();
93
+
94
+        return (int)$row;
95
+    }
96
+
97
+    /**
98
+     * {@inheritDoc}
99
+     */
100
+    public function getAttempts(string $methodIdentifier,
101
+                                string $userIdentifier): int {
102
+        $identifier = $this->hash($methodIdentifier, $userIdentifier);
103
+        return $this->getExistingAttemptCount($identifier);
104
+    }
105
+
106
+    /**
107
+     * {@inheritDoc}
108
+     */
109
+    public function registerAttempt(string $methodIdentifier,
110
+                                    string $userIdentifier,
111
+                                    int $period) {
112
+        $identifier = $this->hash($methodIdentifier, $userIdentifier);
113
+        $deleteAfter = $this->timeFactory->getDateTime()->add(new \DateInterval("PT{$period}S"));
114
+
115
+        $qb = $this->dbConnection->getQueryBuilder();
116
+
117
+        $qb->insert(self::TABLE_NAME)
118
+            ->values([
119
+                'hash' => $qb->createNamedParameter($identifier, IQueryBuilder::PARAM_STR),
120
+                'delete_after' => $qb->createNamedParameter($deleteAfter, IQueryBuilder::PARAM_DATE),
121
+            ]);
122
+
123
+        if (!$this->config->getSystemValueBool('ratelimit.protection.enabled', true)) {
124
+            return;
125
+        }
126
+
127
+        $qb->executeStatement();
128
+    }
129 129
 }
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +2094 added lines, -2094 removed lines patch added patch discarded remove patch
@@ -281,2098 +281,2098 @@
 block discarded – undo
281 281
  * TODO: hookup all manager classes
282 282
  */
283 283
 class Server extends ServerContainer implements IServerContainer {
284
-	/** @var string */
285
-	private $webRoot;
286
-
287
-	/**
288
-	 * @param string $webRoot
289
-	 * @param \OC\Config $config
290
-	 */
291
-	public function __construct($webRoot, \OC\Config $config) {
292
-		parent::__construct();
293
-		$this->webRoot = $webRoot;
294
-
295
-		// To find out if we are running from CLI or not
296
-		$this->registerParameter('isCLI', \OC::$CLI);
297
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
298
-
299
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
300
-			return $c;
301
-		});
302
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
303
-			return $c;
304
-		});
305
-
306
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
307
-		/** @deprecated 19.0.0 */
308
-		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
309
-
310
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
311
-		/** @deprecated 19.0.0 */
312
-		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
313
-
314
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
315
-		/** @deprecated 19.0.0 */
316
-		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
317
-
318
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
319
-		/** @deprecated 19.0.0 */
320
-		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
321
-
322
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
323
-		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
324
-
325
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
326
-
327
-		$this->registerService(View::class, function (Server $c) {
328
-			return new View();
329
-		}, false);
330
-
331
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
332
-			return new PreviewManager(
333
-				$c->get(\OCP\IConfig::class),
334
-				$c->get(IRootFolder::class),
335
-				new \OC\Preview\Storage\Root(
336
-					$c->get(IRootFolder::class),
337
-					$c->get(SystemConfig::class)
338
-				),
339
-				$c->get(IEventDispatcher::class),
340
-				$c->get(SymfonyAdapter::class),
341
-				$c->get(GeneratorHelper::class),
342
-				$c->get(ISession::class)->get('user_id'),
343
-				$c->get(Coordinator::class),
344
-				$c->get(IServerContainer::class),
345
-				$c->get(IBinaryFinder::class),
346
-				$c->get(IMagickSupport::class)
347
-			);
348
-		});
349
-		/** @deprecated 19.0.0 */
350
-		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
351
-
352
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
353
-			return new \OC\Preview\Watcher(
354
-				new \OC\Preview\Storage\Root(
355
-					$c->get(IRootFolder::class),
356
-					$c->get(SystemConfig::class)
357
-				)
358
-			);
359
-		});
360
-
361
-		$this->registerService(IProfiler::class, function (Server $c) {
362
-			return new Profiler($c->get(SystemConfig::class));
363
-		});
364
-
365
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
366
-			$view = new View();
367
-			$util = new Encryption\Util(
368
-				$view,
369
-				$c->get(IUserManager::class),
370
-				$c->get(IGroupManager::class),
371
-				$c->get(\OCP\IConfig::class)
372
-			);
373
-			return new Encryption\Manager(
374
-				$c->get(\OCP\IConfig::class),
375
-				$c->get(LoggerInterface::class),
376
-				$c->getL10N('core'),
377
-				new View(),
378
-				$util,
379
-				new ArrayCache()
380
-			);
381
-		});
382
-		/** @deprecated 19.0.0 */
383
-		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
384
-
385
-		/** @deprecated 21.0.0 */
386
-		$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
387
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
388
-			$util = new Encryption\Util(
389
-				new View(),
390
-				$c->get(IUserManager::class),
391
-				$c->get(IGroupManager::class),
392
-				$c->get(\OCP\IConfig::class)
393
-			);
394
-			return new Encryption\File(
395
-				$util,
396
-				$c->get(IRootFolder::class),
397
-				$c->get(\OCP\Share\IManager::class)
398
-			);
399
-		});
400
-
401
-		/** @deprecated 21.0.0 */
402
-		$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
403
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
404
-			$view = new View();
405
-			$util = new Encryption\Util(
406
-				$view,
407
-				$c->get(IUserManager::class),
408
-				$c->get(IGroupManager::class),
409
-				$c->get(\OCP\IConfig::class)
410
-			);
411
-
412
-			return new Encryption\Keys\Storage(
413
-				$view,
414
-				$util,
415
-				$c->get(ICrypto::class),
416
-				$c->get(\OCP\IConfig::class)
417
-			);
418
-		});
419
-		/** @deprecated 20.0.0 */
420
-		$this->registerDeprecatedAlias('TagMapper', TagMapper::class);
421
-
422
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
423
-		/** @deprecated 19.0.0 */
424
-		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
425
-
426
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
427
-			/** @var \OCP\IConfig $config */
428
-			$config = $c->get(\OCP\IConfig::class);
429
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
430
-			return new $factoryClass($this);
431
-		});
432
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
433
-			return $c->get('SystemTagManagerFactory')->getManager();
434
-		});
435
-		/** @deprecated 19.0.0 */
436
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
437
-
438
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
439
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
440
-		});
441
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
442
-			$manager = \OC\Files\Filesystem::getMountManager(null);
443
-			$view = new View();
444
-			$root = new Root(
445
-				$manager,
446
-				$view,
447
-				null,
448
-				$c->get(IUserMountCache::class),
449
-				$this->get(LoggerInterface::class),
450
-				$this->get(IUserManager::class),
451
-				$this->get(IEventDispatcher::class),
452
-			);
453
-
454
-			$previewConnector = new \OC\Preview\WatcherConnector(
455
-				$root,
456
-				$c->get(SystemConfig::class)
457
-			);
458
-			$previewConnector->connectWatcher();
459
-
460
-			return $root;
461
-		});
462
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
463
-			return new HookConnector(
464
-				$c->get(IRootFolder::class),
465
-				new View(),
466
-				$c->get(\OC\EventDispatcher\SymfonyAdapter::class),
467
-				$c->get(IEventDispatcher::class)
468
-			);
469
-		});
470
-
471
-		/** @deprecated 19.0.0 */
472
-		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
473
-
474
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
475
-			return new LazyRoot(function () use ($c) {
476
-				return $c->get('RootFolder');
477
-			});
478
-		});
479
-		/** @deprecated 19.0.0 */
480
-		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
481
-
482
-		/** @deprecated 19.0.0 */
483
-		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
484
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
485
-
486
-		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
487
-			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
488
-		});
489
-
490
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
491
-			$groupManager = new \OC\Group\Manager(
492
-				$this->get(IUserManager::class),
493
-				$c->get(SymfonyAdapter::class),
494
-				$this->get(LoggerInterface::class),
495
-				$this->get(ICacheFactory::class)
496
-			);
497
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
498
-				/** @var IEventDispatcher $dispatcher */
499
-				$dispatcher = $this->get(IEventDispatcher::class);
500
-				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
501
-			});
502
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
503
-				/** @var IEventDispatcher $dispatcher */
504
-				$dispatcher = $this->get(IEventDispatcher::class);
505
-				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
506
-			});
507
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
508
-				/** @var IEventDispatcher $dispatcher */
509
-				$dispatcher = $this->get(IEventDispatcher::class);
510
-				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
511
-			});
512
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
513
-				/** @var IEventDispatcher $dispatcher */
514
-				$dispatcher = $this->get(IEventDispatcher::class);
515
-				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
516
-			});
517
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
518
-				/** @var IEventDispatcher $dispatcher */
519
-				$dispatcher = $this->get(IEventDispatcher::class);
520
-				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
521
-			});
522
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
523
-				/** @var IEventDispatcher $dispatcher */
524
-				$dispatcher = $this->get(IEventDispatcher::class);
525
-				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
526
-			});
527
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
528
-				/** @var IEventDispatcher $dispatcher */
529
-				$dispatcher = $this->get(IEventDispatcher::class);
530
-				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
531
-			});
532
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
533
-				/** @var IEventDispatcher $dispatcher */
534
-				$dispatcher = $this->get(IEventDispatcher::class);
535
-				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
536
-			});
537
-			return $groupManager;
538
-		});
539
-		/** @deprecated 19.0.0 */
540
-		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
541
-
542
-		$this->registerService(Store::class, function (ContainerInterface $c) {
543
-			$session = $c->get(ISession::class);
544
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
545
-				$tokenProvider = $c->get(IProvider::class);
546
-			} else {
547
-				$tokenProvider = null;
548
-			}
549
-			$logger = $c->get(LoggerInterface::class);
550
-			return new Store($session, $logger, $tokenProvider);
551
-		});
552
-		$this->registerAlias(IStore::class, Store::class);
553
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
554
-		$this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
555
-
556
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
557
-			$manager = $c->get(IUserManager::class);
558
-			$session = new \OC\Session\Memory('');
559
-			$timeFactory = new TimeFactory();
560
-			// Token providers might require a working database. This code
561
-			// might however be called when Nextcloud is not yet setup.
562
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
563
-				$provider = $c->get(IProvider::class);
564
-			} else {
565
-				$provider = null;
566
-			}
567
-
568
-			$legacyDispatcher = $c->get(SymfonyAdapter::class);
569
-
570
-			$userSession = new \OC\User\Session(
571
-				$manager,
572
-				$session,
573
-				$timeFactory,
574
-				$provider,
575
-				$c->get(\OCP\IConfig::class),
576
-				$c->get(ISecureRandom::class),
577
-				$c->getLockdownManager(),
578
-				$c->get(LoggerInterface::class),
579
-				$c->get(IEventDispatcher::class)
580
-			);
581
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
582
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
583
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
584
-			});
585
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
586
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
587
-				/** @var \OC\User\User $user */
588
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
589
-			});
590
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
591
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
592
-				/** @var \OC\User\User $user */
593
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
594
-				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
595
-			});
596
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
597
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
598
-				/** @var \OC\User\User $user */
599
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
600
-			});
601
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
602
-				/** @var \OC\User\User $user */
603
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
604
-
605
-				/** @var IEventDispatcher $dispatcher */
606
-				$dispatcher = $this->get(IEventDispatcher::class);
607
-				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
608
-			});
609
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
610
-				/** @var \OC\User\User $user */
611
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
612
-
613
-				/** @var IEventDispatcher $dispatcher */
614
-				$dispatcher = $this->get(IEventDispatcher::class);
615
-				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
616
-			});
617
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
618
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
619
-
620
-				/** @var IEventDispatcher $dispatcher */
621
-				$dispatcher = $this->get(IEventDispatcher::class);
622
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
623
-			});
624
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
625
-				/** @var \OC\User\User $user */
626
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
627
-
628
-				/** @var IEventDispatcher $dispatcher */
629
-				$dispatcher = $this->get(IEventDispatcher::class);
630
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
631
-			});
632
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
633
-				/** @var IEventDispatcher $dispatcher */
634
-				$dispatcher = $this->get(IEventDispatcher::class);
635
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
636
-			});
637
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
638
-				/** @var \OC\User\User $user */
639
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
640
-
641
-				/** @var IEventDispatcher $dispatcher */
642
-				$dispatcher = $this->get(IEventDispatcher::class);
643
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
644
-			});
645
-			$userSession->listen('\OC\User', 'logout', function ($user) {
646
-				\OC_Hook::emit('OC_User', 'logout', []);
647
-
648
-				/** @var IEventDispatcher $dispatcher */
649
-				$dispatcher = $this->get(IEventDispatcher::class);
650
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
651
-			});
652
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
653
-				/** @var IEventDispatcher $dispatcher */
654
-				$dispatcher = $this->get(IEventDispatcher::class);
655
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
656
-			});
657
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
658
-				/** @var \OC\User\User $user */
659
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
660
-
661
-				/** @var IEventDispatcher $dispatcher */
662
-				$dispatcher = $this->get(IEventDispatcher::class);
663
-				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
664
-			});
665
-			return $userSession;
666
-		});
667
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
668
-		/** @deprecated 19.0.0 */
669
-		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
670
-
671
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
672
-
673
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
674
-		/** @deprecated 19.0.0 */
675
-		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
676
-
677
-		/** @deprecated 19.0.0 */
678
-		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
679
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
680
-
681
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
682
-			return new \OC\SystemConfig($config);
683
-		});
684
-		/** @deprecated 19.0.0 */
685
-		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
686
-
687
-		/** @deprecated 19.0.0 */
688
-		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
689
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
690
-
691
-		$this->registerService(IFactory::class, function (Server $c) {
692
-			return new \OC\L10N\Factory(
693
-				$c->get(\OCP\IConfig::class),
694
-				$c->getRequest(),
695
-				$c->get(IUserSession::class),
696
-				$c->get(ICacheFactory::class),
697
-				\OC::$SERVERROOT
698
-			);
699
-		});
700
-		/** @deprecated 19.0.0 */
701
-		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
702
-
703
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
704
-		/** @deprecated 19.0.0 */
705
-		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
706
-
707
-		/** @deprecated 19.0.0 */
708
-		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
709
-		/** @deprecated 19.0.0 */
710
-		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
711
-
712
-		$this->registerService(ICache::class, function ($c) {
713
-			return new Cache\File();
714
-		});
715
-		/** @deprecated 19.0.0 */
716
-		$this->registerDeprecatedAlias('UserCache', ICache::class);
717
-
718
-		$this->registerService(Factory::class, function (Server $c) {
719
-			$profiler = $c->get(IProfiler::class);
720
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
721
-				$profiler,
722
-				ArrayCache::class,
723
-				ArrayCache::class,
724
-				ArrayCache::class
725
-			);
726
-			/** @var \OCP\IConfig $config */
727
-			$config = $c->get(\OCP\IConfig::class);
728
-
729
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
730
-				if (!$config->getSystemValueBool('log_query')) {
731
-					$v = \OC_App::getAppVersions();
732
-				} else {
733
-					// If the log_query is enabled, we can not get the app versions
734
-					// as that does a query, which will be logged and the logging
735
-					// depends on redis and here we are back again in the same function.
736
-					$v = [
737
-						'log_query' => 'enabled',
738
-					];
739
-				}
740
-				$v['core'] = implode(',', \OC_Util::getVersion());
741
-				$version = implode(',', $v);
742
-				$instanceId = \OC_Util::getInstanceId();
743
-				$path = \OC::$SERVERROOT;
744
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
745
-				return new \OC\Memcache\Factory($prefix,
746
-					$c->get(LoggerInterface::class),
747
-					$profiler,
748
-					$config->getSystemValue('memcache.local', null),
749
-					$config->getSystemValue('memcache.distributed', null),
750
-					$config->getSystemValue('memcache.locking', null),
751
-					$config->getSystemValueString('redis_log_file')
752
-				);
753
-			}
754
-			return $arrayCacheFactory;
755
-		});
756
-		/** @deprecated 19.0.0 */
757
-		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
758
-		$this->registerAlias(ICacheFactory::class, Factory::class);
759
-
760
-		$this->registerService('RedisFactory', function (Server $c) {
761
-			$systemConfig = $c->get(SystemConfig::class);
762
-			return new RedisFactory($systemConfig, $c->getEventLogger());
763
-		});
764
-
765
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
766
-			$l10n = $this->get(IFactory::class)->get('lib');
767
-			return new \OC\Activity\Manager(
768
-				$c->getRequest(),
769
-				$c->get(IUserSession::class),
770
-				$c->get(\OCP\IConfig::class),
771
-				$c->get(IValidator::class),
772
-				$l10n
773
-			);
774
-		});
775
-		/** @deprecated 19.0.0 */
776
-		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
777
-
778
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
779
-			return new \OC\Activity\EventMerger(
780
-				$c->getL10N('lib')
781
-			);
782
-		});
783
-		$this->registerAlias(IValidator::class, Validator::class);
784
-
785
-		$this->registerService(AvatarManager::class, function (Server $c) {
786
-			return new AvatarManager(
787
-				$c->get(IUserSession::class),
788
-				$c->get(\OC\User\Manager::class),
789
-				$c->getAppDataDir('avatar'),
790
-				$c->getL10N('lib'),
791
-				$c->get(LoggerInterface::class),
792
-				$c->get(\OCP\IConfig::class),
793
-				$c->get(IAccountManager::class),
794
-				$c->get(KnownUserService::class)
795
-			);
796
-		});
797
-
798
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
799
-		/** @deprecated 19.0.0 */
800
-		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
801
-
802
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
803
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
804
-		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
805
-
806
-		$this->registerService(\OC\Log::class, function (Server $c) {
807
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
808
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
809
-			$logger = $factory->get($logType);
810
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
811
-
812
-			return new Log($logger, $this->get(SystemConfig::class), null, $registry);
813
-		});
814
-		$this->registerAlias(ILogger::class, \OC\Log::class);
815
-		/** @deprecated 19.0.0 */
816
-		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
817
-		// PSR-3 logger
818
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
819
-
820
-		$this->registerService(ILogFactory::class, function (Server $c) {
821
-			return new LogFactory($c, $this->get(SystemConfig::class));
822
-		});
823
-
824
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
825
-		/** @deprecated 19.0.0 */
826
-		$this->registerDeprecatedAlias('JobList', IJobList::class);
827
-
828
-		$this->registerService(Router::class, function (Server $c) {
829
-			$cacheFactory = $c->get(ICacheFactory::class);
830
-			if ($cacheFactory->isLocalCacheAvailable()) {
831
-				$router = $c->resolve(CachingRouter::class);
832
-			} else {
833
-				$router = $c->resolve(Router::class);
834
-			}
835
-			return $router;
836
-		});
837
-		$this->registerAlias(IRouter::class, Router::class);
838
-		/** @deprecated 19.0.0 */
839
-		$this->registerDeprecatedAlias('Router', IRouter::class);
840
-
841
-		$this->registerAlias(ISearch::class, Search::class);
842
-		/** @deprecated 19.0.0 */
843
-		$this->registerDeprecatedAlias('Search', ISearch::class);
844
-
845
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
846
-			$cacheFactory = $c->get(ICacheFactory::class);
847
-			if ($cacheFactory->isAvailable()) {
848
-				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
849
-					$c->get(AllConfig::class),
850
-					$this->get(ICacheFactory::class),
851
-					new \OC\AppFramework\Utility\TimeFactory()
852
-				);
853
-			} else {
854
-				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
855
-					$c->get(AllConfig::class),
856
-					$c->get(IDBConnection::class),
857
-					new \OC\AppFramework\Utility\TimeFactory()
858
-				);
859
-			}
860
-
861
-			return $backend;
862
-		});
863
-
864
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
865
-		/** @deprecated 19.0.0 */
866
-		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
867
-		$this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
868
-		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
869
-
870
-		$this->registerAlias(ICrypto::class, Crypto::class);
871
-		/** @deprecated 19.0.0 */
872
-		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
873
-
874
-		$this->registerAlias(IHasher::class, Hasher::class);
875
-		/** @deprecated 19.0.0 */
876
-		$this->registerDeprecatedAlias('Hasher', IHasher::class);
877
-
878
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
879
-		/** @deprecated 19.0.0 */
880
-		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
881
-
882
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
883
-		$this->registerService(Connection::class, function (Server $c) {
884
-			$systemConfig = $c->get(SystemConfig::class);
885
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
886
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
887
-			if (!$factory->isValidType($type)) {
888
-				throw new \OC\DatabaseException('Invalid database type');
889
-			}
890
-			$connectionParams = $factory->createConnectionParams();
891
-			$connection = $factory->getConnection($type, $connectionParams);
892
-			return $connection;
893
-		});
894
-		/** @deprecated 19.0.0 */
895
-		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
896
-
897
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
898
-		$this->registerAlias(IClientService::class, ClientService::class);
899
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
900
-			return new NegativeDnsCache(
901
-				$c->get(ICacheFactory::class),
902
-			);
903
-		});
904
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
905
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
906
-			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
907
-		});
908
-		/** @deprecated 19.0.0 */
909
-		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
910
-
911
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
912
-			$queryLogger = new QueryLogger();
913
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
914
-				// In debug mode, module is being activated by default
915
-				$queryLogger->activate();
916
-			}
917
-			return $queryLogger;
918
-		});
919
-		/** @deprecated 19.0.0 */
920
-		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
921
-
922
-		/** @deprecated 19.0.0 */
923
-		$this->registerDeprecatedAlias('TempManager', TempManager::class);
924
-		$this->registerAlias(ITempManager::class, TempManager::class);
925
-
926
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
927
-			// TODO: use auto-wiring
928
-			return new \OC\App\AppManager(
929
-				$c->get(IUserSession::class),
930
-				$c->get(\OCP\IConfig::class),
931
-				$c->get(\OC\AppConfig::class),
932
-				$c->get(IGroupManager::class),
933
-				$c->get(ICacheFactory::class),
934
-				$c->get(SymfonyAdapter::class),
935
-				$c->get(IEventDispatcher::class),
936
-				$c->get(LoggerInterface::class)
937
-			);
938
-		});
939
-		/** @deprecated 19.0.0 */
940
-		$this->registerDeprecatedAlias('AppManager', AppManager::class);
941
-		$this->registerAlias(IAppManager::class, AppManager::class);
942
-
943
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
944
-		/** @deprecated 19.0.0 */
945
-		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
946
-
947
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
948
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
949
-
950
-			return new DateTimeFormatter(
951
-				$c->get(IDateTimeZone::class)->getTimeZone(),
952
-				$c->getL10N('lib', $language)
953
-			);
954
-		});
955
-		/** @deprecated 19.0.0 */
956
-		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
957
-
958
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
959
-			$mountCache = $c->get(UserMountCache::class);
960
-			$listener = new UserMountCacheListener($mountCache);
961
-			$listener->listen($c->get(IUserManager::class));
962
-			return $mountCache;
963
-		});
964
-		/** @deprecated 19.0.0 */
965
-		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
966
-
967
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
968
-			$loader = $c->get(IStorageFactory::class);
969
-			$mountCache = $c->get(IUserMountCache::class);
970
-			$eventLogger = $c->get(IEventLogger::class);
971
-			$manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
972
-
973
-			// builtin providers
974
-
975
-			$config = $c->get(\OCP\IConfig::class);
976
-			$logger = $c->get(LoggerInterface::class);
977
-			$manager->registerProvider(new CacheMountProvider($config));
978
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
979
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
980
-			$manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
981
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
982
-
983
-			return $manager;
984
-		});
985
-		/** @deprecated 19.0.0 */
986
-		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
987
-
988
-		/** @deprecated 20.0.0 */
989
-		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
990
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
991
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
992
-			if ($busClass) {
993
-				[$app, $class] = explode('::', $busClass, 2);
994
-				if ($c->get(IAppManager::class)->isInstalled($app)) {
995
-					\OC_App::loadApp($app);
996
-					return $c->get($class);
997
-				} else {
998
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
999
-				}
1000
-			} else {
1001
-				$jobList = $c->get(IJobList::class);
1002
-				return new CronBus($jobList);
1003
-			}
1004
-		});
1005
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
1006
-		/** @deprecated 20.0.0 */
1007
-		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1008
-		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1009
-		/** @deprecated 19.0.0 */
1010
-		$this->registerDeprecatedAlias('Throttler', Throttler::class);
1011
-		$this->registerAlias(IThrottler::class, Throttler::class);
1012
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1013
-			// IConfig and IAppManager requires a working database. This code
1014
-			// might however be called when ownCloud is not yet setup.
1015
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1016
-				$config = $c->get(\OCP\IConfig::class);
1017
-				$appManager = $c->get(IAppManager::class);
1018
-			} else {
1019
-				$config = null;
1020
-				$appManager = null;
1021
-			}
1022
-
1023
-			return new Checker(
1024
-				new EnvironmentHelper(),
1025
-				new FileAccessHelper(),
1026
-				new AppLocator(),
1027
-				$config,
1028
-				$c->get(ICacheFactory::class),
1029
-				$appManager,
1030
-				$c->get(IMimeTypeDetector::class)
1031
-			);
1032
-		});
1033
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1034
-			if (isset($this['urlParams'])) {
1035
-				$urlParams = $this['urlParams'];
1036
-			} else {
1037
-				$urlParams = [];
1038
-			}
1039
-
1040
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1041
-				&& in_array('fakeinput', stream_get_wrappers())
1042
-			) {
1043
-				$stream = 'fakeinput://data';
1044
-			} else {
1045
-				$stream = 'php://input';
1046
-			}
1047
-
1048
-			return new Request(
1049
-				[
1050
-					'get' => $_GET,
1051
-					'post' => $_POST,
1052
-					'files' => $_FILES,
1053
-					'server' => $_SERVER,
1054
-					'env' => $_ENV,
1055
-					'cookies' => $_COOKIE,
1056
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1057
-						? $_SERVER['REQUEST_METHOD']
1058
-						: '',
1059
-					'urlParams' => $urlParams,
1060
-				],
1061
-				$this->get(IRequestId::class),
1062
-				$this->get(\OCP\IConfig::class),
1063
-				$this->get(CsrfTokenManager::class),
1064
-				$stream
1065
-			);
1066
-		});
1067
-		/** @deprecated 19.0.0 */
1068
-		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1069
-
1070
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1071
-			return new RequestId(
1072
-				$_SERVER['UNIQUE_ID'] ?? '',
1073
-				$this->get(ISecureRandom::class)
1074
-			);
1075
-		});
1076
-
1077
-		$this->registerService(IMailer::class, function (Server $c) {
1078
-			return new Mailer(
1079
-				$c->get(\OCP\IConfig::class),
1080
-				$c->get(LoggerInterface::class),
1081
-				$c->get(Defaults::class),
1082
-				$c->get(IURLGenerator::class),
1083
-				$c->getL10N('lib'),
1084
-				$c->get(IEventDispatcher::class),
1085
-				$c->get(IFactory::class)
1086
-			);
1087
-		});
1088
-		/** @deprecated 19.0.0 */
1089
-		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1090
-
1091
-		/** @deprecated 21.0.0 */
1092
-		$this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1093
-
1094
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1095
-			$config = $c->get(\OCP\IConfig::class);
1096
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1097
-			if (is_null($factoryClass) || !class_exists($factoryClass)) {
1098
-				return new NullLDAPProviderFactory($this);
1099
-			}
1100
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1101
-			return new $factoryClass($this);
1102
-		});
1103
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1104
-			$factory = $c->get(ILDAPProviderFactory::class);
1105
-			return $factory->getLDAPProvider();
1106
-		});
1107
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1108
-			$ini = $c->get(IniGetWrapper::class);
1109
-			$config = $c->get(\OCP\IConfig::class);
1110
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1111
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1112
-				/** @var \OC\Memcache\Factory $memcacheFactory */
1113
-				$memcacheFactory = $c->get(ICacheFactory::class);
1114
-				$memcache = $memcacheFactory->createLocking('lock');
1115
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
1116
-					return new MemcacheLockingProvider($memcache, $ttl);
1117
-				}
1118
-				return new DBLockingProvider(
1119
-					$c->get(IDBConnection::class),
1120
-					new TimeFactory(),
1121
-					$ttl,
1122
-					!\OC::$CLI
1123
-				);
1124
-			}
1125
-			return new NoopLockingProvider();
1126
-		});
1127
-		/** @deprecated 19.0.0 */
1128
-		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1129
-
1130
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
1131
-			return new LockManager();
1132
-		});
1133
-
1134
-		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
1135
-		$this->registerService(SetupManager::class, function ($c) {
1136
-			// create the setupmanager through the mount manager to resolve the cyclic dependency
1137
-			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1138
-		});
1139
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1140
-		/** @deprecated 19.0.0 */
1141
-		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1142
-
1143
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1144
-			return new \OC\Files\Type\Detection(
1145
-				$c->get(IURLGenerator::class),
1146
-				$c->get(LoggerInterface::class),
1147
-				\OC::$configDir,
1148
-				\OC::$SERVERROOT . '/resources/config/'
1149
-			);
1150
-		});
1151
-		/** @deprecated 19.0.0 */
1152
-		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1153
-
1154
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1155
-		/** @deprecated 19.0.0 */
1156
-		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1157
-		$this->registerService(BundleFetcher::class, function () {
1158
-			return new BundleFetcher($this->getL10N('lib'));
1159
-		});
1160
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1161
-		/** @deprecated 19.0.0 */
1162
-		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1163
-
1164
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1165
-			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1166
-			$manager->registerCapability(function () use ($c) {
1167
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1168
-			});
1169
-			$manager->registerCapability(function () use ($c) {
1170
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1171
-			});
1172
-			$manager->registerCapability(function () use ($c) {
1173
-				return $c->get(MetadataCapabilities::class);
1174
-			});
1175
-			return $manager;
1176
-		});
1177
-		/** @deprecated 19.0.0 */
1178
-		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1179
-
1180
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1181
-			$config = $c->get(\OCP\IConfig::class);
1182
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1183
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1184
-			$factory = new $factoryClass($this);
1185
-			$manager = $factory->getManager();
1186
-
1187
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1188
-				$manager = $c->get(IUserManager::class);
1189
-				$userDisplayName = $manager->getDisplayName($id);
1190
-				if ($userDisplayName === null) {
1191
-					$l = $c->get(IFactory::class)->get('core');
1192
-					return $l->t('Unknown user');
1193
-				}
1194
-				return $userDisplayName;
1195
-			});
1196
-
1197
-			return $manager;
1198
-		});
1199
-		/** @deprecated 19.0.0 */
1200
-		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1201
-
1202
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1203
-		$this->registerService('ThemingDefaults', function (Server $c) {
1204
-			try {
1205
-				$classExists = class_exists('OCA\Theming\ThemingDefaults');
1206
-			} catch (\OCP\AutoloadNotAllowedException $e) {
1207
-				// App disabled or in maintenance mode
1208
-				$classExists = false;
1209
-			}
1210
-
1211
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1212
-				$imageManager = new ImageManager(
1213
-					$c->get(\OCP\IConfig::class),
1214
-					$c->getAppDataDir('theming'),
1215
-					$c->get(IURLGenerator::class),
1216
-					$this->get(ICacheFactory::class),
1217
-					$this->get(ILogger::class),
1218
-					$this->get(ITempManager::class)
1219
-				);
1220
-				return new ThemingDefaults(
1221
-					$c->get(\OCP\IConfig::class),
1222
-					$c->getL10N('theming'),
1223
-					$c->get(IUserSession::class),
1224
-					$c->get(IURLGenerator::class),
1225
-					$c->get(ICacheFactory::class),
1226
-					new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1227
-					$imageManager,
1228
-					$c->get(IAppManager::class),
1229
-					$c->get(INavigationManager::class)
1230
-				);
1231
-			}
1232
-			return new \OC_Defaults();
1233
-		});
1234
-		$this->registerService(JSCombiner::class, function (Server $c) {
1235
-			return new JSCombiner(
1236
-				$c->getAppDataDir('js'),
1237
-				$c->get(IURLGenerator::class),
1238
-				$this->get(ICacheFactory::class),
1239
-				$c->get(SystemConfig::class),
1240
-				$c->get(LoggerInterface::class)
1241
-			);
1242
-		});
1243
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1244
-		/** @deprecated 19.0.0 */
1245
-		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1246
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1247
-
1248
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1249
-			// FIXME: Instantiated here due to cyclic dependency
1250
-			$request = new Request(
1251
-				[
1252
-					'get' => $_GET,
1253
-					'post' => $_POST,
1254
-					'files' => $_FILES,
1255
-					'server' => $_SERVER,
1256
-					'env' => $_ENV,
1257
-					'cookies' => $_COOKIE,
1258
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1259
-						? $_SERVER['REQUEST_METHOD']
1260
-						: null,
1261
-				],
1262
-				$c->get(IRequestId::class),
1263
-				$c->get(\OCP\IConfig::class)
1264
-			);
1265
-
1266
-			return new CryptoWrapper(
1267
-				$c->get(\OCP\IConfig::class),
1268
-				$c->get(ICrypto::class),
1269
-				$c->get(ISecureRandom::class),
1270
-				$request
1271
-			);
1272
-		});
1273
-		/** @deprecated 19.0.0 */
1274
-		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1275
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1276
-			return new SessionStorage($c->get(ISession::class));
1277
-		});
1278
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1279
-		/** @deprecated 19.0.0 */
1280
-		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1281
-
1282
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1283
-			$config = $c->get(\OCP\IConfig::class);
1284
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1285
-			/** @var \OCP\Share\IProviderFactory $factory */
1286
-			$factory = new $factoryClass($this);
1287
-
1288
-			$manager = new \OC\Share20\Manager(
1289
-				$c->get(LoggerInterface::class),
1290
-				$c->get(\OCP\IConfig::class),
1291
-				$c->get(ISecureRandom::class),
1292
-				$c->get(IHasher::class),
1293
-				$c->get(IMountManager::class),
1294
-				$c->get(IGroupManager::class),
1295
-				$c->getL10N('lib'),
1296
-				$c->get(IFactory::class),
1297
-				$factory,
1298
-				$c->get(IUserManager::class),
1299
-				$c->get(IRootFolder::class),
1300
-				$c->get(SymfonyAdapter::class),
1301
-				$c->get(IMailer::class),
1302
-				$c->get(IURLGenerator::class),
1303
-				$c->get('ThemingDefaults'),
1304
-				$c->get(IEventDispatcher::class),
1305
-				$c->get(IUserSession::class),
1306
-				$c->get(KnownUserService::class)
1307
-			);
1308
-
1309
-			return $manager;
1310
-		});
1311
-		/** @deprecated 19.0.0 */
1312
-		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1313
-
1314
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1315
-			$instance = new Collaboration\Collaborators\Search($c);
1316
-
1317
-			// register default plugins
1318
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1319
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1320
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1321
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1322
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1323
-
1324
-			return $instance;
1325
-		});
1326
-		/** @deprecated 19.0.0 */
1327
-		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1328
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1329
-
1330
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1331
-
1332
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1333
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1334
-
1335
-		$this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1336
-
1337
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1338
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1339
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1340
-			return new \OC\Files\AppData\Factory(
1341
-				$c->get(IRootFolder::class),
1342
-				$c->get(SystemConfig::class)
1343
-			);
1344
-		});
1345
-
1346
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1347
-			return new LockdownManager(function () use ($c) {
1348
-				return $c->get(ISession::class);
1349
-			});
1350
-		});
1351
-
1352
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1353
-			return new DiscoveryService(
1354
-				$c->get(ICacheFactory::class),
1355
-				$c->get(IClientService::class)
1356
-			);
1357
-		});
1358
-
1359
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1360
-			return new CloudIdManager(
1361
-				$c->get(\OCP\Contacts\IManager::class),
1362
-				$c->get(IURLGenerator::class),
1363
-				$c->get(IUserManager::class),
1364
-				$c->get(ICacheFactory::class),
1365
-				$c->get(IEventDispatcher::class),
1366
-			);
1367
-		});
1368
-
1369
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1370
-
1371
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1372
-			return new CloudFederationProviderManager(
1373
-				$c->get(IAppManager::class),
1374
-				$c->get(IClientService::class),
1375
-				$c->get(ICloudIdManager::class),
1376
-				$c->get(LoggerInterface::class)
1377
-			);
1378
-		});
1379
-
1380
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1381
-			return new CloudFederationFactory();
1382
-		});
1383
-
1384
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1385
-		/** @deprecated 19.0.0 */
1386
-		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1387
-
1388
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1389
-		$this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1390
-		/** @deprecated 19.0.0 */
1391
-		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1392
-
1393
-		$this->registerService(Defaults::class, function (Server $c) {
1394
-			return new Defaults(
1395
-				$c->getThemingDefaults()
1396
-			);
1397
-		});
1398
-		/** @deprecated 19.0.0 */
1399
-		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1400
-
1401
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1402
-			return $c->get(\OCP\IUserSession::class)->getSession();
1403
-		}, false);
1404
-
1405
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1406
-			return new ShareHelper(
1407
-				$c->get(\OCP\Share\IManager::class)
1408
-			);
1409
-		});
1410
-
1411
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1412
-			return new Installer(
1413
-				$c->get(AppFetcher::class),
1414
-				$c->get(IClientService::class),
1415
-				$c->get(ITempManager::class),
1416
-				$c->get(LoggerInterface::class),
1417
-				$c->get(\OCP\IConfig::class),
1418
-				\OC::$CLI
1419
-			);
1420
-		});
1421
-
1422
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1423
-			return new ApiFactory($c->get(IClientService::class));
1424
-		});
1425
-
1426
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1427
-			$memcacheFactory = $c->get(ICacheFactory::class);
1428
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1429
-		});
1430
-
1431
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1432
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1433
-
1434
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1435
-
1436
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1437
-
1438
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1439
-
1440
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1441
-
1442
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1443
-
1444
-		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1445
-
1446
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1447
-
1448
-		$this->registerAlias(IBroker::class, Broker::class);
1449
-
1450
-		$this->registerAlias(IMetadataManager::class, MetadataManager::class);
1451
-
1452
-		$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1453
-
1454
-		$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1455
-
1456
-		$this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1457
-
1458
-		$this->registerAlias(ITranslationManager::class, TranslationManager::class);
1459
-
1460
-		$this->connectDispatcher();
1461
-	}
1462
-
1463
-	public function boot() {
1464
-		/** @var HookConnector $hookConnector */
1465
-		$hookConnector = $this->get(HookConnector::class);
1466
-		$hookConnector->viewToNode();
1467
-	}
1468
-
1469
-	/**
1470
-	 * @return \OCP\Calendar\IManager
1471
-	 * @deprecated 20.0.0
1472
-	 */
1473
-	public function getCalendarManager() {
1474
-		return $this->get(\OC\Calendar\Manager::class);
1475
-	}
1476
-
1477
-	/**
1478
-	 * @return \OCP\Calendar\Resource\IManager
1479
-	 * @deprecated 20.0.0
1480
-	 */
1481
-	public function getCalendarResourceBackendManager() {
1482
-		return $this->get(\OC\Calendar\Resource\Manager::class);
1483
-	}
1484
-
1485
-	/**
1486
-	 * @return \OCP\Calendar\Room\IManager
1487
-	 * @deprecated 20.0.0
1488
-	 */
1489
-	public function getCalendarRoomBackendManager() {
1490
-		return $this->get(\OC\Calendar\Room\Manager::class);
1491
-	}
1492
-
1493
-	private function connectDispatcher(): void {
1494
-		/** @var IEventDispatcher $eventDispatcher */
1495
-		$eventDispatcher = $this->get(IEventDispatcher::class);
1496
-		$eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1497
-		$eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1498
-		$eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1499
-		$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1500
-	}
1501
-
1502
-	/**
1503
-	 * @return \OCP\Contacts\IManager
1504
-	 * @deprecated 20.0.0
1505
-	 */
1506
-	public function getContactsManager() {
1507
-		return $this->get(\OCP\Contacts\IManager::class);
1508
-	}
1509
-
1510
-	/**
1511
-	 * @return \OC\Encryption\Manager
1512
-	 * @deprecated 20.0.0
1513
-	 */
1514
-	public function getEncryptionManager() {
1515
-		return $this->get(\OCP\Encryption\IManager::class);
1516
-	}
1517
-
1518
-	/**
1519
-	 * @return \OC\Encryption\File
1520
-	 * @deprecated 20.0.0
1521
-	 */
1522
-	public function getEncryptionFilesHelper() {
1523
-		return $this->get(IFile::class);
1524
-	}
1525
-
1526
-	/**
1527
-	 * @return \OCP\Encryption\Keys\IStorage
1528
-	 * @deprecated 20.0.0
1529
-	 */
1530
-	public function getEncryptionKeyStorage() {
1531
-		return $this->get(IStorage::class);
1532
-	}
1533
-
1534
-	/**
1535
-	 * The current request object holding all information about the request
1536
-	 * currently being processed is returned from this method.
1537
-	 * In case the current execution was not initiated by a web request null is returned
1538
-	 *
1539
-	 * @return \OCP\IRequest
1540
-	 * @deprecated 20.0.0
1541
-	 */
1542
-	public function getRequest() {
1543
-		return $this->get(IRequest::class);
1544
-	}
1545
-
1546
-	/**
1547
-	 * Returns the preview manager which can create preview images for a given file
1548
-	 *
1549
-	 * @return IPreview
1550
-	 * @deprecated 20.0.0
1551
-	 */
1552
-	public function getPreviewManager() {
1553
-		return $this->get(IPreview::class);
1554
-	}
1555
-
1556
-	/**
1557
-	 * Returns the tag manager which can get and set tags for different object types
1558
-	 *
1559
-	 * @see \OCP\ITagManager::load()
1560
-	 * @return ITagManager
1561
-	 * @deprecated 20.0.0
1562
-	 */
1563
-	public function getTagManager() {
1564
-		return $this->get(ITagManager::class);
1565
-	}
1566
-
1567
-	/**
1568
-	 * Returns the system-tag manager
1569
-	 *
1570
-	 * @return ISystemTagManager
1571
-	 *
1572
-	 * @since 9.0.0
1573
-	 * @deprecated 20.0.0
1574
-	 */
1575
-	public function getSystemTagManager() {
1576
-		return $this->get(ISystemTagManager::class);
1577
-	}
1578
-
1579
-	/**
1580
-	 * Returns the system-tag object mapper
1581
-	 *
1582
-	 * @return ISystemTagObjectMapper
1583
-	 *
1584
-	 * @since 9.0.0
1585
-	 * @deprecated 20.0.0
1586
-	 */
1587
-	public function getSystemTagObjectMapper() {
1588
-		return $this->get(ISystemTagObjectMapper::class);
1589
-	}
1590
-
1591
-	/**
1592
-	 * Returns the avatar manager, used for avatar functionality
1593
-	 *
1594
-	 * @return IAvatarManager
1595
-	 * @deprecated 20.0.0
1596
-	 */
1597
-	public function getAvatarManager() {
1598
-		return $this->get(IAvatarManager::class);
1599
-	}
1600
-
1601
-	/**
1602
-	 * Returns the root folder of ownCloud's data directory
1603
-	 *
1604
-	 * @return IRootFolder
1605
-	 * @deprecated 20.0.0
1606
-	 */
1607
-	public function getRootFolder() {
1608
-		return $this->get(IRootFolder::class);
1609
-	}
1610
-
1611
-	/**
1612
-	 * Returns the root folder of ownCloud's data directory
1613
-	 * This is the lazy variant so this gets only initialized once it
1614
-	 * is actually used.
1615
-	 *
1616
-	 * @return IRootFolder
1617
-	 * @deprecated 20.0.0
1618
-	 */
1619
-	public function getLazyRootFolder() {
1620
-		return $this->get(IRootFolder::class);
1621
-	}
1622
-
1623
-	/**
1624
-	 * Returns a view to ownCloud's files folder
1625
-	 *
1626
-	 * @param string $userId user ID
1627
-	 * @return \OCP\Files\Folder|null
1628
-	 * @deprecated 20.0.0
1629
-	 */
1630
-	public function getUserFolder($userId = null) {
1631
-		if ($userId === null) {
1632
-			$user = $this->get(IUserSession::class)->getUser();
1633
-			if (!$user) {
1634
-				return null;
1635
-			}
1636
-			$userId = $user->getUID();
1637
-		}
1638
-		$root = $this->get(IRootFolder::class);
1639
-		return $root->getUserFolder($userId);
1640
-	}
1641
-
1642
-	/**
1643
-	 * @return \OC\User\Manager
1644
-	 * @deprecated 20.0.0
1645
-	 */
1646
-	public function getUserManager() {
1647
-		return $this->get(IUserManager::class);
1648
-	}
1649
-
1650
-	/**
1651
-	 * @return \OC\Group\Manager
1652
-	 * @deprecated 20.0.0
1653
-	 */
1654
-	public function getGroupManager() {
1655
-		return $this->get(IGroupManager::class);
1656
-	}
1657
-
1658
-	/**
1659
-	 * @return \OC\User\Session
1660
-	 * @deprecated 20.0.0
1661
-	 */
1662
-	public function getUserSession() {
1663
-		return $this->get(IUserSession::class);
1664
-	}
1665
-
1666
-	/**
1667
-	 * @return \OCP\ISession
1668
-	 * @deprecated 20.0.0
1669
-	 */
1670
-	public function getSession() {
1671
-		return $this->get(Session::class)->getSession();
1672
-	}
1673
-
1674
-	/**
1675
-	 * @param \OCP\ISession $session
1676
-	 */
1677
-	public function setSession(\OCP\ISession $session) {
1678
-		$this->get(SessionStorage::class)->setSession($session);
1679
-		$this->get(Session::class)->setSession($session);
1680
-		$this->get(Store::class)->setSession($session);
1681
-	}
1682
-
1683
-	/**
1684
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1685
-	 * @deprecated 20.0.0
1686
-	 */
1687
-	public function getTwoFactorAuthManager() {
1688
-		return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1689
-	}
1690
-
1691
-	/**
1692
-	 * @return \OC\NavigationManager
1693
-	 * @deprecated 20.0.0
1694
-	 */
1695
-	public function getNavigationManager() {
1696
-		return $this->get(INavigationManager::class);
1697
-	}
1698
-
1699
-	/**
1700
-	 * @return \OCP\IConfig
1701
-	 * @deprecated 20.0.0
1702
-	 */
1703
-	public function getConfig() {
1704
-		return $this->get(AllConfig::class);
1705
-	}
1706
-
1707
-	/**
1708
-	 * @return \OC\SystemConfig
1709
-	 * @deprecated 20.0.0
1710
-	 */
1711
-	public function getSystemConfig() {
1712
-		return $this->get(SystemConfig::class);
1713
-	}
1714
-
1715
-	/**
1716
-	 * Returns the app config manager
1717
-	 *
1718
-	 * @return IAppConfig
1719
-	 * @deprecated 20.0.0
1720
-	 */
1721
-	public function getAppConfig() {
1722
-		return $this->get(IAppConfig::class);
1723
-	}
1724
-
1725
-	/**
1726
-	 * @return IFactory
1727
-	 * @deprecated 20.0.0
1728
-	 */
1729
-	public function getL10NFactory() {
1730
-		return $this->get(IFactory::class);
1731
-	}
1732
-
1733
-	/**
1734
-	 * get an L10N instance
1735
-	 *
1736
-	 * @param string $app appid
1737
-	 * @param string $lang
1738
-	 * @return IL10N
1739
-	 * @deprecated 20.0.0
1740
-	 */
1741
-	public function getL10N($app, $lang = null) {
1742
-		return $this->get(IFactory::class)->get($app, $lang);
1743
-	}
1744
-
1745
-	/**
1746
-	 * @return IURLGenerator
1747
-	 * @deprecated 20.0.0
1748
-	 */
1749
-	public function getURLGenerator() {
1750
-		return $this->get(IURLGenerator::class);
1751
-	}
1752
-
1753
-	/**
1754
-	 * @return AppFetcher
1755
-	 * @deprecated 20.0.0
1756
-	 */
1757
-	public function getAppFetcher() {
1758
-		return $this->get(AppFetcher::class);
1759
-	}
1760
-
1761
-	/**
1762
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1763
-	 * getMemCacheFactory() instead.
1764
-	 *
1765
-	 * @return ICache
1766
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1767
-	 */
1768
-	public function getCache() {
1769
-		return $this->get(ICache::class);
1770
-	}
1771
-
1772
-	/**
1773
-	 * Returns an \OCP\CacheFactory instance
1774
-	 *
1775
-	 * @return \OCP\ICacheFactory
1776
-	 * @deprecated 20.0.0
1777
-	 */
1778
-	public function getMemCacheFactory() {
1779
-		return $this->get(ICacheFactory::class);
1780
-	}
1781
-
1782
-	/**
1783
-	 * Returns an \OC\RedisFactory instance
1784
-	 *
1785
-	 * @return \OC\RedisFactory
1786
-	 * @deprecated 20.0.0
1787
-	 */
1788
-	public function getGetRedisFactory() {
1789
-		return $this->get('RedisFactory');
1790
-	}
1791
-
1792
-
1793
-	/**
1794
-	 * Returns the current session
1795
-	 *
1796
-	 * @return \OCP\IDBConnection
1797
-	 * @deprecated 20.0.0
1798
-	 */
1799
-	public function getDatabaseConnection() {
1800
-		return $this->get(IDBConnection::class);
1801
-	}
1802
-
1803
-	/**
1804
-	 * Returns the activity manager
1805
-	 *
1806
-	 * @return \OCP\Activity\IManager
1807
-	 * @deprecated 20.0.0
1808
-	 */
1809
-	public function getActivityManager() {
1810
-		return $this->get(\OCP\Activity\IManager::class);
1811
-	}
1812
-
1813
-	/**
1814
-	 * Returns an job list for controlling background jobs
1815
-	 *
1816
-	 * @return IJobList
1817
-	 * @deprecated 20.0.0
1818
-	 */
1819
-	public function getJobList() {
1820
-		return $this->get(IJobList::class);
1821
-	}
1822
-
1823
-	/**
1824
-	 * Returns a logger instance
1825
-	 *
1826
-	 * @return ILogger
1827
-	 * @deprecated 20.0.0
1828
-	 */
1829
-	public function getLogger() {
1830
-		return $this->get(ILogger::class);
1831
-	}
1832
-
1833
-	/**
1834
-	 * @return ILogFactory
1835
-	 * @throws \OCP\AppFramework\QueryException
1836
-	 * @deprecated 20.0.0
1837
-	 */
1838
-	public function getLogFactory() {
1839
-		return $this->get(ILogFactory::class);
1840
-	}
1841
-
1842
-	/**
1843
-	 * Returns a router for generating and matching urls
1844
-	 *
1845
-	 * @return IRouter
1846
-	 * @deprecated 20.0.0
1847
-	 */
1848
-	public function getRouter() {
1849
-		return $this->get(IRouter::class);
1850
-	}
1851
-
1852
-	/**
1853
-	 * Returns a search instance
1854
-	 *
1855
-	 * @return ISearch
1856
-	 * @deprecated 20.0.0
1857
-	 */
1858
-	public function getSearch() {
1859
-		return $this->get(ISearch::class);
1860
-	}
1861
-
1862
-	/**
1863
-	 * Returns a SecureRandom instance
1864
-	 *
1865
-	 * @return \OCP\Security\ISecureRandom
1866
-	 * @deprecated 20.0.0
1867
-	 */
1868
-	public function getSecureRandom() {
1869
-		return $this->get(ISecureRandom::class);
1870
-	}
1871
-
1872
-	/**
1873
-	 * Returns a Crypto instance
1874
-	 *
1875
-	 * @return ICrypto
1876
-	 * @deprecated 20.0.0
1877
-	 */
1878
-	public function getCrypto() {
1879
-		return $this->get(ICrypto::class);
1880
-	}
1881
-
1882
-	/**
1883
-	 * Returns a Hasher instance
1884
-	 *
1885
-	 * @return IHasher
1886
-	 * @deprecated 20.0.0
1887
-	 */
1888
-	public function getHasher() {
1889
-		return $this->get(IHasher::class);
1890
-	}
1891
-
1892
-	/**
1893
-	 * Returns a CredentialsManager instance
1894
-	 *
1895
-	 * @return ICredentialsManager
1896
-	 * @deprecated 20.0.0
1897
-	 */
1898
-	public function getCredentialsManager() {
1899
-		return $this->get(ICredentialsManager::class);
1900
-	}
1901
-
1902
-	/**
1903
-	 * Get the certificate manager
1904
-	 *
1905
-	 * @return \OCP\ICertificateManager
1906
-	 */
1907
-	public function getCertificateManager() {
1908
-		return $this->get(ICertificateManager::class);
1909
-	}
1910
-
1911
-	/**
1912
-	 * Returns an instance of the HTTP client service
1913
-	 *
1914
-	 * @return IClientService
1915
-	 * @deprecated 20.0.0
1916
-	 */
1917
-	public function getHTTPClientService() {
1918
-		return $this->get(IClientService::class);
1919
-	}
1920
-
1921
-	/**
1922
-	 * Create a new event source
1923
-	 *
1924
-	 * @return \OCP\IEventSource
1925
-	 * @deprecated 20.0.0
1926
-	 */
1927
-	public function createEventSource() {
1928
-		return new \OC_EventSource();
1929
-	}
1930
-
1931
-	/**
1932
-	 * Get the active event logger
1933
-	 *
1934
-	 * The returned logger only logs data when debug mode is enabled
1935
-	 *
1936
-	 * @return IEventLogger
1937
-	 * @deprecated 20.0.0
1938
-	 */
1939
-	public function getEventLogger() {
1940
-		return $this->get(IEventLogger::class);
1941
-	}
1942
-
1943
-	/**
1944
-	 * Get the active query logger
1945
-	 *
1946
-	 * The returned logger only logs data when debug mode is enabled
1947
-	 *
1948
-	 * @return IQueryLogger
1949
-	 * @deprecated 20.0.0
1950
-	 */
1951
-	public function getQueryLogger() {
1952
-		return $this->get(IQueryLogger::class);
1953
-	}
1954
-
1955
-	/**
1956
-	 * Get the manager for temporary files and folders
1957
-	 *
1958
-	 * @return \OCP\ITempManager
1959
-	 * @deprecated 20.0.0
1960
-	 */
1961
-	public function getTempManager() {
1962
-		return $this->get(ITempManager::class);
1963
-	}
1964
-
1965
-	/**
1966
-	 * Get the app manager
1967
-	 *
1968
-	 * @return \OCP\App\IAppManager
1969
-	 * @deprecated 20.0.0
1970
-	 */
1971
-	public function getAppManager() {
1972
-		return $this->get(IAppManager::class);
1973
-	}
1974
-
1975
-	/**
1976
-	 * Creates a new mailer
1977
-	 *
1978
-	 * @return IMailer
1979
-	 * @deprecated 20.0.0
1980
-	 */
1981
-	public function getMailer() {
1982
-		return $this->get(IMailer::class);
1983
-	}
1984
-
1985
-	/**
1986
-	 * Get the webroot
1987
-	 *
1988
-	 * @return string
1989
-	 * @deprecated 20.0.0
1990
-	 */
1991
-	public function getWebRoot() {
1992
-		return $this->webRoot;
1993
-	}
1994
-
1995
-	/**
1996
-	 * @return \OC\OCSClient
1997
-	 * @deprecated 20.0.0
1998
-	 */
1999
-	public function getOcsClient() {
2000
-		return $this->get('OcsClient');
2001
-	}
2002
-
2003
-	/**
2004
-	 * @return IDateTimeZone
2005
-	 * @deprecated 20.0.0
2006
-	 */
2007
-	public function getDateTimeZone() {
2008
-		return $this->get(IDateTimeZone::class);
2009
-	}
2010
-
2011
-	/**
2012
-	 * @return IDateTimeFormatter
2013
-	 * @deprecated 20.0.0
2014
-	 */
2015
-	public function getDateTimeFormatter() {
2016
-		return $this->get(IDateTimeFormatter::class);
2017
-	}
2018
-
2019
-	/**
2020
-	 * @return IMountProviderCollection
2021
-	 * @deprecated 20.0.0
2022
-	 */
2023
-	public function getMountProviderCollection() {
2024
-		return $this->get(IMountProviderCollection::class);
2025
-	}
2026
-
2027
-	/**
2028
-	 * Get the IniWrapper
2029
-	 *
2030
-	 * @return IniGetWrapper
2031
-	 * @deprecated 20.0.0
2032
-	 */
2033
-	public function getIniWrapper() {
2034
-		return $this->get(IniGetWrapper::class);
2035
-	}
2036
-
2037
-	/**
2038
-	 * @return \OCP\Command\IBus
2039
-	 * @deprecated 20.0.0
2040
-	 */
2041
-	public function getCommandBus() {
2042
-		return $this->get(IBus::class);
2043
-	}
2044
-
2045
-	/**
2046
-	 * Get the trusted domain helper
2047
-	 *
2048
-	 * @return TrustedDomainHelper
2049
-	 * @deprecated 20.0.0
2050
-	 */
2051
-	public function getTrustedDomainHelper() {
2052
-		return $this->get(TrustedDomainHelper::class);
2053
-	}
2054
-
2055
-	/**
2056
-	 * Get the locking provider
2057
-	 *
2058
-	 * @return ILockingProvider
2059
-	 * @since 8.1.0
2060
-	 * @deprecated 20.0.0
2061
-	 */
2062
-	public function getLockingProvider() {
2063
-		return $this->get(ILockingProvider::class);
2064
-	}
2065
-
2066
-	/**
2067
-	 * @return IMountManager
2068
-	 * @deprecated 20.0.0
2069
-	 **/
2070
-	public function getMountManager() {
2071
-		return $this->get(IMountManager::class);
2072
-	}
2073
-
2074
-	/**
2075
-	 * @return IUserMountCache
2076
-	 * @deprecated 20.0.0
2077
-	 */
2078
-	public function getUserMountCache() {
2079
-		return $this->get(IUserMountCache::class);
2080
-	}
2081
-
2082
-	/**
2083
-	 * Get the MimeTypeDetector
2084
-	 *
2085
-	 * @return IMimeTypeDetector
2086
-	 * @deprecated 20.0.0
2087
-	 */
2088
-	public function getMimeTypeDetector() {
2089
-		return $this->get(IMimeTypeDetector::class);
2090
-	}
2091
-
2092
-	/**
2093
-	 * Get the MimeTypeLoader
2094
-	 *
2095
-	 * @return IMimeTypeLoader
2096
-	 * @deprecated 20.0.0
2097
-	 */
2098
-	public function getMimeTypeLoader() {
2099
-		return $this->get(IMimeTypeLoader::class);
2100
-	}
2101
-
2102
-	/**
2103
-	 * Get the manager of all the capabilities
2104
-	 *
2105
-	 * @return CapabilitiesManager
2106
-	 * @deprecated 20.0.0
2107
-	 */
2108
-	public function getCapabilitiesManager() {
2109
-		return $this->get(CapabilitiesManager::class);
2110
-	}
2111
-
2112
-	/**
2113
-	 * Get the EventDispatcher
2114
-	 *
2115
-	 * @return EventDispatcherInterface
2116
-	 * @since 8.2.0
2117
-	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2118
-	 */
2119
-	public function getEventDispatcher() {
2120
-		return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2121
-	}
2122
-
2123
-	/**
2124
-	 * Get the Notification Manager
2125
-	 *
2126
-	 * @return \OCP\Notification\IManager
2127
-	 * @since 8.2.0
2128
-	 * @deprecated 20.0.0
2129
-	 */
2130
-	public function getNotificationManager() {
2131
-		return $this->get(\OCP\Notification\IManager::class);
2132
-	}
2133
-
2134
-	/**
2135
-	 * @return ICommentsManager
2136
-	 * @deprecated 20.0.0
2137
-	 */
2138
-	public function getCommentsManager() {
2139
-		return $this->get(ICommentsManager::class);
2140
-	}
2141
-
2142
-	/**
2143
-	 * @return \OCA\Theming\ThemingDefaults
2144
-	 * @deprecated 20.0.0
2145
-	 */
2146
-	public function getThemingDefaults() {
2147
-		return $this->get('ThemingDefaults');
2148
-	}
2149
-
2150
-	/**
2151
-	 * @return \OC\IntegrityCheck\Checker
2152
-	 * @deprecated 20.0.0
2153
-	 */
2154
-	public function getIntegrityCodeChecker() {
2155
-		return $this->get('IntegrityCodeChecker');
2156
-	}
2157
-
2158
-	/**
2159
-	 * @return \OC\Session\CryptoWrapper
2160
-	 * @deprecated 20.0.0
2161
-	 */
2162
-	public function getSessionCryptoWrapper() {
2163
-		return $this->get('CryptoWrapper');
2164
-	}
2165
-
2166
-	/**
2167
-	 * @return CsrfTokenManager
2168
-	 * @deprecated 20.0.0
2169
-	 */
2170
-	public function getCsrfTokenManager() {
2171
-		return $this->get(CsrfTokenManager::class);
2172
-	}
2173
-
2174
-	/**
2175
-	 * @return Throttler
2176
-	 * @deprecated 20.0.0
2177
-	 */
2178
-	public function getBruteForceThrottler() {
2179
-		return $this->get(Throttler::class);
2180
-	}
2181
-
2182
-	/**
2183
-	 * @return IContentSecurityPolicyManager
2184
-	 * @deprecated 20.0.0
2185
-	 */
2186
-	public function getContentSecurityPolicyManager() {
2187
-		return $this->get(ContentSecurityPolicyManager::class);
2188
-	}
2189
-
2190
-	/**
2191
-	 * @return ContentSecurityPolicyNonceManager
2192
-	 * @deprecated 20.0.0
2193
-	 */
2194
-	public function getContentSecurityPolicyNonceManager() {
2195
-		return $this->get(ContentSecurityPolicyNonceManager::class);
2196
-	}
2197
-
2198
-	/**
2199
-	 * Not a public API as of 8.2, wait for 9.0
2200
-	 *
2201
-	 * @return \OCA\Files_External\Service\BackendService
2202
-	 * @deprecated 20.0.0
2203
-	 */
2204
-	public function getStoragesBackendService() {
2205
-		return $this->get(BackendService::class);
2206
-	}
2207
-
2208
-	/**
2209
-	 * Not a public API as of 8.2, wait for 9.0
2210
-	 *
2211
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
2212
-	 * @deprecated 20.0.0
2213
-	 */
2214
-	public function getGlobalStoragesService() {
2215
-		return $this->get(GlobalStoragesService::class);
2216
-	}
2217
-
2218
-	/**
2219
-	 * Not a public API as of 8.2, wait for 9.0
2220
-	 *
2221
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2222
-	 * @deprecated 20.0.0
2223
-	 */
2224
-	public function getUserGlobalStoragesService() {
2225
-		return $this->get(UserGlobalStoragesService::class);
2226
-	}
2227
-
2228
-	/**
2229
-	 * Not a public API as of 8.2, wait for 9.0
2230
-	 *
2231
-	 * @return \OCA\Files_External\Service\UserStoragesService
2232
-	 * @deprecated 20.0.0
2233
-	 */
2234
-	public function getUserStoragesService() {
2235
-		return $this->get(UserStoragesService::class);
2236
-	}
2237
-
2238
-	/**
2239
-	 * @return \OCP\Share\IManager
2240
-	 * @deprecated 20.0.0
2241
-	 */
2242
-	public function getShareManager() {
2243
-		return $this->get(\OCP\Share\IManager::class);
2244
-	}
2245
-
2246
-	/**
2247
-	 * @return \OCP\Collaboration\Collaborators\ISearch
2248
-	 * @deprecated 20.0.0
2249
-	 */
2250
-	public function getCollaboratorSearch() {
2251
-		return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2252
-	}
2253
-
2254
-	/**
2255
-	 * @return \OCP\Collaboration\AutoComplete\IManager
2256
-	 * @deprecated 20.0.0
2257
-	 */
2258
-	public function getAutoCompleteManager() {
2259
-		return $this->get(IManager::class);
2260
-	}
2261
-
2262
-	/**
2263
-	 * Returns the LDAP Provider
2264
-	 *
2265
-	 * @return \OCP\LDAP\ILDAPProvider
2266
-	 * @deprecated 20.0.0
2267
-	 */
2268
-	public function getLDAPProvider() {
2269
-		return $this->get('LDAPProvider');
2270
-	}
2271
-
2272
-	/**
2273
-	 * @return \OCP\Settings\IManager
2274
-	 * @deprecated 20.0.0
2275
-	 */
2276
-	public function getSettingsManager() {
2277
-		return $this->get(\OC\Settings\Manager::class);
2278
-	}
2279
-
2280
-	/**
2281
-	 * @return \OCP\Files\IAppData
2282
-	 * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
2283
-	 */
2284
-	public function getAppDataDir($app) {
2285
-		/** @var \OC\Files\AppData\Factory $factory */
2286
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
2287
-		return $factory->get($app);
2288
-	}
2289
-
2290
-	/**
2291
-	 * @return \OCP\Lockdown\ILockdownManager
2292
-	 * @deprecated 20.0.0
2293
-	 */
2294
-	public function getLockdownManager() {
2295
-		return $this->get('LockdownManager');
2296
-	}
2297
-
2298
-	/**
2299
-	 * @return \OCP\Federation\ICloudIdManager
2300
-	 * @deprecated 20.0.0
2301
-	 */
2302
-	public function getCloudIdManager() {
2303
-		return $this->get(ICloudIdManager::class);
2304
-	}
2305
-
2306
-	/**
2307
-	 * @return \OCP\GlobalScale\IConfig
2308
-	 * @deprecated 20.0.0
2309
-	 */
2310
-	public function getGlobalScaleConfig() {
2311
-		return $this->get(IConfig::class);
2312
-	}
2313
-
2314
-	/**
2315
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2316
-	 * @deprecated 20.0.0
2317
-	 */
2318
-	public function getCloudFederationProviderManager() {
2319
-		return $this->get(ICloudFederationProviderManager::class);
2320
-	}
2321
-
2322
-	/**
2323
-	 * @return \OCP\Remote\Api\IApiFactory
2324
-	 * @deprecated 20.0.0
2325
-	 */
2326
-	public function getRemoteApiFactory() {
2327
-		return $this->get(IApiFactory::class);
2328
-	}
2329
-
2330
-	/**
2331
-	 * @return \OCP\Federation\ICloudFederationFactory
2332
-	 * @deprecated 20.0.0
2333
-	 */
2334
-	public function getCloudFederationFactory() {
2335
-		return $this->get(ICloudFederationFactory::class);
2336
-	}
2337
-
2338
-	/**
2339
-	 * @return \OCP\Remote\IInstanceFactory
2340
-	 * @deprecated 20.0.0
2341
-	 */
2342
-	public function getRemoteInstanceFactory() {
2343
-		return $this->get(IInstanceFactory::class);
2344
-	}
2345
-
2346
-	/**
2347
-	 * @return IStorageFactory
2348
-	 * @deprecated 20.0.0
2349
-	 */
2350
-	public function getStorageFactory() {
2351
-		return $this->get(IStorageFactory::class);
2352
-	}
2353
-
2354
-	/**
2355
-	 * Get the Preview GeneratorHelper
2356
-	 *
2357
-	 * @return GeneratorHelper
2358
-	 * @since 17.0.0
2359
-	 * @deprecated 20.0.0
2360
-	 */
2361
-	public function getGeneratorHelper() {
2362
-		return $this->get(\OC\Preview\GeneratorHelper::class);
2363
-	}
2364
-
2365
-	private function registerDeprecatedAlias(string $alias, string $target) {
2366
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2367
-			try {
2368
-				/** @var LoggerInterface $logger */
2369
-				$logger = $container->get(LoggerInterface::class);
2370
-				$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2371
-			} catch (ContainerExceptionInterface $e) {
2372
-				// Could not get logger. Continue
2373
-			}
2374
-
2375
-			return $container->get($target);
2376
-		}, false);
2377
-	}
284
+    /** @var string */
285
+    private $webRoot;
286
+
287
+    /**
288
+     * @param string $webRoot
289
+     * @param \OC\Config $config
290
+     */
291
+    public function __construct($webRoot, \OC\Config $config) {
292
+        parent::__construct();
293
+        $this->webRoot = $webRoot;
294
+
295
+        // To find out if we are running from CLI or not
296
+        $this->registerParameter('isCLI', \OC::$CLI);
297
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
298
+
299
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
300
+            return $c;
301
+        });
302
+        $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
303
+            return $c;
304
+        });
305
+
306
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
307
+        /** @deprecated 19.0.0 */
308
+        $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
309
+
310
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
311
+        /** @deprecated 19.0.0 */
312
+        $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
313
+
314
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
315
+        /** @deprecated 19.0.0 */
316
+        $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
317
+
318
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
319
+        /** @deprecated 19.0.0 */
320
+        $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
321
+
322
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
323
+        $this->registerAlias(ITemplateManager::class, TemplateManager::class);
324
+
325
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
326
+
327
+        $this->registerService(View::class, function (Server $c) {
328
+            return new View();
329
+        }, false);
330
+
331
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
332
+            return new PreviewManager(
333
+                $c->get(\OCP\IConfig::class),
334
+                $c->get(IRootFolder::class),
335
+                new \OC\Preview\Storage\Root(
336
+                    $c->get(IRootFolder::class),
337
+                    $c->get(SystemConfig::class)
338
+                ),
339
+                $c->get(IEventDispatcher::class),
340
+                $c->get(SymfonyAdapter::class),
341
+                $c->get(GeneratorHelper::class),
342
+                $c->get(ISession::class)->get('user_id'),
343
+                $c->get(Coordinator::class),
344
+                $c->get(IServerContainer::class),
345
+                $c->get(IBinaryFinder::class),
346
+                $c->get(IMagickSupport::class)
347
+            );
348
+        });
349
+        /** @deprecated 19.0.0 */
350
+        $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
351
+
352
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
353
+            return new \OC\Preview\Watcher(
354
+                new \OC\Preview\Storage\Root(
355
+                    $c->get(IRootFolder::class),
356
+                    $c->get(SystemConfig::class)
357
+                )
358
+            );
359
+        });
360
+
361
+        $this->registerService(IProfiler::class, function (Server $c) {
362
+            return new Profiler($c->get(SystemConfig::class));
363
+        });
364
+
365
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
366
+            $view = new View();
367
+            $util = new Encryption\Util(
368
+                $view,
369
+                $c->get(IUserManager::class),
370
+                $c->get(IGroupManager::class),
371
+                $c->get(\OCP\IConfig::class)
372
+            );
373
+            return new Encryption\Manager(
374
+                $c->get(\OCP\IConfig::class),
375
+                $c->get(LoggerInterface::class),
376
+                $c->getL10N('core'),
377
+                new View(),
378
+                $util,
379
+                new ArrayCache()
380
+            );
381
+        });
382
+        /** @deprecated 19.0.0 */
383
+        $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
384
+
385
+        /** @deprecated 21.0.0 */
386
+        $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
387
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
388
+            $util = new Encryption\Util(
389
+                new View(),
390
+                $c->get(IUserManager::class),
391
+                $c->get(IGroupManager::class),
392
+                $c->get(\OCP\IConfig::class)
393
+            );
394
+            return new Encryption\File(
395
+                $util,
396
+                $c->get(IRootFolder::class),
397
+                $c->get(\OCP\Share\IManager::class)
398
+            );
399
+        });
400
+
401
+        /** @deprecated 21.0.0 */
402
+        $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
403
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
404
+            $view = new View();
405
+            $util = new Encryption\Util(
406
+                $view,
407
+                $c->get(IUserManager::class),
408
+                $c->get(IGroupManager::class),
409
+                $c->get(\OCP\IConfig::class)
410
+            );
411
+
412
+            return new Encryption\Keys\Storage(
413
+                $view,
414
+                $util,
415
+                $c->get(ICrypto::class),
416
+                $c->get(\OCP\IConfig::class)
417
+            );
418
+        });
419
+        /** @deprecated 20.0.0 */
420
+        $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
421
+
422
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
423
+        /** @deprecated 19.0.0 */
424
+        $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
425
+
426
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
427
+            /** @var \OCP\IConfig $config */
428
+            $config = $c->get(\OCP\IConfig::class);
429
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
430
+            return new $factoryClass($this);
431
+        });
432
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
433
+            return $c->get('SystemTagManagerFactory')->getManager();
434
+        });
435
+        /** @deprecated 19.0.0 */
436
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
437
+
438
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
439
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
440
+        });
441
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
442
+            $manager = \OC\Files\Filesystem::getMountManager(null);
443
+            $view = new View();
444
+            $root = new Root(
445
+                $manager,
446
+                $view,
447
+                null,
448
+                $c->get(IUserMountCache::class),
449
+                $this->get(LoggerInterface::class),
450
+                $this->get(IUserManager::class),
451
+                $this->get(IEventDispatcher::class),
452
+            );
453
+
454
+            $previewConnector = new \OC\Preview\WatcherConnector(
455
+                $root,
456
+                $c->get(SystemConfig::class)
457
+            );
458
+            $previewConnector->connectWatcher();
459
+
460
+            return $root;
461
+        });
462
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
463
+            return new HookConnector(
464
+                $c->get(IRootFolder::class),
465
+                new View(),
466
+                $c->get(\OC\EventDispatcher\SymfonyAdapter::class),
467
+                $c->get(IEventDispatcher::class)
468
+            );
469
+        });
470
+
471
+        /** @deprecated 19.0.0 */
472
+        $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
473
+
474
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
475
+            return new LazyRoot(function () use ($c) {
476
+                return $c->get('RootFolder');
477
+            });
478
+        });
479
+        /** @deprecated 19.0.0 */
480
+        $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
481
+
482
+        /** @deprecated 19.0.0 */
483
+        $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
484
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
485
+
486
+        $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
487
+            return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
488
+        });
489
+
490
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
491
+            $groupManager = new \OC\Group\Manager(
492
+                $this->get(IUserManager::class),
493
+                $c->get(SymfonyAdapter::class),
494
+                $this->get(LoggerInterface::class),
495
+                $this->get(ICacheFactory::class)
496
+            );
497
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
498
+                /** @var IEventDispatcher $dispatcher */
499
+                $dispatcher = $this->get(IEventDispatcher::class);
500
+                $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
501
+            });
502
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
503
+                /** @var IEventDispatcher $dispatcher */
504
+                $dispatcher = $this->get(IEventDispatcher::class);
505
+                $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
506
+            });
507
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
508
+                /** @var IEventDispatcher $dispatcher */
509
+                $dispatcher = $this->get(IEventDispatcher::class);
510
+                $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
511
+            });
512
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
513
+                /** @var IEventDispatcher $dispatcher */
514
+                $dispatcher = $this->get(IEventDispatcher::class);
515
+                $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
516
+            });
517
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
518
+                /** @var IEventDispatcher $dispatcher */
519
+                $dispatcher = $this->get(IEventDispatcher::class);
520
+                $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
521
+            });
522
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
523
+                /** @var IEventDispatcher $dispatcher */
524
+                $dispatcher = $this->get(IEventDispatcher::class);
525
+                $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
526
+            });
527
+            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
528
+                /** @var IEventDispatcher $dispatcher */
529
+                $dispatcher = $this->get(IEventDispatcher::class);
530
+                $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
531
+            });
532
+            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
533
+                /** @var IEventDispatcher $dispatcher */
534
+                $dispatcher = $this->get(IEventDispatcher::class);
535
+                $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
536
+            });
537
+            return $groupManager;
538
+        });
539
+        /** @deprecated 19.0.0 */
540
+        $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
541
+
542
+        $this->registerService(Store::class, function (ContainerInterface $c) {
543
+            $session = $c->get(ISession::class);
544
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
545
+                $tokenProvider = $c->get(IProvider::class);
546
+            } else {
547
+                $tokenProvider = null;
548
+            }
549
+            $logger = $c->get(LoggerInterface::class);
550
+            return new Store($session, $logger, $tokenProvider);
551
+        });
552
+        $this->registerAlias(IStore::class, Store::class);
553
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
554
+        $this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
555
+
556
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
557
+            $manager = $c->get(IUserManager::class);
558
+            $session = new \OC\Session\Memory('');
559
+            $timeFactory = new TimeFactory();
560
+            // Token providers might require a working database. This code
561
+            // might however be called when Nextcloud is not yet setup.
562
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
563
+                $provider = $c->get(IProvider::class);
564
+            } else {
565
+                $provider = null;
566
+            }
567
+
568
+            $legacyDispatcher = $c->get(SymfonyAdapter::class);
569
+
570
+            $userSession = new \OC\User\Session(
571
+                $manager,
572
+                $session,
573
+                $timeFactory,
574
+                $provider,
575
+                $c->get(\OCP\IConfig::class),
576
+                $c->get(ISecureRandom::class),
577
+                $c->getLockdownManager(),
578
+                $c->get(LoggerInterface::class),
579
+                $c->get(IEventDispatcher::class)
580
+            );
581
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
582
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
583
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
584
+            });
585
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
586
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
587
+                /** @var \OC\User\User $user */
588
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
589
+            });
590
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
591
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
592
+                /** @var \OC\User\User $user */
593
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
594
+                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
595
+            });
596
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
597
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
598
+                /** @var \OC\User\User $user */
599
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
600
+            });
601
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
602
+                /** @var \OC\User\User $user */
603
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
604
+
605
+                /** @var IEventDispatcher $dispatcher */
606
+                $dispatcher = $this->get(IEventDispatcher::class);
607
+                $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
608
+            });
609
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
610
+                /** @var \OC\User\User $user */
611
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
612
+
613
+                /** @var IEventDispatcher $dispatcher */
614
+                $dispatcher = $this->get(IEventDispatcher::class);
615
+                $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
616
+            });
617
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
618
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
619
+
620
+                /** @var IEventDispatcher $dispatcher */
621
+                $dispatcher = $this->get(IEventDispatcher::class);
622
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
623
+            });
624
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
625
+                /** @var \OC\User\User $user */
626
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
627
+
628
+                /** @var IEventDispatcher $dispatcher */
629
+                $dispatcher = $this->get(IEventDispatcher::class);
630
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
631
+            });
632
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
633
+                /** @var IEventDispatcher $dispatcher */
634
+                $dispatcher = $this->get(IEventDispatcher::class);
635
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
636
+            });
637
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
638
+                /** @var \OC\User\User $user */
639
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
640
+
641
+                /** @var IEventDispatcher $dispatcher */
642
+                $dispatcher = $this->get(IEventDispatcher::class);
643
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
644
+            });
645
+            $userSession->listen('\OC\User', 'logout', function ($user) {
646
+                \OC_Hook::emit('OC_User', 'logout', []);
647
+
648
+                /** @var IEventDispatcher $dispatcher */
649
+                $dispatcher = $this->get(IEventDispatcher::class);
650
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
651
+            });
652
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
653
+                /** @var IEventDispatcher $dispatcher */
654
+                $dispatcher = $this->get(IEventDispatcher::class);
655
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
656
+            });
657
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
658
+                /** @var \OC\User\User $user */
659
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
660
+
661
+                /** @var IEventDispatcher $dispatcher */
662
+                $dispatcher = $this->get(IEventDispatcher::class);
663
+                $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
664
+            });
665
+            return $userSession;
666
+        });
667
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
668
+        /** @deprecated 19.0.0 */
669
+        $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
670
+
671
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
672
+
673
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
674
+        /** @deprecated 19.0.0 */
675
+        $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
676
+
677
+        /** @deprecated 19.0.0 */
678
+        $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
679
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
680
+
681
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
682
+            return new \OC\SystemConfig($config);
683
+        });
684
+        /** @deprecated 19.0.0 */
685
+        $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
686
+
687
+        /** @deprecated 19.0.0 */
688
+        $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
689
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
690
+
691
+        $this->registerService(IFactory::class, function (Server $c) {
692
+            return new \OC\L10N\Factory(
693
+                $c->get(\OCP\IConfig::class),
694
+                $c->getRequest(),
695
+                $c->get(IUserSession::class),
696
+                $c->get(ICacheFactory::class),
697
+                \OC::$SERVERROOT
698
+            );
699
+        });
700
+        /** @deprecated 19.0.0 */
701
+        $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
702
+
703
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
704
+        /** @deprecated 19.0.0 */
705
+        $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
706
+
707
+        /** @deprecated 19.0.0 */
708
+        $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
709
+        /** @deprecated 19.0.0 */
710
+        $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
711
+
712
+        $this->registerService(ICache::class, function ($c) {
713
+            return new Cache\File();
714
+        });
715
+        /** @deprecated 19.0.0 */
716
+        $this->registerDeprecatedAlias('UserCache', ICache::class);
717
+
718
+        $this->registerService(Factory::class, function (Server $c) {
719
+            $profiler = $c->get(IProfiler::class);
720
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
721
+                $profiler,
722
+                ArrayCache::class,
723
+                ArrayCache::class,
724
+                ArrayCache::class
725
+            );
726
+            /** @var \OCP\IConfig $config */
727
+            $config = $c->get(\OCP\IConfig::class);
728
+
729
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
730
+                if (!$config->getSystemValueBool('log_query')) {
731
+                    $v = \OC_App::getAppVersions();
732
+                } else {
733
+                    // If the log_query is enabled, we can not get the app versions
734
+                    // as that does a query, which will be logged and the logging
735
+                    // depends on redis and here we are back again in the same function.
736
+                    $v = [
737
+                        'log_query' => 'enabled',
738
+                    ];
739
+                }
740
+                $v['core'] = implode(',', \OC_Util::getVersion());
741
+                $version = implode(',', $v);
742
+                $instanceId = \OC_Util::getInstanceId();
743
+                $path = \OC::$SERVERROOT;
744
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
745
+                return new \OC\Memcache\Factory($prefix,
746
+                    $c->get(LoggerInterface::class),
747
+                    $profiler,
748
+                    $config->getSystemValue('memcache.local', null),
749
+                    $config->getSystemValue('memcache.distributed', null),
750
+                    $config->getSystemValue('memcache.locking', null),
751
+                    $config->getSystemValueString('redis_log_file')
752
+                );
753
+            }
754
+            return $arrayCacheFactory;
755
+        });
756
+        /** @deprecated 19.0.0 */
757
+        $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
758
+        $this->registerAlias(ICacheFactory::class, Factory::class);
759
+
760
+        $this->registerService('RedisFactory', function (Server $c) {
761
+            $systemConfig = $c->get(SystemConfig::class);
762
+            return new RedisFactory($systemConfig, $c->getEventLogger());
763
+        });
764
+
765
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
766
+            $l10n = $this->get(IFactory::class)->get('lib');
767
+            return new \OC\Activity\Manager(
768
+                $c->getRequest(),
769
+                $c->get(IUserSession::class),
770
+                $c->get(\OCP\IConfig::class),
771
+                $c->get(IValidator::class),
772
+                $l10n
773
+            );
774
+        });
775
+        /** @deprecated 19.0.0 */
776
+        $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
777
+
778
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
779
+            return new \OC\Activity\EventMerger(
780
+                $c->getL10N('lib')
781
+            );
782
+        });
783
+        $this->registerAlias(IValidator::class, Validator::class);
784
+
785
+        $this->registerService(AvatarManager::class, function (Server $c) {
786
+            return new AvatarManager(
787
+                $c->get(IUserSession::class),
788
+                $c->get(\OC\User\Manager::class),
789
+                $c->getAppDataDir('avatar'),
790
+                $c->getL10N('lib'),
791
+                $c->get(LoggerInterface::class),
792
+                $c->get(\OCP\IConfig::class),
793
+                $c->get(IAccountManager::class),
794
+                $c->get(KnownUserService::class)
795
+            );
796
+        });
797
+
798
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
799
+        /** @deprecated 19.0.0 */
800
+        $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
801
+
802
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
803
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
804
+        $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
805
+
806
+        $this->registerService(\OC\Log::class, function (Server $c) {
807
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
808
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
809
+            $logger = $factory->get($logType);
810
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
811
+
812
+            return new Log($logger, $this->get(SystemConfig::class), null, $registry);
813
+        });
814
+        $this->registerAlias(ILogger::class, \OC\Log::class);
815
+        /** @deprecated 19.0.0 */
816
+        $this->registerDeprecatedAlias('Logger', \OC\Log::class);
817
+        // PSR-3 logger
818
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
819
+
820
+        $this->registerService(ILogFactory::class, function (Server $c) {
821
+            return new LogFactory($c, $this->get(SystemConfig::class));
822
+        });
823
+
824
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
825
+        /** @deprecated 19.0.0 */
826
+        $this->registerDeprecatedAlias('JobList', IJobList::class);
827
+
828
+        $this->registerService(Router::class, function (Server $c) {
829
+            $cacheFactory = $c->get(ICacheFactory::class);
830
+            if ($cacheFactory->isLocalCacheAvailable()) {
831
+                $router = $c->resolve(CachingRouter::class);
832
+            } else {
833
+                $router = $c->resolve(Router::class);
834
+            }
835
+            return $router;
836
+        });
837
+        $this->registerAlias(IRouter::class, Router::class);
838
+        /** @deprecated 19.0.0 */
839
+        $this->registerDeprecatedAlias('Router', IRouter::class);
840
+
841
+        $this->registerAlias(ISearch::class, Search::class);
842
+        /** @deprecated 19.0.0 */
843
+        $this->registerDeprecatedAlias('Search', ISearch::class);
844
+
845
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
846
+            $cacheFactory = $c->get(ICacheFactory::class);
847
+            if ($cacheFactory->isAvailable()) {
848
+                $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
849
+                    $c->get(AllConfig::class),
850
+                    $this->get(ICacheFactory::class),
851
+                    new \OC\AppFramework\Utility\TimeFactory()
852
+                );
853
+            } else {
854
+                $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
855
+                    $c->get(AllConfig::class),
856
+                    $c->get(IDBConnection::class),
857
+                    new \OC\AppFramework\Utility\TimeFactory()
858
+                );
859
+            }
860
+
861
+            return $backend;
862
+        });
863
+
864
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
865
+        /** @deprecated 19.0.0 */
866
+        $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
867
+        $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
868
+        $this->registerAlias(IVerificationToken::class, VerificationToken::class);
869
+
870
+        $this->registerAlias(ICrypto::class, Crypto::class);
871
+        /** @deprecated 19.0.0 */
872
+        $this->registerDeprecatedAlias('Crypto', ICrypto::class);
873
+
874
+        $this->registerAlias(IHasher::class, Hasher::class);
875
+        /** @deprecated 19.0.0 */
876
+        $this->registerDeprecatedAlias('Hasher', IHasher::class);
877
+
878
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
879
+        /** @deprecated 19.0.0 */
880
+        $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
881
+
882
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
883
+        $this->registerService(Connection::class, function (Server $c) {
884
+            $systemConfig = $c->get(SystemConfig::class);
885
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
886
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
887
+            if (!$factory->isValidType($type)) {
888
+                throw new \OC\DatabaseException('Invalid database type');
889
+            }
890
+            $connectionParams = $factory->createConnectionParams();
891
+            $connection = $factory->getConnection($type, $connectionParams);
892
+            return $connection;
893
+        });
894
+        /** @deprecated 19.0.0 */
895
+        $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
896
+
897
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
898
+        $this->registerAlias(IClientService::class, ClientService::class);
899
+        $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
900
+            return new NegativeDnsCache(
901
+                $c->get(ICacheFactory::class),
902
+            );
903
+        });
904
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
905
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
906
+            return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
907
+        });
908
+        /** @deprecated 19.0.0 */
909
+        $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
910
+
911
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
912
+            $queryLogger = new QueryLogger();
913
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
914
+                // In debug mode, module is being activated by default
915
+                $queryLogger->activate();
916
+            }
917
+            return $queryLogger;
918
+        });
919
+        /** @deprecated 19.0.0 */
920
+        $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
921
+
922
+        /** @deprecated 19.0.0 */
923
+        $this->registerDeprecatedAlias('TempManager', TempManager::class);
924
+        $this->registerAlias(ITempManager::class, TempManager::class);
925
+
926
+        $this->registerService(AppManager::class, function (ContainerInterface $c) {
927
+            // TODO: use auto-wiring
928
+            return new \OC\App\AppManager(
929
+                $c->get(IUserSession::class),
930
+                $c->get(\OCP\IConfig::class),
931
+                $c->get(\OC\AppConfig::class),
932
+                $c->get(IGroupManager::class),
933
+                $c->get(ICacheFactory::class),
934
+                $c->get(SymfonyAdapter::class),
935
+                $c->get(IEventDispatcher::class),
936
+                $c->get(LoggerInterface::class)
937
+            );
938
+        });
939
+        /** @deprecated 19.0.0 */
940
+        $this->registerDeprecatedAlias('AppManager', AppManager::class);
941
+        $this->registerAlias(IAppManager::class, AppManager::class);
942
+
943
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
944
+        /** @deprecated 19.0.0 */
945
+        $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
946
+
947
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
948
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
949
+
950
+            return new DateTimeFormatter(
951
+                $c->get(IDateTimeZone::class)->getTimeZone(),
952
+                $c->getL10N('lib', $language)
953
+            );
954
+        });
955
+        /** @deprecated 19.0.0 */
956
+        $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
957
+
958
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
959
+            $mountCache = $c->get(UserMountCache::class);
960
+            $listener = new UserMountCacheListener($mountCache);
961
+            $listener->listen($c->get(IUserManager::class));
962
+            return $mountCache;
963
+        });
964
+        /** @deprecated 19.0.0 */
965
+        $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
966
+
967
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
968
+            $loader = $c->get(IStorageFactory::class);
969
+            $mountCache = $c->get(IUserMountCache::class);
970
+            $eventLogger = $c->get(IEventLogger::class);
971
+            $manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
972
+
973
+            // builtin providers
974
+
975
+            $config = $c->get(\OCP\IConfig::class);
976
+            $logger = $c->get(LoggerInterface::class);
977
+            $manager->registerProvider(new CacheMountProvider($config));
978
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
979
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
980
+            $manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
981
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
982
+
983
+            return $manager;
984
+        });
985
+        /** @deprecated 19.0.0 */
986
+        $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
987
+
988
+        /** @deprecated 20.0.0 */
989
+        $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
990
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
991
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
992
+            if ($busClass) {
993
+                [$app, $class] = explode('::', $busClass, 2);
994
+                if ($c->get(IAppManager::class)->isInstalled($app)) {
995
+                    \OC_App::loadApp($app);
996
+                    return $c->get($class);
997
+                } else {
998
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
999
+                }
1000
+            } else {
1001
+                $jobList = $c->get(IJobList::class);
1002
+                return new CronBus($jobList);
1003
+            }
1004
+        });
1005
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
1006
+        /** @deprecated 20.0.0 */
1007
+        $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1008
+        $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1009
+        /** @deprecated 19.0.0 */
1010
+        $this->registerDeprecatedAlias('Throttler', Throttler::class);
1011
+        $this->registerAlias(IThrottler::class, Throttler::class);
1012
+        $this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1013
+            // IConfig and IAppManager requires a working database. This code
1014
+            // might however be called when ownCloud is not yet setup.
1015
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1016
+                $config = $c->get(\OCP\IConfig::class);
1017
+                $appManager = $c->get(IAppManager::class);
1018
+            } else {
1019
+                $config = null;
1020
+                $appManager = null;
1021
+            }
1022
+
1023
+            return new Checker(
1024
+                new EnvironmentHelper(),
1025
+                new FileAccessHelper(),
1026
+                new AppLocator(),
1027
+                $config,
1028
+                $c->get(ICacheFactory::class),
1029
+                $appManager,
1030
+                $c->get(IMimeTypeDetector::class)
1031
+            );
1032
+        });
1033
+        $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1034
+            if (isset($this['urlParams'])) {
1035
+                $urlParams = $this['urlParams'];
1036
+            } else {
1037
+                $urlParams = [];
1038
+            }
1039
+
1040
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1041
+                && in_array('fakeinput', stream_get_wrappers())
1042
+            ) {
1043
+                $stream = 'fakeinput://data';
1044
+            } else {
1045
+                $stream = 'php://input';
1046
+            }
1047
+
1048
+            return new Request(
1049
+                [
1050
+                    'get' => $_GET,
1051
+                    'post' => $_POST,
1052
+                    'files' => $_FILES,
1053
+                    'server' => $_SERVER,
1054
+                    'env' => $_ENV,
1055
+                    'cookies' => $_COOKIE,
1056
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1057
+                        ? $_SERVER['REQUEST_METHOD']
1058
+                        : '',
1059
+                    'urlParams' => $urlParams,
1060
+                ],
1061
+                $this->get(IRequestId::class),
1062
+                $this->get(\OCP\IConfig::class),
1063
+                $this->get(CsrfTokenManager::class),
1064
+                $stream
1065
+            );
1066
+        });
1067
+        /** @deprecated 19.0.0 */
1068
+        $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1069
+
1070
+        $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1071
+            return new RequestId(
1072
+                $_SERVER['UNIQUE_ID'] ?? '',
1073
+                $this->get(ISecureRandom::class)
1074
+            );
1075
+        });
1076
+
1077
+        $this->registerService(IMailer::class, function (Server $c) {
1078
+            return new Mailer(
1079
+                $c->get(\OCP\IConfig::class),
1080
+                $c->get(LoggerInterface::class),
1081
+                $c->get(Defaults::class),
1082
+                $c->get(IURLGenerator::class),
1083
+                $c->getL10N('lib'),
1084
+                $c->get(IEventDispatcher::class),
1085
+                $c->get(IFactory::class)
1086
+            );
1087
+        });
1088
+        /** @deprecated 19.0.0 */
1089
+        $this->registerDeprecatedAlias('Mailer', IMailer::class);
1090
+
1091
+        /** @deprecated 21.0.0 */
1092
+        $this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1093
+
1094
+        $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1095
+            $config = $c->get(\OCP\IConfig::class);
1096
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1097
+            if (is_null($factoryClass) || !class_exists($factoryClass)) {
1098
+                return new NullLDAPProviderFactory($this);
1099
+            }
1100
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1101
+            return new $factoryClass($this);
1102
+        });
1103
+        $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1104
+            $factory = $c->get(ILDAPProviderFactory::class);
1105
+            return $factory->getLDAPProvider();
1106
+        });
1107
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1108
+            $ini = $c->get(IniGetWrapper::class);
1109
+            $config = $c->get(\OCP\IConfig::class);
1110
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1111
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1112
+                /** @var \OC\Memcache\Factory $memcacheFactory */
1113
+                $memcacheFactory = $c->get(ICacheFactory::class);
1114
+                $memcache = $memcacheFactory->createLocking('lock');
1115
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
1116
+                    return new MemcacheLockingProvider($memcache, $ttl);
1117
+                }
1118
+                return new DBLockingProvider(
1119
+                    $c->get(IDBConnection::class),
1120
+                    new TimeFactory(),
1121
+                    $ttl,
1122
+                    !\OC::$CLI
1123
+                );
1124
+            }
1125
+            return new NoopLockingProvider();
1126
+        });
1127
+        /** @deprecated 19.0.0 */
1128
+        $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1129
+
1130
+        $this->registerService(ILockManager::class, function (Server $c): LockManager {
1131
+            return new LockManager();
1132
+        });
1133
+
1134
+        $this->registerAlias(ILockdownManager::class, 'LockdownManager');
1135
+        $this->registerService(SetupManager::class, function ($c) {
1136
+            // create the setupmanager through the mount manager to resolve the cyclic dependency
1137
+            return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1138
+        });
1139
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1140
+        /** @deprecated 19.0.0 */
1141
+        $this->registerDeprecatedAlias('MountManager', IMountManager::class);
1142
+
1143
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1144
+            return new \OC\Files\Type\Detection(
1145
+                $c->get(IURLGenerator::class),
1146
+                $c->get(LoggerInterface::class),
1147
+                \OC::$configDir,
1148
+                \OC::$SERVERROOT . '/resources/config/'
1149
+            );
1150
+        });
1151
+        /** @deprecated 19.0.0 */
1152
+        $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1153
+
1154
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
1155
+        /** @deprecated 19.0.0 */
1156
+        $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1157
+        $this->registerService(BundleFetcher::class, function () {
1158
+            return new BundleFetcher($this->getL10N('lib'));
1159
+        });
1160
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1161
+        /** @deprecated 19.0.0 */
1162
+        $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1163
+
1164
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1165
+            $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1166
+            $manager->registerCapability(function () use ($c) {
1167
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1168
+            });
1169
+            $manager->registerCapability(function () use ($c) {
1170
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1171
+            });
1172
+            $manager->registerCapability(function () use ($c) {
1173
+                return $c->get(MetadataCapabilities::class);
1174
+            });
1175
+            return $manager;
1176
+        });
1177
+        /** @deprecated 19.0.0 */
1178
+        $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1179
+
1180
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1181
+            $config = $c->get(\OCP\IConfig::class);
1182
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1183
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1184
+            $factory = new $factoryClass($this);
1185
+            $manager = $factory->getManager();
1186
+
1187
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1188
+                $manager = $c->get(IUserManager::class);
1189
+                $userDisplayName = $manager->getDisplayName($id);
1190
+                if ($userDisplayName === null) {
1191
+                    $l = $c->get(IFactory::class)->get('core');
1192
+                    return $l->t('Unknown user');
1193
+                }
1194
+                return $userDisplayName;
1195
+            });
1196
+
1197
+            return $manager;
1198
+        });
1199
+        /** @deprecated 19.0.0 */
1200
+        $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1201
+
1202
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1203
+        $this->registerService('ThemingDefaults', function (Server $c) {
1204
+            try {
1205
+                $classExists = class_exists('OCA\Theming\ThemingDefaults');
1206
+            } catch (\OCP\AutoloadNotAllowedException $e) {
1207
+                // App disabled or in maintenance mode
1208
+                $classExists = false;
1209
+            }
1210
+
1211
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1212
+                $imageManager = new ImageManager(
1213
+                    $c->get(\OCP\IConfig::class),
1214
+                    $c->getAppDataDir('theming'),
1215
+                    $c->get(IURLGenerator::class),
1216
+                    $this->get(ICacheFactory::class),
1217
+                    $this->get(ILogger::class),
1218
+                    $this->get(ITempManager::class)
1219
+                );
1220
+                return new ThemingDefaults(
1221
+                    $c->get(\OCP\IConfig::class),
1222
+                    $c->getL10N('theming'),
1223
+                    $c->get(IUserSession::class),
1224
+                    $c->get(IURLGenerator::class),
1225
+                    $c->get(ICacheFactory::class),
1226
+                    new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1227
+                    $imageManager,
1228
+                    $c->get(IAppManager::class),
1229
+                    $c->get(INavigationManager::class)
1230
+                );
1231
+            }
1232
+            return new \OC_Defaults();
1233
+        });
1234
+        $this->registerService(JSCombiner::class, function (Server $c) {
1235
+            return new JSCombiner(
1236
+                $c->getAppDataDir('js'),
1237
+                $c->get(IURLGenerator::class),
1238
+                $this->get(ICacheFactory::class),
1239
+                $c->get(SystemConfig::class),
1240
+                $c->get(LoggerInterface::class)
1241
+            );
1242
+        });
1243
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1244
+        /** @deprecated 19.0.0 */
1245
+        $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1246
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1247
+
1248
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1249
+            // FIXME: Instantiated here due to cyclic dependency
1250
+            $request = new Request(
1251
+                [
1252
+                    'get' => $_GET,
1253
+                    'post' => $_POST,
1254
+                    'files' => $_FILES,
1255
+                    'server' => $_SERVER,
1256
+                    'env' => $_ENV,
1257
+                    'cookies' => $_COOKIE,
1258
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1259
+                        ? $_SERVER['REQUEST_METHOD']
1260
+                        : null,
1261
+                ],
1262
+                $c->get(IRequestId::class),
1263
+                $c->get(\OCP\IConfig::class)
1264
+            );
1265
+
1266
+            return new CryptoWrapper(
1267
+                $c->get(\OCP\IConfig::class),
1268
+                $c->get(ICrypto::class),
1269
+                $c->get(ISecureRandom::class),
1270
+                $request
1271
+            );
1272
+        });
1273
+        /** @deprecated 19.0.0 */
1274
+        $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1275
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1276
+            return new SessionStorage($c->get(ISession::class));
1277
+        });
1278
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1279
+        /** @deprecated 19.0.0 */
1280
+        $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1281
+
1282
+        $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1283
+            $config = $c->get(\OCP\IConfig::class);
1284
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1285
+            /** @var \OCP\Share\IProviderFactory $factory */
1286
+            $factory = new $factoryClass($this);
1287
+
1288
+            $manager = new \OC\Share20\Manager(
1289
+                $c->get(LoggerInterface::class),
1290
+                $c->get(\OCP\IConfig::class),
1291
+                $c->get(ISecureRandom::class),
1292
+                $c->get(IHasher::class),
1293
+                $c->get(IMountManager::class),
1294
+                $c->get(IGroupManager::class),
1295
+                $c->getL10N('lib'),
1296
+                $c->get(IFactory::class),
1297
+                $factory,
1298
+                $c->get(IUserManager::class),
1299
+                $c->get(IRootFolder::class),
1300
+                $c->get(SymfonyAdapter::class),
1301
+                $c->get(IMailer::class),
1302
+                $c->get(IURLGenerator::class),
1303
+                $c->get('ThemingDefaults'),
1304
+                $c->get(IEventDispatcher::class),
1305
+                $c->get(IUserSession::class),
1306
+                $c->get(KnownUserService::class)
1307
+            );
1308
+
1309
+            return $manager;
1310
+        });
1311
+        /** @deprecated 19.0.0 */
1312
+        $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1313
+
1314
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1315
+            $instance = new Collaboration\Collaborators\Search($c);
1316
+
1317
+            // register default plugins
1318
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1319
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1320
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1321
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1322
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1323
+
1324
+            return $instance;
1325
+        });
1326
+        /** @deprecated 19.0.0 */
1327
+        $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1328
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1329
+
1330
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1331
+
1332
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1333
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1334
+
1335
+        $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1336
+
1337
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1338
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1339
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1340
+            return new \OC\Files\AppData\Factory(
1341
+                $c->get(IRootFolder::class),
1342
+                $c->get(SystemConfig::class)
1343
+            );
1344
+        });
1345
+
1346
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1347
+            return new LockdownManager(function () use ($c) {
1348
+                return $c->get(ISession::class);
1349
+            });
1350
+        });
1351
+
1352
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1353
+            return new DiscoveryService(
1354
+                $c->get(ICacheFactory::class),
1355
+                $c->get(IClientService::class)
1356
+            );
1357
+        });
1358
+
1359
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1360
+            return new CloudIdManager(
1361
+                $c->get(\OCP\Contacts\IManager::class),
1362
+                $c->get(IURLGenerator::class),
1363
+                $c->get(IUserManager::class),
1364
+                $c->get(ICacheFactory::class),
1365
+                $c->get(IEventDispatcher::class),
1366
+            );
1367
+        });
1368
+
1369
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1370
+
1371
+        $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1372
+            return new CloudFederationProviderManager(
1373
+                $c->get(IAppManager::class),
1374
+                $c->get(IClientService::class),
1375
+                $c->get(ICloudIdManager::class),
1376
+                $c->get(LoggerInterface::class)
1377
+            );
1378
+        });
1379
+
1380
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1381
+            return new CloudFederationFactory();
1382
+        });
1383
+
1384
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1385
+        /** @deprecated 19.0.0 */
1386
+        $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1387
+
1388
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1389
+        $this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1390
+        /** @deprecated 19.0.0 */
1391
+        $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1392
+
1393
+        $this->registerService(Defaults::class, function (Server $c) {
1394
+            return new Defaults(
1395
+                $c->getThemingDefaults()
1396
+            );
1397
+        });
1398
+        /** @deprecated 19.0.0 */
1399
+        $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1400
+
1401
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1402
+            return $c->get(\OCP\IUserSession::class)->getSession();
1403
+        }, false);
1404
+
1405
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1406
+            return new ShareHelper(
1407
+                $c->get(\OCP\Share\IManager::class)
1408
+            );
1409
+        });
1410
+
1411
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1412
+            return new Installer(
1413
+                $c->get(AppFetcher::class),
1414
+                $c->get(IClientService::class),
1415
+                $c->get(ITempManager::class),
1416
+                $c->get(LoggerInterface::class),
1417
+                $c->get(\OCP\IConfig::class),
1418
+                \OC::$CLI
1419
+            );
1420
+        });
1421
+
1422
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1423
+            return new ApiFactory($c->get(IClientService::class));
1424
+        });
1425
+
1426
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1427
+            $memcacheFactory = $c->get(ICacheFactory::class);
1428
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1429
+        });
1430
+
1431
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1432
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1433
+
1434
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1435
+
1436
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1437
+
1438
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1439
+
1440
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1441
+
1442
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1443
+
1444
+        $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1445
+
1446
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1447
+
1448
+        $this->registerAlias(IBroker::class, Broker::class);
1449
+
1450
+        $this->registerAlias(IMetadataManager::class, MetadataManager::class);
1451
+
1452
+        $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1453
+
1454
+        $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1455
+
1456
+        $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1457
+
1458
+        $this->registerAlias(ITranslationManager::class, TranslationManager::class);
1459
+
1460
+        $this->connectDispatcher();
1461
+    }
1462
+
1463
+    public function boot() {
1464
+        /** @var HookConnector $hookConnector */
1465
+        $hookConnector = $this->get(HookConnector::class);
1466
+        $hookConnector->viewToNode();
1467
+    }
1468
+
1469
+    /**
1470
+     * @return \OCP\Calendar\IManager
1471
+     * @deprecated 20.0.0
1472
+     */
1473
+    public function getCalendarManager() {
1474
+        return $this->get(\OC\Calendar\Manager::class);
1475
+    }
1476
+
1477
+    /**
1478
+     * @return \OCP\Calendar\Resource\IManager
1479
+     * @deprecated 20.0.0
1480
+     */
1481
+    public function getCalendarResourceBackendManager() {
1482
+        return $this->get(\OC\Calendar\Resource\Manager::class);
1483
+    }
1484
+
1485
+    /**
1486
+     * @return \OCP\Calendar\Room\IManager
1487
+     * @deprecated 20.0.0
1488
+     */
1489
+    public function getCalendarRoomBackendManager() {
1490
+        return $this->get(\OC\Calendar\Room\Manager::class);
1491
+    }
1492
+
1493
+    private function connectDispatcher(): void {
1494
+        /** @var IEventDispatcher $eventDispatcher */
1495
+        $eventDispatcher = $this->get(IEventDispatcher::class);
1496
+        $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1497
+        $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1498
+        $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1499
+        $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1500
+    }
1501
+
1502
+    /**
1503
+     * @return \OCP\Contacts\IManager
1504
+     * @deprecated 20.0.0
1505
+     */
1506
+    public function getContactsManager() {
1507
+        return $this->get(\OCP\Contacts\IManager::class);
1508
+    }
1509
+
1510
+    /**
1511
+     * @return \OC\Encryption\Manager
1512
+     * @deprecated 20.0.0
1513
+     */
1514
+    public function getEncryptionManager() {
1515
+        return $this->get(\OCP\Encryption\IManager::class);
1516
+    }
1517
+
1518
+    /**
1519
+     * @return \OC\Encryption\File
1520
+     * @deprecated 20.0.0
1521
+     */
1522
+    public function getEncryptionFilesHelper() {
1523
+        return $this->get(IFile::class);
1524
+    }
1525
+
1526
+    /**
1527
+     * @return \OCP\Encryption\Keys\IStorage
1528
+     * @deprecated 20.0.0
1529
+     */
1530
+    public function getEncryptionKeyStorage() {
1531
+        return $this->get(IStorage::class);
1532
+    }
1533
+
1534
+    /**
1535
+     * The current request object holding all information about the request
1536
+     * currently being processed is returned from this method.
1537
+     * In case the current execution was not initiated by a web request null is returned
1538
+     *
1539
+     * @return \OCP\IRequest
1540
+     * @deprecated 20.0.0
1541
+     */
1542
+    public function getRequest() {
1543
+        return $this->get(IRequest::class);
1544
+    }
1545
+
1546
+    /**
1547
+     * Returns the preview manager which can create preview images for a given file
1548
+     *
1549
+     * @return IPreview
1550
+     * @deprecated 20.0.0
1551
+     */
1552
+    public function getPreviewManager() {
1553
+        return $this->get(IPreview::class);
1554
+    }
1555
+
1556
+    /**
1557
+     * Returns the tag manager which can get and set tags for different object types
1558
+     *
1559
+     * @see \OCP\ITagManager::load()
1560
+     * @return ITagManager
1561
+     * @deprecated 20.0.0
1562
+     */
1563
+    public function getTagManager() {
1564
+        return $this->get(ITagManager::class);
1565
+    }
1566
+
1567
+    /**
1568
+     * Returns the system-tag manager
1569
+     *
1570
+     * @return ISystemTagManager
1571
+     *
1572
+     * @since 9.0.0
1573
+     * @deprecated 20.0.0
1574
+     */
1575
+    public function getSystemTagManager() {
1576
+        return $this->get(ISystemTagManager::class);
1577
+    }
1578
+
1579
+    /**
1580
+     * Returns the system-tag object mapper
1581
+     *
1582
+     * @return ISystemTagObjectMapper
1583
+     *
1584
+     * @since 9.0.0
1585
+     * @deprecated 20.0.0
1586
+     */
1587
+    public function getSystemTagObjectMapper() {
1588
+        return $this->get(ISystemTagObjectMapper::class);
1589
+    }
1590
+
1591
+    /**
1592
+     * Returns the avatar manager, used for avatar functionality
1593
+     *
1594
+     * @return IAvatarManager
1595
+     * @deprecated 20.0.0
1596
+     */
1597
+    public function getAvatarManager() {
1598
+        return $this->get(IAvatarManager::class);
1599
+    }
1600
+
1601
+    /**
1602
+     * Returns the root folder of ownCloud's data directory
1603
+     *
1604
+     * @return IRootFolder
1605
+     * @deprecated 20.0.0
1606
+     */
1607
+    public function getRootFolder() {
1608
+        return $this->get(IRootFolder::class);
1609
+    }
1610
+
1611
+    /**
1612
+     * Returns the root folder of ownCloud's data directory
1613
+     * This is the lazy variant so this gets only initialized once it
1614
+     * is actually used.
1615
+     *
1616
+     * @return IRootFolder
1617
+     * @deprecated 20.0.0
1618
+     */
1619
+    public function getLazyRootFolder() {
1620
+        return $this->get(IRootFolder::class);
1621
+    }
1622
+
1623
+    /**
1624
+     * Returns a view to ownCloud's files folder
1625
+     *
1626
+     * @param string $userId user ID
1627
+     * @return \OCP\Files\Folder|null
1628
+     * @deprecated 20.0.0
1629
+     */
1630
+    public function getUserFolder($userId = null) {
1631
+        if ($userId === null) {
1632
+            $user = $this->get(IUserSession::class)->getUser();
1633
+            if (!$user) {
1634
+                return null;
1635
+            }
1636
+            $userId = $user->getUID();
1637
+        }
1638
+        $root = $this->get(IRootFolder::class);
1639
+        return $root->getUserFolder($userId);
1640
+    }
1641
+
1642
+    /**
1643
+     * @return \OC\User\Manager
1644
+     * @deprecated 20.0.0
1645
+     */
1646
+    public function getUserManager() {
1647
+        return $this->get(IUserManager::class);
1648
+    }
1649
+
1650
+    /**
1651
+     * @return \OC\Group\Manager
1652
+     * @deprecated 20.0.0
1653
+     */
1654
+    public function getGroupManager() {
1655
+        return $this->get(IGroupManager::class);
1656
+    }
1657
+
1658
+    /**
1659
+     * @return \OC\User\Session
1660
+     * @deprecated 20.0.0
1661
+     */
1662
+    public function getUserSession() {
1663
+        return $this->get(IUserSession::class);
1664
+    }
1665
+
1666
+    /**
1667
+     * @return \OCP\ISession
1668
+     * @deprecated 20.0.0
1669
+     */
1670
+    public function getSession() {
1671
+        return $this->get(Session::class)->getSession();
1672
+    }
1673
+
1674
+    /**
1675
+     * @param \OCP\ISession $session
1676
+     */
1677
+    public function setSession(\OCP\ISession $session) {
1678
+        $this->get(SessionStorage::class)->setSession($session);
1679
+        $this->get(Session::class)->setSession($session);
1680
+        $this->get(Store::class)->setSession($session);
1681
+    }
1682
+
1683
+    /**
1684
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1685
+     * @deprecated 20.0.0
1686
+     */
1687
+    public function getTwoFactorAuthManager() {
1688
+        return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1689
+    }
1690
+
1691
+    /**
1692
+     * @return \OC\NavigationManager
1693
+     * @deprecated 20.0.0
1694
+     */
1695
+    public function getNavigationManager() {
1696
+        return $this->get(INavigationManager::class);
1697
+    }
1698
+
1699
+    /**
1700
+     * @return \OCP\IConfig
1701
+     * @deprecated 20.0.0
1702
+     */
1703
+    public function getConfig() {
1704
+        return $this->get(AllConfig::class);
1705
+    }
1706
+
1707
+    /**
1708
+     * @return \OC\SystemConfig
1709
+     * @deprecated 20.0.0
1710
+     */
1711
+    public function getSystemConfig() {
1712
+        return $this->get(SystemConfig::class);
1713
+    }
1714
+
1715
+    /**
1716
+     * Returns the app config manager
1717
+     *
1718
+     * @return IAppConfig
1719
+     * @deprecated 20.0.0
1720
+     */
1721
+    public function getAppConfig() {
1722
+        return $this->get(IAppConfig::class);
1723
+    }
1724
+
1725
+    /**
1726
+     * @return IFactory
1727
+     * @deprecated 20.0.0
1728
+     */
1729
+    public function getL10NFactory() {
1730
+        return $this->get(IFactory::class);
1731
+    }
1732
+
1733
+    /**
1734
+     * get an L10N instance
1735
+     *
1736
+     * @param string $app appid
1737
+     * @param string $lang
1738
+     * @return IL10N
1739
+     * @deprecated 20.0.0
1740
+     */
1741
+    public function getL10N($app, $lang = null) {
1742
+        return $this->get(IFactory::class)->get($app, $lang);
1743
+    }
1744
+
1745
+    /**
1746
+     * @return IURLGenerator
1747
+     * @deprecated 20.0.0
1748
+     */
1749
+    public function getURLGenerator() {
1750
+        return $this->get(IURLGenerator::class);
1751
+    }
1752
+
1753
+    /**
1754
+     * @return AppFetcher
1755
+     * @deprecated 20.0.0
1756
+     */
1757
+    public function getAppFetcher() {
1758
+        return $this->get(AppFetcher::class);
1759
+    }
1760
+
1761
+    /**
1762
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1763
+     * getMemCacheFactory() instead.
1764
+     *
1765
+     * @return ICache
1766
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1767
+     */
1768
+    public function getCache() {
1769
+        return $this->get(ICache::class);
1770
+    }
1771
+
1772
+    /**
1773
+     * Returns an \OCP\CacheFactory instance
1774
+     *
1775
+     * @return \OCP\ICacheFactory
1776
+     * @deprecated 20.0.0
1777
+     */
1778
+    public function getMemCacheFactory() {
1779
+        return $this->get(ICacheFactory::class);
1780
+    }
1781
+
1782
+    /**
1783
+     * Returns an \OC\RedisFactory instance
1784
+     *
1785
+     * @return \OC\RedisFactory
1786
+     * @deprecated 20.0.0
1787
+     */
1788
+    public function getGetRedisFactory() {
1789
+        return $this->get('RedisFactory');
1790
+    }
1791
+
1792
+
1793
+    /**
1794
+     * Returns the current session
1795
+     *
1796
+     * @return \OCP\IDBConnection
1797
+     * @deprecated 20.0.0
1798
+     */
1799
+    public function getDatabaseConnection() {
1800
+        return $this->get(IDBConnection::class);
1801
+    }
1802
+
1803
+    /**
1804
+     * Returns the activity manager
1805
+     *
1806
+     * @return \OCP\Activity\IManager
1807
+     * @deprecated 20.0.0
1808
+     */
1809
+    public function getActivityManager() {
1810
+        return $this->get(\OCP\Activity\IManager::class);
1811
+    }
1812
+
1813
+    /**
1814
+     * Returns an job list for controlling background jobs
1815
+     *
1816
+     * @return IJobList
1817
+     * @deprecated 20.0.0
1818
+     */
1819
+    public function getJobList() {
1820
+        return $this->get(IJobList::class);
1821
+    }
1822
+
1823
+    /**
1824
+     * Returns a logger instance
1825
+     *
1826
+     * @return ILogger
1827
+     * @deprecated 20.0.0
1828
+     */
1829
+    public function getLogger() {
1830
+        return $this->get(ILogger::class);
1831
+    }
1832
+
1833
+    /**
1834
+     * @return ILogFactory
1835
+     * @throws \OCP\AppFramework\QueryException
1836
+     * @deprecated 20.0.0
1837
+     */
1838
+    public function getLogFactory() {
1839
+        return $this->get(ILogFactory::class);
1840
+    }
1841
+
1842
+    /**
1843
+     * Returns a router for generating and matching urls
1844
+     *
1845
+     * @return IRouter
1846
+     * @deprecated 20.0.0
1847
+     */
1848
+    public function getRouter() {
1849
+        return $this->get(IRouter::class);
1850
+    }
1851
+
1852
+    /**
1853
+     * Returns a search instance
1854
+     *
1855
+     * @return ISearch
1856
+     * @deprecated 20.0.0
1857
+     */
1858
+    public function getSearch() {
1859
+        return $this->get(ISearch::class);
1860
+    }
1861
+
1862
+    /**
1863
+     * Returns a SecureRandom instance
1864
+     *
1865
+     * @return \OCP\Security\ISecureRandom
1866
+     * @deprecated 20.0.0
1867
+     */
1868
+    public function getSecureRandom() {
1869
+        return $this->get(ISecureRandom::class);
1870
+    }
1871
+
1872
+    /**
1873
+     * Returns a Crypto instance
1874
+     *
1875
+     * @return ICrypto
1876
+     * @deprecated 20.0.0
1877
+     */
1878
+    public function getCrypto() {
1879
+        return $this->get(ICrypto::class);
1880
+    }
1881
+
1882
+    /**
1883
+     * Returns a Hasher instance
1884
+     *
1885
+     * @return IHasher
1886
+     * @deprecated 20.0.0
1887
+     */
1888
+    public function getHasher() {
1889
+        return $this->get(IHasher::class);
1890
+    }
1891
+
1892
+    /**
1893
+     * Returns a CredentialsManager instance
1894
+     *
1895
+     * @return ICredentialsManager
1896
+     * @deprecated 20.0.0
1897
+     */
1898
+    public function getCredentialsManager() {
1899
+        return $this->get(ICredentialsManager::class);
1900
+    }
1901
+
1902
+    /**
1903
+     * Get the certificate manager
1904
+     *
1905
+     * @return \OCP\ICertificateManager
1906
+     */
1907
+    public function getCertificateManager() {
1908
+        return $this->get(ICertificateManager::class);
1909
+    }
1910
+
1911
+    /**
1912
+     * Returns an instance of the HTTP client service
1913
+     *
1914
+     * @return IClientService
1915
+     * @deprecated 20.0.0
1916
+     */
1917
+    public function getHTTPClientService() {
1918
+        return $this->get(IClientService::class);
1919
+    }
1920
+
1921
+    /**
1922
+     * Create a new event source
1923
+     *
1924
+     * @return \OCP\IEventSource
1925
+     * @deprecated 20.0.0
1926
+     */
1927
+    public function createEventSource() {
1928
+        return new \OC_EventSource();
1929
+    }
1930
+
1931
+    /**
1932
+     * Get the active event logger
1933
+     *
1934
+     * The returned logger only logs data when debug mode is enabled
1935
+     *
1936
+     * @return IEventLogger
1937
+     * @deprecated 20.0.0
1938
+     */
1939
+    public function getEventLogger() {
1940
+        return $this->get(IEventLogger::class);
1941
+    }
1942
+
1943
+    /**
1944
+     * Get the active query logger
1945
+     *
1946
+     * The returned logger only logs data when debug mode is enabled
1947
+     *
1948
+     * @return IQueryLogger
1949
+     * @deprecated 20.0.0
1950
+     */
1951
+    public function getQueryLogger() {
1952
+        return $this->get(IQueryLogger::class);
1953
+    }
1954
+
1955
+    /**
1956
+     * Get the manager for temporary files and folders
1957
+     *
1958
+     * @return \OCP\ITempManager
1959
+     * @deprecated 20.0.0
1960
+     */
1961
+    public function getTempManager() {
1962
+        return $this->get(ITempManager::class);
1963
+    }
1964
+
1965
+    /**
1966
+     * Get the app manager
1967
+     *
1968
+     * @return \OCP\App\IAppManager
1969
+     * @deprecated 20.0.0
1970
+     */
1971
+    public function getAppManager() {
1972
+        return $this->get(IAppManager::class);
1973
+    }
1974
+
1975
+    /**
1976
+     * Creates a new mailer
1977
+     *
1978
+     * @return IMailer
1979
+     * @deprecated 20.0.0
1980
+     */
1981
+    public function getMailer() {
1982
+        return $this->get(IMailer::class);
1983
+    }
1984
+
1985
+    /**
1986
+     * Get the webroot
1987
+     *
1988
+     * @return string
1989
+     * @deprecated 20.0.0
1990
+     */
1991
+    public function getWebRoot() {
1992
+        return $this->webRoot;
1993
+    }
1994
+
1995
+    /**
1996
+     * @return \OC\OCSClient
1997
+     * @deprecated 20.0.0
1998
+     */
1999
+    public function getOcsClient() {
2000
+        return $this->get('OcsClient');
2001
+    }
2002
+
2003
+    /**
2004
+     * @return IDateTimeZone
2005
+     * @deprecated 20.0.0
2006
+     */
2007
+    public function getDateTimeZone() {
2008
+        return $this->get(IDateTimeZone::class);
2009
+    }
2010
+
2011
+    /**
2012
+     * @return IDateTimeFormatter
2013
+     * @deprecated 20.0.0
2014
+     */
2015
+    public function getDateTimeFormatter() {
2016
+        return $this->get(IDateTimeFormatter::class);
2017
+    }
2018
+
2019
+    /**
2020
+     * @return IMountProviderCollection
2021
+     * @deprecated 20.0.0
2022
+     */
2023
+    public function getMountProviderCollection() {
2024
+        return $this->get(IMountProviderCollection::class);
2025
+    }
2026
+
2027
+    /**
2028
+     * Get the IniWrapper
2029
+     *
2030
+     * @return IniGetWrapper
2031
+     * @deprecated 20.0.0
2032
+     */
2033
+    public function getIniWrapper() {
2034
+        return $this->get(IniGetWrapper::class);
2035
+    }
2036
+
2037
+    /**
2038
+     * @return \OCP\Command\IBus
2039
+     * @deprecated 20.0.0
2040
+     */
2041
+    public function getCommandBus() {
2042
+        return $this->get(IBus::class);
2043
+    }
2044
+
2045
+    /**
2046
+     * Get the trusted domain helper
2047
+     *
2048
+     * @return TrustedDomainHelper
2049
+     * @deprecated 20.0.0
2050
+     */
2051
+    public function getTrustedDomainHelper() {
2052
+        return $this->get(TrustedDomainHelper::class);
2053
+    }
2054
+
2055
+    /**
2056
+     * Get the locking provider
2057
+     *
2058
+     * @return ILockingProvider
2059
+     * @since 8.1.0
2060
+     * @deprecated 20.0.0
2061
+     */
2062
+    public function getLockingProvider() {
2063
+        return $this->get(ILockingProvider::class);
2064
+    }
2065
+
2066
+    /**
2067
+     * @return IMountManager
2068
+     * @deprecated 20.0.0
2069
+     **/
2070
+    public function getMountManager() {
2071
+        return $this->get(IMountManager::class);
2072
+    }
2073
+
2074
+    /**
2075
+     * @return IUserMountCache
2076
+     * @deprecated 20.0.0
2077
+     */
2078
+    public function getUserMountCache() {
2079
+        return $this->get(IUserMountCache::class);
2080
+    }
2081
+
2082
+    /**
2083
+     * Get the MimeTypeDetector
2084
+     *
2085
+     * @return IMimeTypeDetector
2086
+     * @deprecated 20.0.0
2087
+     */
2088
+    public function getMimeTypeDetector() {
2089
+        return $this->get(IMimeTypeDetector::class);
2090
+    }
2091
+
2092
+    /**
2093
+     * Get the MimeTypeLoader
2094
+     *
2095
+     * @return IMimeTypeLoader
2096
+     * @deprecated 20.0.0
2097
+     */
2098
+    public function getMimeTypeLoader() {
2099
+        return $this->get(IMimeTypeLoader::class);
2100
+    }
2101
+
2102
+    /**
2103
+     * Get the manager of all the capabilities
2104
+     *
2105
+     * @return CapabilitiesManager
2106
+     * @deprecated 20.0.0
2107
+     */
2108
+    public function getCapabilitiesManager() {
2109
+        return $this->get(CapabilitiesManager::class);
2110
+    }
2111
+
2112
+    /**
2113
+     * Get the EventDispatcher
2114
+     *
2115
+     * @return EventDispatcherInterface
2116
+     * @since 8.2.0
2117
+     * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2118
+     */
2119
+    public function getEventDispatcher() {
2120
+        return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2121
+    }
2122
+
2123
+    /**
2124
+     * Get the Notification Manager
2125
+     *
2126
+     * @return \OCP\Notification\IManager
2127
+     * @since 8.2.0
2128
+     * @deprecated 20.0.0
2129
+     */
2130
+    public function getNotificationManager() {
2131
+        return $this->get(\OCP\Notification\IManager::class);
2132
+    }
2133
+
2134
+    /**
2135
+     * @return ICommentsManager
2136
+     * @deprecated 20.0.0
2137
+     */
2138
+    public function getCommentsManager() {
2139
+        return $this->get(ICommentsManager::class);
2140
+    }
2141
+
2142
+    /**
2143
+     * @return \OCA\Theming\ThemingDefaults
2144
+     * @deprecated 20.0.0
2145
+     */
2146
+    public function getThemingDefaults() {
2147
+        return $this->get('ThemingDefaults');
2148
+    }
2149
+
2150
+    /**
2151
+     * @return \OC\IntegrityCheck\Checker
2152
+     * @deprecated 20.0.0
2153
+     */
2154
+    public function getIntegrityCodeChecker() {
2155
+        return $this->get('IntegrityCodeChecker');
2156
+    }
2157
+
2158
+    /**
2159
+     * @return \OC\Session\CryptoWrapper
2160
+     * @deprecated 20.0.0
2161
+     */
2162
+    public function getSessionCryptoWrapper() {
2163
+        return $this->get('CryptoWrapper');
2164
+    }
2165
+
2166
+    /**
2167
+     * @return CsrfTokenManager
2168
+     * @deprecated 20.0.0
2169
+     */
2170
+    public function getCsrfTokenManager() {
2171
+        return $this->get(CsrfTokenManager::class);
2172
+    }
2173
+
2174
+    /**
2175
+     * @return Throttler
2176
+     * @deprecated 20.0.0
2177
+     */
2178
+    public function getBruteForceThrottler() {
2179
+        return $this->get(Throttler::class);
2180
+    }
2181
+
2182
+    /**
2183
+     * @return IContentSecurityPolicyManager
2184
+     * @deprecated 20.0.0
2185
+     */
2186
+    public function getContentSecurityPolicyManager() {
2187
+        return $this->get(ContentSecurityPolicyManager::class);
2188
+    }
2189
+
2190
+    /**
2191
+     * @return ContentSecurityPolicyNonceManager
2192
+     * @deprecated 20.0.0
2193
+     */
2194
+    public function getContentSecurityPolicyNonceManager() {
2195
+        return $this->get(ContentSecurityPolicyNonceManager::class);
2196
+    }
2197
+
2198
+    /**
2199
+     * Not a public API as of 8.2, wait for 9.0
2200
+     *
2201
+     * @return \OCA\Files_External\Service\BackendService
2202
+     * @deprecated 20.0.0
2203
+     */
2204
+    public function getStoragesBackendService() {
2205
+        return $this->get(BackendService::class);
2206
+    }
2207
+
2208
+    /**
2209
+     * Not a public API as of 8.2, wait for 9.0
2210
+     *
2211
+     * @return \OCA\Files_External\Service\GlobalStoragesService
2212
+     * @deprecated 20.0.0
2213
+     */
2214
+    public function getGlobalStoragesService() {
2215
+        return $this->get(GlobalStoragesService::class);
2216
+    }
2217
+
2218
+    /**
2219
+     * Not a public API as of 8.2, wait for 9.0
2220
+     *
2221
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
2222
+     * @deprecated 20.0.0
2223
+     */
2224
+    public function getUserGlobalStoragesService() {
2225
+        return $this->get(UserGlobalStoragesService::class);
2226
+    }
2227
+
2228
+    /**
2229
+     * Not a public API as of 8.2, wait for 9.0
2230
+     *
2231
+     * @return \OCA\Files_External\Service\UserStoragesService
2232
+     * @deprecated 20.0.0
2233
+     */
2234
+    public function getUserStoragesService() {
2235
+        return $this->get(UserStoragesService::class);
2236
+    }
2237
+
2238
+    /**
2239
+     * @return \OCP\Share\IManager
2240
+     * @deprecated 20.0.0
2241
+     */
2242
+    public function getShareManager() {
2243
+        return $this->get(\OCP\Share\IManager::class);
2244
+    }
2245
+
2246
+    /**
2247
+     * @return \OCP\Collaboration\Collaborators\ISearch
2248
+     * @deprecated 20.0.0
2249
+     */
2250
+    public function getCollaboratorSearch() {
2251
+        return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2252
+    }
2253
+
2254
+    /**
2255
+     * @return \OCP\Collaboration\AutoComplete\IManager
2256
+     * @deprecated 20.0.0
2257
+     */
2258
+    public function getAutoCompleteManager() {
2259
+        return $this->get(IManager::class);
2260
+    }
2261
+
2262
+    /**
2263
+     * Returns the LDAP Provider
2264
+     *
2265
+     * @return \OCP\LDAP\ILDAPProvider
2266
+     * @deprecated 20.0.0
2267
+     */
2268
+    public function getLDAPProvider() {
2269
+        return $this->get('LDAPProvider');
2270
+    }
2271
+
2272
+    /**
2273
+     * @return \OCP\Settings\IManager
2274
+     * @deprecated 20.0.0
2275
+     */
2276
+    public function getSettingsManager() {
2277
+        return $this->get(\OC\Settings\Manager::class);
2278
+    }
2279
+
2280
+    /**
2281
+     * @return \OCP\Files\IAppData
2282
+     * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
2283
+     */
2284
+    public function getAppDataDir($app) {
2285
+        /** @var \OC\Files\AppData\Factory $factory */
2286
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
2287
+        return $factory->get($app);
2288
+    }
2289
+
2290
+    /**
2291
+     * @return \OCP\Lockdown\ILockdownManager
2292
+     * @deprecated 20.0.0
2293
+     */
2294
+    public function getLockdownManager() {
2295
+        return $this->get('LockdownManager');
2296
+    }
2297
+
2298
+    /**
2299
+     * @return \OCP\Federation\ICloudIdManager
2300
+     * @deprecated 20.0.0
2301
+     */
2302
+    public function getCloudIdManager() {
2303
+        return $this->get(ICloudIdManager::class);
2304
+    }
2305
+
2306
+    /**
2307
+     * @return \OCP\GlobalScale\IConfig
2308
+     * @deprecated 20.0.0
2309
+     */
2310
+    public function getGlobalScaleConfig() {
2311
+        return $this->get(IConfig::class);
2312
+    }
2313
+
2314
+    /**
2315
+     * @return \OCP\Federation\ICloudFederationProviderManager
2316
+     * @deprecated 20.0.0
2317
+     */
2318
+    public function getCloudFederationProviderManager() {
2319
+        return $this->get(ICloudFederationProviderManager::class);
2320
+    }
2321
+
2322
+    /**
2323
+     * @return \OCP\Remote\Api\IApiFactory
2324
+     * @deprecated 20.0.0
2325
+     */
2326
+    public function getRemoteApiFactory() {
2327
+        return $this->get(IApiFactory::class);
2328
+    }
2329
+
2330
+    /**
2331
+     * @return \OCP\Federation\ICloudFederationFactory
2332
+     * @deprecated 20.0.0
2333
+     */
2334
+    public function getCloudFederationFactory() {
2335
+        return $this->get(ICloudFederationFactory::class);
2336
+    }
2337
+
2338
+    /**
2339
+     * @return \OCP\Remote\IInstanceFactory
2340
+     * @deprecated 20.0.0
2341
+     */
2342
+    public function getRemoteInstanceFactory() {
2343
+        return $this->get(IInstanceFactory::class);
2344
+    }
2345
+
2346
+    /**
2347
+     * @return IStorageFactory
2348
+     * @deprecated 20.0.0
2349
+     */
2350
+    public function getStorageFactory() {
2351
+        return $this->get(IStorageFactory::class);
2352
+    }
2353
+
2354
+    /**
2355
+     * Get the Preview GeneratorHelper
2356
+     *
2357
+     * @return GeneratorHelper
2358
+     * @since 17.0.0
2359
+     * @deprecated 20.0.0
2360
+     */
2361
+    public function getGeneratorHelper() {
2362
+        return $this->get(\OC\Preview\GeneratorHelper::class);
2363
+    }
2364
+
2365
+    private function registerDeprecatedAlias(string $alias, string $target) {
2366
+        $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2367
+            try {
2368
+                /** @var LoggerInterface $logger */
2369
+                $logger = $container->get(LoggerInterface::class);
2370
+                $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2371
+            } catch (ContainerExceptionInterface $e) {
2372
+                // Could not get logger. Continue
2373
+            }
2374
+
2375
+            return $container->get($target);
2376
+        }, false);
2377
+    }
2378 2378
 }
Please login to merge, or discard this patch.