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