Completed
Push — master ( abdf8c...733110 )
by Blizzz
10:14
created

Server::getTwoFactorAuthManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Arthur Schiwon <[email protected]>
6
 * @author Bart Visscher <[email protected]>
7
 * @author Bernhard Posselt <[email protected]>
8
 * @author Bernhard Reiter <[email protected]>
9
 * @author Bjoern Schiessle <[email protected]>
10
 * @author Björn Schießle <[email protected]>
11
 * @author Christopher Schäpers <[email protected]>
12
 * @author Christoph Wurst <[email protected]>
13
 * @author Joas Schilling <[email protected]>
14
 * @author Jörn Friedrich Dreyer <[email protected]>
15
 * @author Lukas Reschke <[email protected]>
16
 * @author Morris Jobke <[email protected]>
17
 * @author Robin Appelman <[email protected]>
18
 * @author Robin McCorkell <[email protected]>
19
 * @author Roeland Jago Douma <[email protected]>
20
 * @author Sander <[email protected]>
21
 * @author Thomas Müller <[email protected]>
22
 * @author Thomas Tanghus <[email protected]>
23
 * @author Vincent Petry <[email protected]>
24
 * @author Roger Szabo <[email protected]>
25
 *
26
 * @license AGPL-3.0
27
 *
28
 * This code is free software: you can redistribute it and/or modify
29
 * it under the terms of the GNU Affero General Public License, version 3,
30
 * as published by the Free Software Foundation.
31
 *
32
 * This program is distributed in the hope that it will be useful,
33
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35
 * GNU Affero General Public License for more details.
36
 *
37
 * You should have received a copy of the GNU Affero General Public License, version 3,
38
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
39
 *
40
 */
41
namespace OC;
42
43
use bantu\IniGetWrapper\IniGetWrapper;
44
use OC\AppFramework\Http\Request;
45
use OC\AppFramework\Db\Db;
46
use OC\AppFramework\Utility\TimeFactory;
47
use OC\Command\AsyncBus;
48
use OC\Diagnostics\EventLogger;
49
use OC\Diagnostics\NullEventLogger;
50
use OC\Diagnostics\NullQueryLogger;
51
use OC\Diagnostics\QueryLogger;
52
use OC\Files\Config\UserMountCache;
53
use OC\Files\Config\UserMountCacheListener;
54
use OC\Files\Mount\CacheMountProvider;
55
use OC\Files\Mount\LocalHomeMountProvider;
56
use OC\Files\Mount\ObjectHomeMountProvider;
57
use OC\Files\Node\HookConnector;
58
use OC\Files\Node\LazyRoot;
59
use OC\Files\Node\Root;
60
use OC\Files\View;
61
use OC\Http\Client\ClientService;
62
use OC\IntegrityCheck\Checker;
63
use OC\IntegrityCheck\Helpers\AppLocator;
64
use OC\IntegrityCheck\Helpers\EnvironmentHelper;
65
use OC\IntegrityCheck\Helpers\FileAccessHelper;
66
use OC\Lock\DBLockingProvider;
67
use OC\Lock\MemcacheLockingProvider;
68
use OC\Lock\NoopLockingProvider;
69
use OC\Mail\Mailer;
70
use OC\Memcache\ArrayCache;
71
use OC\Notification\Manager;
72
use OC\Security\Bruteforce\Throttler;
73
use OC\Security\CertificateManager;
74
use OC\Security\CSP\ContentSecurityPolicyManager;
75
use OC\Security\Crypto;
76
use OC\Security\CSRF\CsrfTokenGenerator;
77
use OC\Security\CSRF\CsrfTokenManager;
78
use OC\Security\CSRF\TokenStorage\SessionStorage;
79
use OC\Security\Hasher;
80
use OC\Security\CredentialsManager;
81
use OC\Security\SecureRandom;
82
use OC\Security\TrustedDomainHelper;
83
use OC\Session\CryptoWrapper;
84
use OC\Tagging\TagMapper;
85
use OCA\Theming\Template;
86
use OCP\IL10N;
87
use OCP\IServerContainer;
88
use OCP\Security\IContentSecurityPolicyManager;
89
use Symfony\Component\EventDispatcher\EventDispatcher;
90
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
91
92
/**
93
 * Class Server
94
 *
95
 * @package OC
96
 *
97
 * TODO: hookup all manager classes
98
 */
99
class Server extends ServerContainer implements IServerContainer {
100
	/** @var string */
101
	private $webRoot;
102
103
	/**
104
	 * @param string $webRoot
105
	 * @param \OC\Config $config
106
	 */
107
	public function __construct($webRoot, \OC\Config $config) {
108
		parent::__construct();
109
		$this->webRoot = $webRoot;
110
111
		$this->registerService('ContactsManager', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
112
			return new ContactsManager();
113
		});
114
115
		$this->registerService('PreviewManager', function (Server $c) {
116
			return new PreviewManager($c->getConfig());
117
		});
118
119
		$this->registerService('EncryptionManager', function (Server $c) {
120
			$view = new View();
121
			$util = new Encryption\Util(
122
				$view,
123
				$c->getUserManager(),
124
				$c->getGroupManager(),
125
				$c->getConfig()
126
			);
127
			return new Encryption\Manager(
128
				$c->getConfig(),
129
				$c->getLogger(),
130
				$c->getL10N('core'),
131
				new View(),
132
				$util,
133
				new ArrayCache()
134
			);
135
		});
136
137
		$this->registerService('EncryptionFileHelper', function (Server $c) {
138
			$util = new Encryption\Util(
139
				new View(),
140
				$c->getUserManager(),
141
				$c->getGroupManager(),
142
				$c->getConfig()
143
			);
144
			return new Encryption\File($util);
145
		});
146
147
		$this->registerService('EncryptionKeyStorage', function (Server $c) {
148
			$view = new View();
149
			$util = new Encryption\Util(
150
				$view,
151
				$c->getUserManager(),
152
				$c->getGroupManager(),
153
				$c->getConfig()
154
			);
155
156
			return new Encryption\Keys\Storage($view, $util);
157
		});
158
		$this->registerService('TagMapper', function (Server $c) {
159
			return new TagMapper($c->getDatabaseConnection());
160
		});
161
		$this->registerService('TagManager', function (Server $c) {
162
			$tagMapper = $c->query('TagMapper');
163
			return new TagManager($tagMapper, $c->getUserSession());
164
		});
165 View Code Duplication
		$this->registerService('SystemTagManagerFactory', function (Server $c) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
166
			$config = $c->getConfig();
167
			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
168
			/** @var \OC\SystemTag\ManagerFactory $factory */
169
			$factory = new $factoryClass($this);
170
			return $factory;
171
		});
