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