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