172
		$this->registerService('SystemTagManager', function (Server $c) {
173
			return $c->query('SystemTagManagerFactory')->getManager();
174
		});
175
		$this->registerService('SystemTagObjectMapper', function (Server $c) {
176
			return $c->query('SystemTagManagerFactory')->getObjectMapper();
177
		});
178
		$this->registerService('RootFolder', function () {
179
			$manager = \OC\Files\Filesystem::getMountManager(null);
180
			$view = new View();
181
			$root = new Root($manager, $view, null);
182
			$connector = new HookConnector($root, $view);
183
			$connector->viewToNode();
184
			return $root;
185
		});
186
		$this->registerService('LazyRootFolder', function(Server $c) {
187
			return new LazyRoot(function() use ($c) {
188
				return $c->getRootFolder();
189
			});
190
		});
191
		$this->registerService('UserManager', function (Server $c) {
192
			$config = $c->getConfig();
193
			return new \OC\User\Manager($config);
194
		});
195
		$this->registerService('GroupManager', function (Server $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
196
			$groupManager = new \OC\Group\Manager($this->getUserManager());
197
			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
198
				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
199
			});
200
			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
201
				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
202
			});
203
			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
204
				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
205
			});
206
			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
207
				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
208
			});
209
			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
210
				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
211
			});
212
			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
213
				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
214
				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
215
				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
216
			});
217
			return $groupManager;
218
		});
219
		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
220
			$dbConnection = $c->getDatabaseConnection();
221
			return new Authentication\Token\DefaultTokenMapper($dbConnection);
222
		});
223
		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
224
			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
225
			$crypto = $c->getCrypto();
226
			$config = $c->getConfig();
227
			$logger = $c->getLogger();
228
			$timeFactory = new TimeFactory();
229
			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
230
		});
231
		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
232
		$this->registerService('UserSession', function (Server $c) {
233
			$manager = $c->getUserManager();
234
			$session = new \OC\Session\Memory('');
235
			$timeFactory = new TimeFactory();
236
			// Token providers might require a working database. This code
237
			// might however be called when ownCloud is not yet setup.
238 View Code Duplication
			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
239
				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
240
			} else {
241
				$defaultTokenProvider = null;
242
			}
243
244
			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig());
245
			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
246
				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
247
			});
248
			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
249
				/** @var $user \OC\User\User */
250
				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
251
			});
252
			$userSession->listen('\OC\User', 'preDelete', function ($user) {
253
				/** @var $user \OC\User\User */
254
				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
255
			});
256
			$userSession->listen('\OC\User', 'postDelete', function ($user) {
257
				/** @var $user \OC\User\User */
258
				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
259
			});
260 View Code Duplication
			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
261
				/** @var $user \OC\User\User */
262
				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
263
			});
264 View Code Duplication
			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
265
				/** @var $user \OC\User\User */
266
				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
267
			});
268
			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
269
				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
270
			});
271
			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
272
				/** @var $user \OC\User\User */
273
				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
274
			});
275
			$userSession->listen('\OC\User', 'logout', function () {
276
				\OC_Hook::emit('OC_User', 'logout', array());
277
			});
278
			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
279
				/** @var $user \OC\User\User */
280
				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
281
			});
282
			return $userSession;
283
		});
284
285
		$this->registerService('\OC\Authentication\TwoFactorAuth\Manager', function (Server $c) {
286
			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig());
0 ignored issues
show
Compatibility introduced by
$c->getAppManager() of type object<OCP\App\IAppManager> is not a sub-type of object<OC\App\AppManager>. It seems like you assume a concrete implementation of the interface OCP\App\IAppManager to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
287
		});
288
289
		$this->registerService('NavigationManager', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
290
			return new \OC\NavigationManager();
291
		});
292
		$this->registerService('AllConfig', function (Server $c) {
293
			return new \OC\AllConfig(
294
				$c->getSystemConfig()
295
			);
296
		});
297
		$this->registerService('SystemConfig', function ($c) use ($config) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
298
			return new \OC\SystemConfig($config);
299
		});
300
		$this->registerService('AppConfig', function (Server $c) {
301
			return new \OC\AppConfig($c->getDatabaseConnection());
302
		});
303
		$this->registerService('L10NFactory', function (Server $c) {
304
			return new \OC\L10N\Factory(
305
				$c->getConfig(),
306
				$c->getRequest(),
307
				$c->getUserSession(),
308
				\OC::$SERVERROOT
309
			);
310
		});
311
		$this->registerService('URLGenerator', function (Server $c) {
312
			$config = $c->getConfig();
313
			$cacheFactory = $c->getMemCacheFactory();
314
			return new \OC\URLGenerator(
315
				$config,
316
				$cacheFactory
317
			);
318
		});
319
		$this->registerService('AppHelper', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
320
			return new \OC\AppHelper();
0 ignored issues
show
Deprecated Code introduced by
The class OC\AppHelper has been deprecated with message: 8.1.0

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
321
		});
322
		$this->registerService('UserCache', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
323
			return new Cache\File();
324
		});
325
		$this->registerService('MemCacheFactory', function (Server $c) {
326
			$config = $c->getConfig();
327
328
			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
329
				$v = \OC_App::getAppVersions();
330
				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
331
				$version = implode(',', $v);
332
				$instanceId = \OC_Util::getInstanceId();
333
				$path = \OC::$SERVERROOT;
334
				$prefix = md5($instanceId . '-' . $version . '-' . $path);
335
				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
336
					$config->getSystemValue('memcache.local', null),
337
					$config->getSystemValue('memcache.distributed', null),
338
					$config->getSystemValue('memcache.locking', null)
339
				);
340
			}
341
342
			return new \OC\Memcache\Factory('', $c->getLogger(),
343
				'\\OC\\Memcache\\ArrayCache',
344
				'\\OC\\Memcache\\ArrayCache',
345
				'\\OC\\Memcache\\ArrayCache'
346
			);
347
		});
348
		$this->registerService('RedisFactory', function (Server $c) {
349
			$systemConfig = $c->getSystemConfig();
350
			return new RedisFactory($systemConfig);
351
		});
352
		$this->registerService('ActivityManager', function (Server $c) {
353
			return new \OC\Activity\Manager(
354
				$c->getRequest(),
355
				$c->getUserSession(),
356
				$c->getConfig()
357
			);
358
		});
359
		$this->registerService('AvatarManager', function (Server $c) {
360
			return new AvatarManager(
361
				$c->getUserManager(),
362
				$c->getRootFolder(),
363
				$c->getL10N('lib'),
364
				$c->getLogger()
365
			);
366
		});
367
		$this->registerService('Logger', function (Server $c) {
368
			$logClass = $c->query('AllConfig')->getSystemValue('log_type', 'file');
369
			// TODO: Drop backwards compatibility for config in the future
370
			$logger = 'OC\\Log\\' . ucfirst($logClass=='owncloud' ? 'file' : $logClass);
371
			call_user_func(array($logger, 'init'));
372
373
			return new Log($logger);
374
		});
375
		$this->registerService('JobList', function (Server $c) {
376
			$config = $c->getConfig();
377
			return new \OC\BackgroundJob\JobList(
378
				$c->getDatabaseConnection(),
379
				$config,
380
				new TimeFactory()
381
			);
382
		});
383
		$this->registerService('Router', function (Server $c) {
384
			$cacheFactory = $c->getMemCacheFactory();
385
			$logger = $c->getLogger();
386
			if ($cacheFactory->isAvailable()) {
387
				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
388
			} else {
389
				$router = new \OC\Route\Router($logger);
390
			}
391
			return $router;
392
		});
393
		$this->registerService('Search', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
394
			return new Search();
395
		});
396
		$this->registerService('SecureRandom', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
397
			return new SecureRandom();
398
		});
399
		$this->registerService('Crypto', function (Server $c) {
400
			return new Crypto($c->getConfig(), $c->getSecureRandom());
401
		});
402
		$this->registerService('Hasher', function (Server $c) {
403
			return new Hasher($c->getConfig());
404
		});
405
		$this->registerService('CredentialsManager', function (Server $c) {
406
			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
407
		});
408
		$this->registerService('DatabaseConnection', function (Server $c) {
409
			$factory = new \OC\DB\ConnectionFactory();
410
			$systemConfig = $c->getSystemConfig();
411
			$type = $systemConfig->getValue('dbtype', 'sqlite');
412
			if (!$factory->isValidType($type)) {
413
				throw new \OC\DatabaseException('Invalid database type');
414
			}
415
			$connectionParams = $factory->createConnectionParams($systemConfig);
416
			$connection = $factory->getConnection($type, $connectionParams);
417
			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
418
			return $connection;
419
		});
420
		$this->registerService('Db', function (Server $c) {
421
			return new Db($c->getDatabaseConnection());
0 ignored issues
show
Deprecated Code introduced by
The class OC\AppFramework\Db\Db has been deprecated with message: use IDBConnection directly, will be removed in ownCloud 10
Small Facade for being able to inject the database connection for tests

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
422
		});
423
		$this->registerService('HTTPHelper', function (Server $c) {
424
			$config = $c->getConfig();
425
			return new HTTPHelper(
0 ignored issues
show
Deprecated Code introduced by
The class OC\HTTPHelper has been deprecated with message: Use \OCP\Http\Client\IClientService

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
426
				$config,
427
				$c->getHTTPClientService()
428
			);
429
		});
430
		$this->registerService('HttpClientService', function (Server $c) {
431
			$user = \OC_User::getUser();
432
			$uid = $user ? $user : null;
433
			return new ClientService(
434
				$c->getConfig(),
435
				new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
436
			);
437
		});
438
		$this->registerService('EventLogger', function (Server $c) {
439
			if ($c->getSystemConfig()->getValue('debug', false)) {
440
				return new EventLogger();
441
			} else {
442
				return new NullEventLogger();
443
			}
444
		});
445
		$this->registerService('QueryLogger', function (Server $c) {
446
			if ($c->getSystemConfig()->getValue('debug', false)) {
447
				return new QueryLogger();
448
			} else {
449
				return new NullQueryLogger();
450
			}
451
		});
452
		$this->registerService('TempManager', function (Server $c) {
453
			return new TempManager(
454
				$c->getLogger(),
455
				$c->getConfig()
456
			);
457
		});
458
		$this->registerService('AppManager', function (Server $c) {
459
			return new \OC\App\AppManager(
460
				$c->getUserSession(),
461
				$c->getAppConfig(),
462
				$c->getGroupManager(),
463
				$c->getMemCacheFactory(),
464
				$c->getEventDispatcher()
465
			);
466
		});
467
		$this->registerService('DateTimeZone', function (Server $c) {
468
			return new DateTimeZone(
469
				$c->getConfig(),
470
				$c->getSession()
471
			);
472
		});
473
		$this->registerService('DateTimeFormatter', function (Server $c) {
474
			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
475
476
			return new DateTimeFormatter(
477
				$c->getDateTimeZone()->getTimeZone(),
478
				$c->getL10N('lib', $language)
479
			);
480
		});
481
		$this->registerService('UserMountCache', function (Server $c) {
482
			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
483
			$listener = new UserMountCacheListener($mountCache);
484
			$listener->listen($c->getUserManager());
485
			return $mountCache;
486
		});
487
		$this->registerService('MountConfigManager', function (Server $c) {
488
			$loader = \OC\Files\Filesystem::getLoader();
489
			$mountCache = $c->query('UserMountCache');
490
			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
491
492
			// builtin providers
493
494
			$config = $c->getConfig();
495
			$manager->registerProvider(new CacheMountProvider($config));
496
			$manager->registerHomeProvider(new LocalHomeMountProvider());
497
			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
498
499
			return $manager;
500
		});
501
		$this->registerService('IniWrapper', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
502
			return new IniGetWrapper();
503
		});
504
		$this->registerService('AsyncCommandBus', function (Server $c) {
505
			$jobList = $c->getJobList();
506
			return new AsyncBus($jobList);
507
		});
508
		$this->registerService('TrustedDomainHelper', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
509
			return new TrustedDomainHelper($this->getConfig());
510
		});
511
		$this->registerService('Throttler', function(Server $c) {
512
			return new Throttler(
513
				$c->getDatabaseConnection(),
514
				new TimeFactory(),
515
				$c->getLogger(),
516
				$c->getConfig()
517
			);
518
		});
519
		$this->registerService('IntegrityCodeChecker', function (Server $c) {
520
			// IConfig and IAppManager requires a working database. This code
521
			// might however be called when ownCloud is not yet setup.
522
			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
523
				$config = $c->getConfig();
524
				$appManager = $c->getAppManager();
525
			} else {
526
				$config = null;
527
				$appManager = null;
528
			}
529
530
			return new Checker(
531
					new EnvironmentHelper(),
532
					new FileAccessHelper(),
533
					new AppLocator(),
534
					$config,
535
					$c->getMemCacheFactory(),
536
					$appManager,
537
					$c->getTempManager()
538
			);
539
		});
540
		$this->registerService('Request', function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
541
			if (isset($this['urlParams'])) {
542
				$urlParams = $this['urlParams'];
543
			} else {
544
				$urlParams = [];
545
			}
546
547
			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
548
				&& in_array('fakeinput', stream_get_wrappers())
549
			) {
550
				$stream = 'fakeinput://data';
551
			} else {
552
				$stream = 'php://input';
553
			}
554
555
			return new Request(
556
				[
557
					'get' => $_GET,
558
					'post' => $_POST,
559
					'files' => $_FILES,
560
					'server' => $_SERVER,
561
					'env' => $_ENV,
562
					'cookies' => $_COOKIE,
563
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
564
						? $_SERVER['REQUEST_METHOD']
565
						: null,
566
					'urlParams' => $urlParams,
567
				],
568
				$this->getSecureRandom(),
569
				$this->getConfig(),
570
				$this->getCsrfTokenManager(),
571
				$stream
572
			);
573
		});
574
		$this->registerService('Mailer', function (Server $c) {
575
			return new Mailer(
576
				$c->getConfig(),
577
				$c->getLogger(),
578
				$c->getThemingDefaults()
579
			);
580
		});
581
		$this->registerService('OcsClient', function (Server $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
582
			return new OCSClient(
583
				$this->getHTTPClientService(),
584
				$this->getConfig(),
585
				$this->getLogger()
586
			);
587
		});
588
		$this->registerService('LDAPProvider', function(Server $c) {
589
			$config = $c->getConfig();
590
			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
591
			if(is_null($factoryClass)) {
592
				throw new \Exception('ldapProviderFactory not set');
593
			}
594
			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
595
			$factory = new $factoryClass($this);
596
			return $factory->getLDAPProvider();
597
		});
598
		$this->registerService('LockingProvider', function (Server $c) {
599
			$ini = $c->getIniWrapper();
600
			$config = $c->getConfig();
601
			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
602
			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
603
				/** @var \OC\Memcache\Factory $memcacheFactory */
604
				$memcacheFactory = $c->getMemCacheFactory();
605
				$memcache = $memcacheFactory->createLocking('lock');
606
				if (!($memcache instanceof \OC\Memcache\NullCache)) {
607
					return new MemcacheLockingProvider($memcache, $ttl);
608
				}
609
				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
610
			}
611
			return new NoopLockingProvider();
612
		});
613
		$this->registerService('MountManager', function () {
614
			return new \OC\Files\Mount\Manager();
615
		});
616
		$this->registerService('MimeTypeDetector', function (Server $c) {
617
			return new \OC\Files\Type\Detection(
618
				$c->getURLGenerator(),
619
				\OC::$SERVERROOT . '/config/',
620
				\OC::$SERVERROOT . '/resources/config/'
621
			);
622
		});
623
		$this->registerService('MimeTypeLoader', function (Server $c) {
624
			return new \OC\Files\Type\Loader(
625
				$c->getDatabaseConnection()
626
			);
627
		});
628
		$this->registerService('NotificationManager', function () {
629
			return new Manager();
630
		});
631
		$this->registerService('CapabilitiesManager', function (Server $c) {
632
			$manager = new \OC\CapabilitiesManager();
633
			$manager->registerCapability(function () use ($c) {
634
				return new \OC\OCS\CoreCapabilities($c->getConfig());
635
			});
636
			return $manager;
637
		});
638 View Code Duplication
		$this->registerService('CommentsManager', function(Server $c) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
639
			$config = $c->getConfig();
640
			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
641
			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
642
			$factory = new $factoryClass($this);
643
			return $factory->getManager();
644
		});
645
		$this->registerService('ThemingDefaults', function(Server $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
646
			try {
647
				$classExists = class_exists('OCA\Theming\Template');
648
			} catch (\OCP\AutoloadNotAllowedException $e) {
649
				// App disabled or in maintenance mode
650
				$classExists = false;
651
			}
652
653
			if ($classExists && $this->getConfig()->getSystemValue('installed', false) && $this->getAppManager()->isInstalled('theming')) {
654
				return new Template(
655
					$this->getConfig(),
656
					$this->getL10N('theming'),
657
					$this->getURLGenerator(),
658
					new \OC_Defaults()
659
				);
660
			}
661
			return new \OC_Defaults();
662
		});
663
		$this->registerService('EventDispatcher', function () {
664
			return new EventDispatcher();
665
		});
666
		$this->registerService('CryptoWrapper', function (Server $c) {
667
			// FIXME: Instantiiated here due to cyclic dependency
668
			$request = new Request(
669
				[
670
					'get' => $_GET,
671
					'post' => $_POST,
672
					'files' => $_FILES,
673
					'server' => $_SERVER,
674
					'env' => $_ENV,
675
					'cookies' => $_COOKIE,
676
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
677
						? $_SERVER['REQUEST_METHOD']
678
						: null,
679
				],
680
				$c->getSecureRandom(),
681
				$c->getConfig()
682
			);
683
684
			return new CryptoWrapper(
685
				$c->getConfig(),
686
				$c->getCrypto(),
687
				$c->getSecureRandom(),
688
				$request
689
			);
690
		});
691
		$this->registerService('CsrfTokenManager', function (Server $c) {
692
			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
693
			$sessionStorage = new SessionStorage($c->getSession());
694
695
			return new CsrfTokenManager(
696
				$tokenGenerator,
697
				$sessionStorage
698
			);
699
		});
700
		$this->registerService('ContentSecurityPolicyManager', function (Server $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
701
			return new ContentSecurityPolicyManager();
702
		});
703
		$this->registerService('ShareManager', function(Server $c) {
704
			$config = $c->getConfig();
705
			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
706
			/** @var \OCP\Share\IProviderFactory $factory */
707
			$factory = new $factoryClass($this);
708
709
			$manager = new \OC\Share20\Manager(
710
				$c->getLogger(),
711
				$c->getConfig(),
712
				$c->getSecureRandom(),
713
				$c->getHasher(),
714
				$c->getMountManager(),
715
				$c->getGroupManager(),
716
				$c->getL10N('core'),
717
				$factory,
718
				$c->getUserManager(),
719
				$c->getLazyRootFolder(),
720
				$c->getEventDispatcher()
721
			);
722
723
			return $manager;
724
		});
725
	}
726
727
	/**
728
	 * @return \OCP\Contacts\IManager
729
	 */
730
	public function getContactsManager() {
731
		return $this->query('ContactsManager');
732
	}
733
734
	/**
735
	 * @return \OC\Encryption\Manager
736
	 */
737
	public function getEncryptionManager() {
738
		return $this->query('EncryptionManager');
739
	}
740
741
	/**
742
	 * @return \OC\Encryption\File
743
	 */
744
	public function getEncryptionFilesHelper() {
745
		return $this->query('EncryptionFileHelper');
746
	}
747
748
	/**
749
	 * @return \OCP\Encryption\Keys\IStorage
750
	 */
751
	public function getEncryptionKeyStorage() {
752
		return $this->query('EncryptionKeyStorage');
753
	}
754
755
	/**
756
	 * The current request object holding all information about the request
757
	 * currently being processed is returned from this method.
758
	 * In case the current execution was not initiated by a web request null is returned
759
	 *
760
	 * @return \OCP\IRequest
761
	 */
762
	public function getRequest() {
763
		return $this->query('Request');
764
	}
765
766
	/**
767
	 * Returns the preview manager which can create preview images for a given file
768
	 *
769
	 * @return \OCP\IPreview
770
	 */
771
	public function getPreviewManager() {
772
		return $this->query('PreviewManager');
773
	}
774
775
	/**
776
	 * Returns the tag manager which can get and set tags for different object types
777
	 *
778
	 * @see \OCP\ITagManager::load()
779
	 * @return \OCP\ITagManager
780
	 */
781
	public function getTagManager() {
782
		return $this->query('TagManager');
783
	}
784
785
	/**
786
	 * Returns the system-tag manager
787
	 *
788
	 * @return \OCP\SystemTag\ISystemTagManager
789
	 *
790
	 * @since 9.0.0
791
	 */
792
	public function getSystemTagManager() {
793
		return $this->query('SystemTagManager');
794
	}
795
796
	/**
797
	 * Returns the system-tag object mapper
798
	 *
799
	 * @return \OCP\SystemTag\ISystemTagObjectMapper
800
	 *
801
	 * @since 9.0.0
802
	 */
803
	public function getSystemTagObjectMapper() {
804
		return $this->query('SystemTagObjectMapper');
805
	}
806
807
808
	/**
809
	 * Returns the avatar manager, used for avatar functionality
810
	 *
811
	 * @return \OCP\IAvatarManager
812
	 */
813
	public function getAvatarManager() {
814
		return $this->query('AvatarManager');
815
	}
816
817
	/**
818
	 * Returns the root folder of ownCloud's data directory
819
	 *
820
	 * @return \OCP\Files\IRootFolder
821
	 */
822
	public function getRootFolder() {
823
		return $this->query('RootFolder');
824
	}
825
826
	/**
827
	 * Returns the root folder of ownCloud's data directory
828
	 * This is the lazy variant so this gets only initialized once it
829
	 * is actually used.
830
	 *
831
	 * @return \OCP\Files\IRootFolder
832
	 */
833
	public function getLazyRootFolder() {
834
		return $this->query('LazyRootFolder');
835
	}
836
837
	/**
838
	 * Returns a view to ownCloud's files folder
839
	 *
840
	 * @param string $userId user ID
841
	 * @return \OCP\Files\Folder|null
842
	 */
843
	public function getUserFolder($userId = null) {
844 View Code Duplication
		if ($userId === null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
845
			$user = $this->getUserSession()->getUser();
846
			if (!$user) {
847
				return null;
848
			}
849
			$userId = $user->getUID();
850
		}
851
		$root = $this->getRootFolder();
852
		return $root->getUserFolder($userId);
853
	}
854
855
	/**
856
	 * Returns an app-specific view in ownClouds data directory
857
	 *
858
	 * @return \OCP\Files\Folder
859
	 */
860
	public function getAppFolder() {
861
		$dir = '/' . \OC_App::getCurrentApp();
862
		$root = $this->getRootFolder();
863
		if (!$root->nodeExists($dir)) {
864
			$folder = $root->newFolder($dir);
865
		} else {
866
			$folder = $root->get($dir);
867
		}
868
		return $folder;
869
	}
870
871
	/**
872
	 * @return \OC\User\Manager
873
	 */
874
	public function getUserManager() {
875
		return $this->query('UserManager');
876
	}
877
878
	/**
879
	 * @return \OC\Group\Manager
880
	 */
881
	public function getGroupManager() {
882
		return $this->query('GroupManager');
883
	}
884
885
	/**
886
	 * @return \OC\User\Session
887
	 */
888
	public function getUserSession() {
889
		return $this->query('UserSession');
890
	}
891
892
	/**
893
	 * @return \OCP\ISession
894
	 */
895
	public function getSession() {
896
		return $this->query('UserSession')->getSession();
897
	}
898
899
	/**
900
	 * @param \OCP\ISession $session
901
	 */
902
	public function setSession(\OCP\ISession $session) {
903
		return $this->query('UserSession')->setSession($session);
904
	}
905
906
	/**
907
	 * @return \OC\Authentication\TwoFactorAuth\Manager
908
	 */
909
	public function getTwoFactorAuthManager() {
910
		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
911
	}
912
913
	/**
914
	 * @return \OC\NavigationManager
915
	 */
916
	public function getNavigationManager() {
917
		return $this->query('NavigationManager');
918
	}
919
920
	/**
921
	 * @return \OCP\IConfig
922
	 */
923
	public function getConfig() {
924
		return $this->query('AllConfig');
925
	}
926
927
	/**
928
	 * @internal For internal use only
929
	 * @return \OC\SystemConfig
930
	 */
931
	public function getSystemConfig() {
932
		return $this->query('SystemConfig');
933
	}
934
935
	/**
936
	 * Returns the app config manager
937
	 *
938
	 * @return \OCP\IAppConfig
939
	 */
940
	public function getAppConfig() {
941
		return $this->query('AppConfig');
942
	}
943
944
	/**
945
	 * @return \OCP\L10N\IFactory
946
	 */
947
	public function getL10NFactory() {
948
		return $this->query('L10NFactory');
949
	}
950
951
	/**
952
	 * get an L10N instance
953
	 *
954
	 * @param string $app appid
955
	 * @param string $lang
956
	 * @return IL10N
957
	 */
958
	public function getL10N($app, $lang = null) {
959
		return $this->getL10NFactory()->get($app, $lang);
960
	}
961
962
	/**
963
	 * @return \OCP\IURLGenerator
964
	 */
965
	public function getURLGenerator() {
966
		return $this->query('URLGenerator');
967
	}
968
969
	/**
970
	 * @return \OCP\IHelper
971
	 */
972
	public function getHelper() {
973
		return $this->query('AppHelper');
974
	}
975
976
	/**
977
	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
978
	 * getMemCacheFactory() instead.
979
	 *
980
	 * @return \OCP\ICache
981
	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
982
	 */
983
	public function getCache() {
984
		return $this->query('UserCache');
985
	}
986
987
	/**
988
	 * Returns an \OCP\CacheFactory instance
989
	 *
990
	 * @return \OCP\ICacheFactory
991
	 */
992
	public function getMemCacheFactory() {
993
		return $this->query('MemCacheFactory');
994
	}
995
996
	/**
997
	 * Returns an \OC\RedisFactory instance
998
	 *
999
	 * @return \OC\RedisFactory
1000
	 */
1001
	public function getGetRedisFactory() {
1002
		return $this->query('RedisFactory');
1003
	}
1004
1005
1006
	/**
1007
	 * Returns the current session
1008
	 *
1009
	 * @return \OCP\IDBConnection
1010
	 */
1011
	public function getDatabaseConnection() {
1012
		return $this->query('DatabaseConnection');
1013
	}
1014
1015
	/**
1016
	 * Returns the activity manager
1017
	 *
1018
	 * @return \OCP\Activity\IManager
1019
	 */
1020
	public function getActivityManager() {
1021
		return $this->query('ActivityManager');
1022
	}
1023
1024
	/**
1025
	 * Returns an job list for controlling background jobs
1026
	 *
1027
	 * @return \OCP\BackgroundJob\IJobList
1028
	 */
1029
	public function getJobList() {
1030
		return $this->query('JobList');
1031
	}
1032
1033
	/**
1034
	 * Returns a logger instance
1035
	 *
1036
	 * @return \OCP\ILogger
1037
	 */
1038
	public function getLogger() {
1039
		return $this->query('Logger');
1040
	}
1041
1042
	/**
1043
	 * Returns a router for generating and matching urls
1044
	 *
1045
	 * @return \OCP\Route\IRouter
1046
	 */
1047
	public function getRouter() {
1048
		return $this->query('Router');
1049
	}
1050
1051
	/**
1052
	 * Returns a search instance
1053
	 *
1054
	 * @return \OCP\ISearch
1055
	 */
1056
	public function getSearch() {
1057
		return $this->query('Search');
1058
	}
1059
1060
	/**
1061
	 * Returns a SecureRandom instance
1062
	 *
1063
	 * @return \OCP\Security\ISecureRandom
1064
	 */
1065
	public function getSecureRandom() {
1066
		return $this->query('SecureRandom');
1067
	}
1068
1069
	/**
1070
	 * Returns a Crypto instance
1071
	 *
1072
	 * @return \OCP\Security\ICrypto
1073
	 */
1074
	public function getCrypto() {
1075
		return $this->query('Crypto');
1076
	}
1077
1078
	/**
1079
	 * Returns a Hasher instance
1080
	 *
1081
	 * @return \OCP\Security\IHasher
1082
	 */
1083
	public function getHasher() {
1084
		return $this->query('Hasher');
1085
	}
1086
1087
	/**
1088
	 * Returns a CredentialsManager instance
1089
	 *
1090
	 * @return \OCP\Security\ICredentialsManager
1091
	 */
1092
	public function getCredentialsManager() {
1093
		return $this->query('CredentialsManager');
1094
	}
1095
1096
	/**
1097
	 * Returns an instance of the db facade
1098
	 *
1099
	 * @deprecated use getDatabaseConnection, will be removed in ownCloud 10
1100
	 * @return \OCP\IDb
1101
	 */
1102
	public function getDb() {
1103
		return $this->query('Db');
1104
	}
1105
1106
	/**
1107
	 * Returns an instance of the HTTP helper class
1108
	 *
1109
	 * @deprecated Use getHTTPClientService()
1110
	 * @return \OC\HTTPHelper
1111
	 */
1112
	public function getHTTPHelper() {
1113
		return $this->query('HTTPHelper');
1114
	}
1115
1116
	/**
1117
	 * Get the certificate manager for the user
1118
	 *
1119
	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1120
	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1121
	 */
1122
	public function getCertificateManager($userId = '') {
1123 View Code Duplication
		if ($userId === '') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1124
			$userSession = $this->getUserSession();
1125
			$user = $userSession->getUser();
1126
			if (is_null($user)) {
1127
				return null;
1128
			}
1129
			$userId = $user->getUID();
1130
		}
1131
		return new CertificateManager($userId, new View(), $this->getConfig());
1132
	}
1133
1134
	/**
1135
	 * Returns an instance of the HTTP client service
1136
	 *
1137
	 * @return \OCP\Http\Client\IClientService
1138
	 */
1139
	public function getHTTPClientService() {
1140
		return $this->query('HttpClientService');
1141
	}
1142
1143
	/**
1144
	 * Create a new event source
1145
	 *
1146
	 * @return \OCP\IEventSource
1147
	 */
1148
	public function createEventSource() {
1149
		return new \OC_EventSource();
1150
	}
1151
1152
	/**
1153
	 * Get the active event logger
1154
	 *
1155
	 * The returned logger only logs data when debug mode is enabled
1156
	 *
1157
	 * @return \OCP\Diagnostics\IEventLogger
1158
	 */
1159
	public function getEventLogger() {
1160
		return $this->query('EventLogger');
1161
	}
1162
1163
	/**
1164
	 * Get the active query logger
1165
	 *
1166
	 * The returned logger only logs data when debug mode is enabled
1167
	 *
1168
	 * @return \OCP\Diagnostics\IQueryLogger
1169
	 */
1170
	public function getQueryLogger() {
1171
		return $this->query('QueryLogger');
1172
	}
1173
1174
	/**
1175
	 * Get the manager for temporary files and folders
1176
	 *
1177
	 * @return \OCP\ITempManager
1178
	 */
1179
	public function getTempManager() {
1180
		return $this->query('TempManager');
1181
	}
1182
1183
	/**
1184
	 * Get the app manager
1185
	 *
1186
	 * @return \OCP\App\IAppManager
1187
	 */
1188
	public function getAppManager() {
1189
		return $this->query('AppManager');
1190
	}
1191
1192
	/**
1193
	 * Creates a new mailer
1194
	 *
1195
	 * @return \OCP\Mail\IMailer
1196
	 */
1197
	public function getMailer() {
1198
		return $this->query('Mailer');
1199
	}
1200
1201
	/**
1202
	 * Get the webroot
1203
	 *
1204
	 * @return string
1205
	 */
1206
	public function getWebRoot() {
1207
		return $this->webRoot;
1208
	}
1209
1210
	/**
1211
	 * @return \OC\OCSClient
1212
	 */
1213
	public function getOcsClient() {
1214
		return $this->query('OcsClient');
1215
	}
1216
1217
	/**
1218
	 * @return \OCP\IDateTimeZone
1219
	 */
1220
	public function getDateTimeZone() {
1221
		return $this->query('DateTimeZone');
1222
	}
1223
1224
	/**
1225
	 * @return \OCP\IDateTimeFormatter
1226
	 */
1227
	public function getDateTimeFormatter() {
1228
		return $this->query('DateTimeFormatter');
1229
	}
1230
1231
	/**
1232
	 * @return \OCP\Files\Config\IMountProviderCollection
1233
	 */
1234
	public function getMountProviderCollection() {
1235
		return $this->query('MountConfigManager');
1236
	}
1237
1238
	/**
1239
	 * Get the IniWrapper
1240
	 *
1241
	 * @return IniGetWrapper
1242
	 */
1243
	public function getIniWrapper() {
1244
		return $this->query('IniWrapper');
1245
	}
1246
1247
	/**
1248
	 * @return \OCP\Command\IBus
1249
	 */
1250
	public function getCommandBus() {
1251
		return $this->query('AsyncCommandBus');
1252
	}
1253
1254
	/**
1255
	 * Get the trusted domain helper
1256
	 *
1257
	 * @return TrustedDomainHelper
1258
	 */
1259
	public function getTrustedDomainHelper() {
1260
		return $this->query('TrustedDomainHelper');
1261
	}
1262
1263
	/**
1264
	 * Get the locking provider
1265
	 *
1266
	 * @return \OCP\Lock\ILockingProvider
1267
	 * @since 8.1.0
1268
	 */
1269
	public function getLockingProvider() {
1270
		return $this->query('LockingProvider');
1271
	}
1272
1273
	/**
1274
	 * @return \OCP\Files\Mount\IMountManager
1275
	 **/
1276
	function getMountManager() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
1277
		return $this->query('MountManager');
1278
	}
1279
1280
	/**
1281
	 * Get the MimeTypeDetector
1282
	 *
1283
	 * @return \OCP\Files\IMimeTypeDetector
1284
	 */
1285
	public function getMimeTypeDetector() {
1286
		return $this->query('MimeTypeDetector');
1287
	}
1288
1289
	/**
1290
	 * Get the MimeTypeLoader
1291
	 *
1292
	 * @return \OCP\Files\IMimeTypeLoader
1293
	 */
1294
	public function getMimeTypeLoader() {
1295
		return $this->query('MimeTypeLoader');
1296
	}
1297
1298
	/**
1299
	 * Get the manager of all the capabilities
1300
	 *
1301
	 * @return \OC\CapabilitiesManager
1302
	 */
1303
	public function getCapabilitiesManager() {
1304
		return $this->query('CapabilitiesManager');
1305
	}
1306
1307
	/**
1308
	 * Get the EventDispatcher
1309
	 *
1310
	 * @return EventDispatcherInterface
1311
	 * @since 8.2.0
1312
	 */
1313
	public function getEventDispatcher() {
1314
		return $this->query('EventDispatcher');
1315
	}
1316
1317
	/**
1318
	 * Get the Notification Manager
1319
	 *
1320
	 * @return \OCP\Notification\IManager
1321
	 * @since 8.2.0
1322
	 */
1323
	public function getNotificationManager() {
1324
		return $this->query('NotificationManager');
1325
	}
1326
1327
	/**
1328
	 * @return \OCP\Comments\ICommentsManager
1329
	 */
1330
	public function getCommentsManager() {
1331
		return $this->query('CommentsManager');
1332
	}
1333
1334
	/**
1335
	 * @internal Not public by intention.
1336
	 * @return \OC_Defaults
1337
	 */
1338
	public function getThemingDefaults() {
1339
		return $this->query('ThemingDefaults');
1340
	}
1341
1342
	/**
1343
	 * @return \OC\IntegrityCheck\Checker
1344
	 */
1345
	public function getIntegrityCodeChecker() {
1346
		return $this->query('IntegrityCodeChecker');
1347
	}
1348
1349
	/**
1350
	 * @return \OC\Session\CryptoWrapper
1351
	 */
1352
	public function getSessionCryptoWrapper() {
1353
		return $this->query('CryptoWrapper');
1354
	}
1355
1356
	/**
1357
	 * @return CsrfTokenManager
1358
	 */
1359
	public function getCsrfTokenManager() {
1360
		return $this->query('CsrfTokenManager');
1361
	}
1362
1363
	/**
1364
	 * @return Throttler
1365
	 */
1366
	public function getBruteForceThrottler() {
1367
		return $this->query('Throttler');
1368
	}
1369
1370
	/**
1371
	 * @return IContentSecurityPolicyManager
1372
	 */
1373
	public function getContentSecurityPolicyManager() {
1374
		return $this->query('ContentSecurityPolicyManager');
1375
	}
1376
1377
	/**
1378
	 * Not a public API as of 8.2, wait for 9.0
1379
	 *
1380
	 * @return \OCA\Files_External\Service\BackendService
1381
	 */
1382
	public function getStoragesBackendService() {
1383
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\BackendService');
1384
	}
1385
1386
	/**
1387
	 * Not a public API as of 8.2, wait for 9.0
1388
	 *
1389
	 * @return \OCA\Files_External\Service\GlobalStoragesService
1390
	 */
1391
	public function getGlobalStoragesService() {
1392
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1393
	}
1394
1395
	/**
1396
	 * Not a public API as of 8.2, wait for 9.0
1397
	 *
1398
	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1399
	 */
1400
	public function getUserGlobalStoragesService() {
1401
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1402
	}
1403
1404
	/**
1405
	 * Not a public API as of 8.2, wait for 9.0
1406
	 *
1407
	 * @return \OCA\Files_External\Service\UserStoragesService
1408
	 */
1409
	public function getUserStoragesService() {
1410
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserStoragesService');
1411
	}
1412
1413
	/**
1414
	 * @return \OCP\Share\IManager
1415
	 */
1416
	public function getShareManager() {
1417
		return $this->query('ShareManager');
1418
	}
1419
1420
	/**
1421
	 * Returns the LDAP Provider
1422
	 *
1423
	 * @return \OCP\LDAP\ILDAPProvider
1424
	 */
1425
	public function getLDAPProvider() {
1426
		return $this->query('LDAPProvider');
1427
	}
1428
}
1429