Completed
Pull Request — master (#479)
by Lukas
33:52 queued 25:33
created

Server::getMailer()   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
 * @author Arthur Schiwon <[email protected]>
4
 * @author Bart Visscher <[email protected]>
5
 * @author Bernhard Posselt <[email protected]>
6
 * @author Bernhard Reiter <[email protected]>
7
 * @author Björn Schießle <[email protected]>
8
 * @author Christoph Wurst <[email protected]>
9
 * @author Christopher Schäpers <[email protected]>
10
 * @author Joas Schilling <[email protected]>
11
 * @author Jörn Friedrich Dreyer <[email protected]>
12
 * @author Lukas Reschke <[email protected]>
13
 * @author Morris Jobke <[email protected]>
14
 * @author Robin Appelman <[email protected]>
15
 * @author Robin McCorkell <[email protected]>
16
 * @author Roeland Jago Douma <[email protected]>
17
 * @author Sander <[email protected]>
18
 * @author Thomas Müller <[email protected]>
19
 * @author Thomas Tanghus <[email protected]>
20
 * @author Vincent Petry <[email protected]>
21
 *
22
 * @copyright Copyright (c) 2016, ownCloud, Inc.
23
 * @license AGPL-3.0
24
 *
25
 * This code is free software: you can redistribute it and/or modify
26
 * it under the terms of the GNU Affero General Public License, version 3,
27
 * as published by the Free Software Foundation.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
 * GNU Affero General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU Affero General Public License, version 3,
35
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
36
 *
37
 */
38
namespace OC;
39
40
use bantu\IniGetWrapper\IniGetWrapper;
41
use OC\AppFramework\Http\Request;
42
use OC\AppFramework\Db\Db;
43
use OC\AppFramework\Utility\TimeFactory;
44
use OC\Command\AsyncBus;
45
use OC\Diagnostics\EventLogger;
46
use OC\Diagnostics\NullEventLogger;
47
use OC\Diagnostics\NullQueryLogger;
48
use OC\Diagnostics\QueryLogger;
49
use OC\Files\Config\UserMountCache;
50
use OC\Files\Config\UserMountCacheListener;
51
use OC\Files\Mount\CacheMountProvider;
52
use OC\Files\Mount\LocalHomeMountProvider;
53
use OC\Files\Mount\ObjectHomeMountProvider;
54
use OC\Files\Node\HookConnector;
55
use OC\Files\Node\LazyRoot;
56
use OC\Files\Node\Root;
57
use OC\Files\View;
58
use OC\Http\Client\ClientService;
59
use OC\IntegrityCheck\Checker;
60
use OC\IntegrityCheck\Helpers\AppLocator;
61
use OC\IntegrityCheck\Helpers\EnvironmentHelper;
62
use OC\IntegrityCheck\Helpers\FileAccessHelper;
63
use OC\Lock\DBLockingProvider;
64
use OC\Lock\MemcacheLockingProvider;
65
use OC\Lock\NoopLockingProvider;
66
use OC\Mail\Mailer;
67
use OC\Memcache\ArrayCache;
68
use OC\Notification\Manager;
69
use OC\Security\Bruteforce\Throttler;
70
use OC\Security\CertificateManager;
71
use OC\Security\CSP\ContentSecurityPolicyManager;
72
use OC\Security\Crypto;
73
use OC\Security\CSRF\CsrfTokenGenerator;
74
use OC\Security\CSRF\CsrfTokenManager;
75
use OC\Security\CSRF\TokenStorage\SessionStorage;
76
use OC\Security\Hasher;
77
use OC\Security\CredentialsManager;
78
use OC\Security\SecureRandom;
79
use OC\Security\TrustedDomainHelper;
80
use OC\Session\CryptoWrapper;
81
use OC\Tagging\TagMapper;
82
use OCA\Theming\Template;
83
use OCP\IL10N;
84
use OCP\IServerContainer;
85
use OCP\Security\IContentSecurityPolicyManager;
86
use Symfony\Component\EventDispatcher\EventDispatcher;
87
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
88
89
/**
90
 * Class Server
91
 *
92
 * @package OC
93
 *
94
 * TODO: hookup all manager classes
95
 */
96
class Server extends ServerContainer implements IServerContainer {
97
	/** @var string */
98
	private $webRoot;
99
100
	/**
101
	 * @param string $webRoot
102
	 * @param \OC\Config $config
103
	 */
104
	public function __construct($webRoot, \OC\Config $config) {
105
		parent::__construct();
106
		$this->webRoot = $webRoot;
107
108
		$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...
109
			return new ContactsManager();
110
		});
111
112
		$this->registerService('PreviewManager', function (Server $c) {
113
			return new PreviewManager($c->getConfig());
114
		});
115
116
		$this->registerService('EncryptionManager', function (Server $c) {
117
			$view = new View();
118
			$util = new Encryption\Util(
119
				$view,
120
				$c->getUserManager(),
121
				$c->getGroupManager(),
122
				$c->getConfig()
123
			);
124
			return new Encryption\Manager(
125
				$c->getConfig(),
126
				$c->getLogger(),
127
				$c->getL10N('core'),
128
				new View(),
129
				$util,
130
				new ArrayCache()
131
			);
132
		});
133
134
		$this->registerService('EncryptionFileHelper', function (Server $c) {
135
			$util = new Encryption\Util(
136
				new View(),
137
				$c->getUserManager(),
138
				$c->getGroupManager(),
139
				$c->getConfig()
140
			);
141
			return new Encryption\File($util);
142
		});
143
144
		$this->registerService('EncryptionKeyStorage', function (Server $c) {
145
			$view = new View();
146
			$util = new Encryption\Util(
147
				$view,
148
				$c->getUserManager(),
149
				$c->getGroupManager(),
150
				$c->getConfig()
151
			);
152
153
			return new Encryption\Keys\Storage($view, $util);
154
		});
155
		$this->registerService('TagMapper', function (Server $c) {
156
			return new TagMapper($c->getDatabaseConnection());
157
		});
158
		$this->registerService('TagManager', function (Server $c) {
159
			$tagMapper = $c->query('TagMapper');
160
			return new TagManager($tagMapper, $c->getUserSession());
161
		});
162 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...
163
			$config = $c->getConfig();
164
			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
165
			/** @var \OC\SystemTag\ManagerFactory $factory */
166
			$factory = new $factoryClass($this);
167
			return $factory;
168
		});
169
		$this->registerService('SystemTagManager', function (Server $c) {
170
			return $c->query('SystemTagManagerFactory')->getManager();
171
		});
172
		$this->registerService('SystemTagObjectMapper', function (Server $c) {
173
			return $c->query('SystemTagManagerFactory')->getObjectMapper();
174
		});
175
		$this->registerService('RootFolder', function () {
176
			$manager = \OC\Files\Filesystem::getMountManager(null);
177
			$view = new View();
178
			$root = new Root($manager, $view, null);
179
			$connector = new HookConnector($root, $view);
180
			$connector->viewToNode();
181
			return $root;
182
		});
183
		$this->registerService('LazyRootFolder', function(Server $c) {
184
			return new LazyRoot(function() use ($c) {
185
				return $c->getRootFolder();
186
			});
187
		});
188
		$this->registerService('UserManager', function (Server $c) {
189
			$config = $c->getConfig();
190
			return new \OC\User\Manager($config);
191
		});
192
		$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...
193
			$groupManager = new \OC\Group\Manager($this->getUserManager());
194
			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
195
				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
196
			});
197
			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
198
				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
199
			});
200
			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
201
				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
202
			});
203
			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
204
				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
205
			});
206
			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
207
				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
208
			});
209
			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
210
				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
211
				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
212
				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
213
			});
214
			return $groupManager;
215
		});
216
		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
217
			$dbConnection = $c->getDatabaseConnection();
218
			return new Authentication\Token\DefaultTokenMapper($dbConnection);
219
		});
220
		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
221
			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
222
			$crypto = $c->getCrypto();
223
			$config = $c->getConfig();
224
			$logger = $c->getLogger();
225
			$timeFactory = new TimeFactory();
226
			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
227
		});
228
		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
229
		$this->registerService('UserSession', function (Server $c) {
230
			$manager = $c->getUserManager();
231
			$session = new \OC\Session\Memory('');
232
			$timeFactory = new TimeFactory();
233
			// Token providers might require a working database. This code
234
			// might however be called when ownCloud is not yet setup.
235 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...
236
				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
237
			} else {
238
				$defaultTokenProvider = null;
239
			}
240
241
			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig());
242
			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
243
				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
244
			});
245
			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
246
				/** @var $user \OC\User\User */
247
				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
248
			});
249
			$userSession->listen('\OC\User', 'preDelete', function ($user) {
250
				/** @var $user \OC\User\User */
251
				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
252
			});
253
			$userSession->listen('\OC\User', 'postDelete', function ($user) {
254
				/** @var $user \OC\User\User */
255
				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
256
			});
257 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...
258
				/** @var $user \OC\User\User */
259
				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
260
			});
261 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...
262
				/** @var $user \OC\User\User */
263
				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
264
			});
265
			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
266
				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
267
			});
268
			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
269
				/** @var $user \OC\User\User */
270
				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
271
			});
272
			$userSession->listen('\OC\User', 'logout', function () {
273
				\OC_Hook::emit('OC_User', 'logout', array());
274
			});
275
			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
276
				/** @var $user \OC\User\User */
277
				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
278
			});
279
			return $userSession;
280
		});
281
282
		$this->registerService('\OC\Authentication\TwoFactorAuth\Manager', function (Server $c) {
283
			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...
284
		});
285
286
		$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...
287
			return new \OC\NavigationManager();
288
		});
289
		$this->registerService('AllConfig', function (Server $c) {
290
			return new \OC\AllConfig(
291
				$c->getSystemConfig()
292
			);
293
		});
294
		$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...
295
			return new \OC\SystemConfig($config);
296
		});
297
		$this->registerService('AppConfig', function (Server $c) {
298
			return new \OC\AppConfig($c->getDatabaseConnection());
299
		});
300
		$this->registerService('L10NFactory', function (Server $c) {
301
			return new \OC\L10N\Factory(
302
				$c->getConfig(),
303
				$c->getRequest(),
304
				$c->getUserSession(),
305
				\OC::$SERVERROOT
306
			);
307
		});
308
		$this->registerService('URLGenerator', function (Server $c) {
309
			$config = $c->getConfig();
310
			$cacheFactory = $c->getMemCacheFactory();
311
			return new \OC\URLGenerator(
312
				$config,
313
				$cacheFactory
314
			);
315
		});
316
		$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...
317
			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...
318
		});
319
		$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...
320
			return new Cache\File();
321
		});
322
		$this->registerService('MemCacheFactory', function (Server $c) {
323
			$config = $c->getConfig();
324
325
			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
326
				$v = \OC_App::getAppVersions();
327
				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
328
				$version = implode(',', $v);
329
				$instanceId = \OC_Util::getInstanceId();
330
				$path = \OC::$SERVERROOT;
331
				$prefix = md5($instanceId . '-' . $version . '-' . $path);
332
				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
333
					$config->getSystemValue('memcache.local', null),
334
					$config->getSystemValue('memcache.distributed', null),
335
					$config->getSystemValue('memcache.locking', null)
336
				);
337
			}
338
339
			return new \OC\Memcache\Factory('', $c->getLogger(),
340
				'\\OC\\Memcache\\ArrayCache',
341
				'\\OC\\Memcache\\ArrayCache',
342
				'\\OC\\Memcache\\ArrayCache'
343
			);
344
		});
345
		$this->registerService('RedisFactory', function (Server $c) {
346
			$systemConfig = $c->getSystemConfig();
347
			return new RedisFactory($systemConfig);
348
		});
349
		$this->registerService('ActivityManager', function (Server $c) {
350
			return new \OC\Activity\Manager(
351
				$c->getRequest(),
352
				$c->getUserSession(),
353
				$c->getConfig()
354
			);
355
		});
356
		$this->registerService('AvatarManager', function (Server $c) {
357
			return new AvatarManager(
358
				$c->getUserManager(),
359
				$c->getRootFolder(),
360
				$c->getL10N('lib'),
361
				$c->getLogger()
362
			);
363
		});
364
		$this->registerService('Logger', function (Server $c) {
365
			$logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud');
366
			$logger = 'OC\\Log\\' . ucfirst($logClass);
367
			call_user_func(array($logger, 'init'));
368
369
			return new Log($logger);
370
		});
371
		$this->registerService('JobList', function (Server $c) {
372
			$config = $c->getConfig();
373
			return new \OC\BackgroundJob\JobList(
374
				$c->getDatabaseConnection(),
375
				$config,
376
				new TimeFactory()
377
			);
378
		});
379
		$this->registerService('Router', function (Server $c) {
380
			$cacheFactory = $c->getMemCacheFactory();
381
			$logger = $c->getLogger();
382
			if ($cacheFactory->isAvailable()) {
383
				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
384
			} else {
385
				$router = new \OC\Route\Router($logger);
386
			}
387
			return $router;
388
		});
389
		$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...
390
			return new Search();
391
		});
392
		$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...
393
			return new SecureRandom();
394
		});
395
		$this->registerService('Crypto', function (Server $c) {
396
			return new Crypto($c->getConfig(), $c->getSecureRandom());
397
		});
398
		$this->registerService('Hasher', function (Server $c) {
399
			return new Hasher($c->getConfig());
400
		});
401
		$this->registerService('CredentialsManager', function (Server $c) {
402
			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
403
		});
404
		$this->registerService('DatabaseConnection', function (Server $c) {
405
			$factory = new \OC\DB\ConnectionFactory();
406
			$systemConfig = $c->getSystemConfig();
407
			$type = $systemConfig->getValue('dbtype', 'sqlite');
408
			if (!$factory->isValidType($type)) {
409
				throw new \OC\DatabaseException('Invalid database type');
410
			}
411
			$connectionParams = $factory->createConnectionParams($systemConfig);
412
			$connection = $factory->getConnection($type, $connectionParams);
413
			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
414
			return $connection;
415
		});
416
		$this->registerService('Db', function (Server $c) {
417
			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...
418
		});
419
		$this->registerService('HTTPHelper', function (Server $c) {
420
			$config = $c->getConfig();
421
			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...
422
				$config,
423
				$c->getHTTPClientService()
424
			);
425
		});
426
		$this->registerService('HttpClientService', function (Server $c) {
427
			$user = \OC_User::getUser();
428
			$uid = $user ? $user : null;
429
			return new ClientService(
430
				$c->getConfig(),
431
				new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
432
			);
433
		});
434
		$this->registerService('EventLogger', function (Server $c) {
435
			if ($c->getSystemConfig()->getValue('debug', false)) {
436
				return new EventLogger();
437
			} else {
438
				return new NullEventLogger();
439
			}
440
		});
441
		$this->registerService('QueryLogger', function (Server $c) {
442
			if ($c->getSystemConfig()->getValue('debug', false)) {
443
				return new QueryLogger();
444
			} else {
445
				return new NullQueryLogger();
446
			}
447
		});
448
		$this->registerService('TempManager', function (Server $c) {
449
			return new TempManager(
450
				$c->getLogger(),
451
				$c->getConfig()
452
			);
453
		});
454
		$this->registerService('AppManager', function (Server $c) {
455
			return new \OC\App\AppManager(
456
				$c->getUserSession(),
457
				$c->getAppConfig(),
458
				$c->getGroupManager(),
459
				$c->getMemCacheFactory(),
460
				$c->getEventDispatcher()
461
			);
462
		});
463
		$this->registerService('DateTimeZone', function (Server $c) {
464
			return new DateTimeZone(
465
				$c->getConfig(),
466
				$c->getSession()
467
			);
468
		});
469
		$this->registerService('DateTimeFormatter', function (Server $c) {
470
			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
471
472
			return new DateTimeFormatter(
473
				$c->getDateTimeZone()->getTimeZone(),
474
				$c->getL10N('lib', $language)
475
			);
476
		});
477
		$this->registerService('UserMountCache', function (Server $c) {
478
			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
479
			$listener = new UserMountCacheListener($mountCache);
480
			$listener->listen($c->getUserManager());
481
			return $mountCache;
482
		});
483
		$this->registerService('MountConfigManager', function (Server $c) {
484
			$loader = \OC\Files\Filesystem::getLoader();
485
			$mountCache = $c->query('UserMountCache');
486
			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
487
488
			// builtin providers
489
490
			$config = $c->getConfig();
491
			$manager->registerProvider(new CacheMountProvider($config));
492
			$manager->registerHomeProvider(new LocalHomeMountProvider());
493
			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
494
495
			return $manager;
496
		});
497
		$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...
498
			return new IniGetWrapper();
499
		});
500
		$this->registerService('AsyncCommandBus', function (Server $c) {
501
			$jobList = $c->getJobList();
502
			return new AsyncBus($jobList);
503
		});
504
		$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...
505
			return new TrustedDomainHelper($this->getConfig());
506
		});
507
		$this->registerService('Throttler', function(Server $c) {
508
			return new Throttler(
509
				$c->getDatabaseConnection(),
510
				new TimeFactory(),
511
				$c->getLogger(),
512
				$c->getConfig()
513
			);
514
		});
515
		$this->registerService('IntegrityCodeChecker', function (Server $c) {
516
			// IConfig and IAppManager requires a working database. This code
517
			// might however be called when ownCloud is not yet setup.
518
			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
519
				$config = $c->getConfig();
520
				$appManager = $c->getAppManager();
521
			} else {
522
				$config = null;
523
				$appManager = null;
524
			}
525
526
			return new Checker(
527
					new EnvironmentHelper(),
528
					new FileAccessHelper(),
529
					new AppLocator(),
530
					$config,
531
					$c->getMemCacheFactory(),
532
					$appManager,
533
					$c->getTempManager()
534
			);
535
		});
536
		$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...
537
			if (isset($this['urlParams'])) {
538
				$urlParams = $this['urlParams'];
539
			} else {
540
				$urlParams = [];
541
			}
542
543
			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
544
				&& in_array('fakeinput', stream_get_wrappers())
545
			) {
546
				$stream = 'fakeinput://data';
547
			} else {
548
				$stream = 'php://input';
549
			}
550
551
			return new Request(
552
				[
553
					'get' => $_GET,
554
					'post' => $_POST,
555
					'files' => $_FILES,
556
					'server' => $_SERVER,
557
					'env' => $_ENV,
558
					'cookies' => $_COOKIE,
559
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
560
						? $_SERVER['REQUEST_METHOD']
561
						: null,
562
					'urlParams' => $urlParams,
563
				],
564
				$this->getSecureRandom(),
565
				$this->getConfig(),
566
				$this->getCsrfTokenManager(),
567
				$stream
568
			);
569
		});
570
		$this->registerService('Mailer', function (Server $c) {
571
			return new Mailer(
572
				$c->getConfig(),
573
				$c->getLogger(),
574
				$c->getThemingDefaults()
575
			);
576
		});
577
		$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...
578
			return new OCSClient(
579
				$this->getHTTPClientService(),
580
				$this->getConfig(),
581
				$this->getLogger()
582
			);
583
		});
584
		$this->registerService('LockingProvider', function (Server $c) {
585
			$ini = $c->getIniWrapper();
586
			$config = $c->getConfig();
587
			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
588
			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
589
				/** @var \OC\Memcache\Factory $memcacheFactory */
590
				$memcacheFactory = $c->getMemCacheFactory();
591
				$memcache = $memcacheFactory->createLocking('lock');
592
				if (!($memcache instanceof \OC\Memcache\NullCache)) {
593
					return new MemcacheLockingProvider($memcache, $ttl);
594
				}
595
				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
596
			}
597
			return new NoopLockingProvider();
598
		});
599
		$this->registerService('MountManager', function () {
600
			return new \OC\Files\Mount\Manager();
601
		});
602
		$this->registerService('MimeTypeDetector', function (Server $c) {
603
			return new \OC\Files\Type\Detection(
604
				$c->getURLGenerator(),
605
				\OC::$SERVERROOT . '/config/',
606
				\OC::$SERVERROOT . '/resources/config/'
607
			);
608
		});
609
		$this->registerService('MimeTypeLoader', function (Server $c) {
610
			return new \OC\Files\Type\Loader(
611
				$c->getDatabaseConnection()
612
			);
613
		});
614
		$this->registerService('NotificationManager', function () {
615
			return new Manager();
616
		});
617
		$this->registerService('CapabilitiesManager', function (Server $c) {
618
			$manager = new \OC\CapabilitiesManager();
619
			$manager->registerCapability(function () use ($c) {
620
				return new \OC\OCS\CoreCapabilities($c->getConfig());
621
			});
622
			return $manager;
623
		});
624 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...
625
			$config = $c->getConfig();
626
			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
627
			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
628
			$factory = new $factoryClass($this);
629
			return $factory->getManager();
630
		});
631
		$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...
632
			if(class_exists('OCA\Theming\Template', false) && $this->getConfig()->getSystemValue('installed', false) && $this->getAppManager()->isInstalled('theming')) {
633
				return new Template(
634
					$this->getConfig(),
635
					$this->getL10N('theming'),
636
					$this->getURLGenerator(),
637
					new \OC_Defaults()
638
				);
639
			}
640
			return new \OC_Defaults();
641
		});
642
		$this->registerService('EventDispatcher', function () {
643
			return new EventDispatcher();
644
		});
645
		$this->registerService('CryptoWrapper', function (Server $c) {
646
			// FIXME: Instantiiated here due to cyclic dependency
647
			$request = new Request(
648
				[
649
					'get' => $_GET,
650
					'post' => $_POST,
651
					'files' => $_FILES,
652
					'server' => $_SERVER,
653
					'env' => $_ENV,
654
					'cookies' => $_COOKIE,
655
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
656
						? $_SERVER['REQUEST_METHOD']
657
						: null,
658
				],
659
				$c->getSecureRandom(),
660
				$c->getConfig()
661
			);
662
663
			return new CryptoWrapper(
664
				$c->getConfig(),
665
				$c->getCrypto(),
666
				$c->getSecureRandom(),
667
				$request
668
			);
669
		});
670
		$this->registerService('CsrfTokenManager', function (Server $c) {
671
			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
672
			$sessionStorage = new SessionStorage($c->getSession());
673
674
			return new CsrfTokenManager(
675
				$tokenGenerator,
676
				$sessionStorage
677
			);
678
		});
679
		$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...
680
			return new ContentSecurityPolicyManager();
681
		});
682
		$this->registerService('ShareManager', function(Server $c) {
683
			$config = $c->getConfig();
684
			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
685
			/** @var \OCP\Share\IProviderFactory $factory */
686
			$factory = new $factoryClass($this);
687
688
			$manager = new \OC\Share20\Manager(
689
				$c->getLogger(),
690
				$c->getConfig(),
691
				$c->getSecureRandom(),
692
				$c->getHasher(),
693
				$c->getMountManager(),
694
				$c->getGroupManager(),
695
				$c->getL10N('core'),
696
				$factory,
697
				$c->getUserManager(),
698
				$c->getLazyRootFolder(),
699
				$c->getEventDispatcher()
700
			);
701
702
			return $manager;
703
		});
704
	}
705
706
	/**
707
	 * @return \OCP\Contacts\IManager
708
	 */
709
	public function getContactsManager() {
710
		return $this->query('ContactsManager');
711
	}
712
713
	/**
714
	 * @return \OC\Encryption\Manager
715
	 */
716
	public function getEncryptionManager() {
717
		return $this->query('EncryptionManager');
718
	}
719
720
	/**
721
	 * @return \OC\Encryption\File
722
	 */
723
	public function getEncryptionFilesHelper() {
724
		return $this->query('EncryptionFileHelper');
725
	}
726
727
	/**
728
	 * @return \OCP\Encryption\Keys\IStorage
729
	 */
730
	public function getEncryptionKeyStorage() {
731
		return $this->query('EncryptionKeyStorage');
732
	}
733
734
	/**
735
	 * The current request object holding all information about the request
736
	 * currently being processed is returned from this method.
737
	 * In case the current execution was not initiated by a web request null is returned
738
	 *
739
	 * @return \OCP\IRequest
740
	 */
741
	public function getRequest() {
742
		return $this->query('Request');
743
	}
744
745
	/**
746
	 * Returns the preview manager which can create preview images for a given file
747
	 *
748
	 * @return \OCP\IPreview
749
	 */
750
	public function getPreviewManager() {
751
		return $this->query('PreviewManager');
752
	}
753
754
	/**
755
	 * Returns the tag manager which can get and set tags for different object types
756
	 *
757
	 * @see \OCP\ITagManager::load()
758
	 * @return \OCP\ITagManager
759
	 */
760
	public function getTagManager() {
761
		return $this->query('TagManager');
762
	}
763
764
	/**
765
	 * Returns the system-tag manager
766
	 *
767
	 * @return \OCP\SystemTag\ISystemTagManager
768
	 *
769
	 * @since 9.0.0
770
	 */
771
	public function getSystemTagManager() {
772
		return $this->query('SystemTagManager');
773
	}
774
775
	/**
776
	 * Returns the system-tag object mapper
777
	 *
778
	 * @return \OCP\SystemTag\ISystemTagObjectMapper
779
	 *
780
	 * @since 9.0.0
781
	 */
782
	public function getSystemTagObjectMapper() {
783
		return $this->query('SystemTagObjectMapper');
784
	}
785
786
787
	/**
788
	 * Returns the avatar manager, used for avatar functionality
789
	 *
790
	 * @return \OCP\IAvatarManager
791
	 */
792
	public function getAvatarManager() {
793
		return $this->query('AvatarManager');
794
	}
795
796
	/**
797
	 * Returns the root folder of ownCloud's data directory
798
	 *
799
	 * @return \OCP\Files\IRootFolder
800
	 */
801
	public function getRootFolder() {
802
		return $this->query('RootFolder');
803
	}
804
805
	/**
806
	 * Returns the root folder of ownCloud's data directory
807
	 * This is the lazy variant so this gets only initialized once it
808
	 * is actually used.
809
	 *
810
	 * @return \OCP\Files\IRootFolder
811
	 */
812
	public function getLazyRootFolder() {
813
		return $this->query('LazyRootFolder');
814
	}
815
816
	/**
817
	 * Returns a view to ownCloud's files folder
818
	 *
819
	 * @param string $userId user ID
820
	 * @return \OCP\Files\Folder|null
821
	 */
822
	public function getUserFolder($userId = null) {
823 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...
824
			$user = $this->getUserSession()->getUser();
825
			if (!$user) {
826
				return null;
827
			}
828
			$userId = $user->getUID();
829
		}
830
		$root = $this->getRootFolder();
831
		return $root->getUserFolder($userId);
832
	}
833
834
	/**
835
	 * Returns an app-specific view in ownClouds data directory
836
	 *
837
	 * @return \OCP\Files\Folder
838
	 */
839
	public function getAppFolder() {
840
		$dir = '/' . \OC_App::getCurrentApp();
841
		$root = $this->getRootFolder();
842
		if (!$root->nodeExists($dir)) {
843
			$folder = $root->newFolder($dir);
844
		} else {
845
			$folder = $root->get($dir);
846
		}
847
		return $folder;
848
	}
849
850
	/**
851
	 * @return \OC\User\Manager
852
	 */
853
	public function getUserManager() {
854
		return $this->query('UserManager');
855
	}
856
857
	/**
858
	 * @return \OC\Group\Manager
859
	 */
860
	public function getGroupManager() {
861
		return $this->query('GroupManager');
862
	}
863
864
	/**
865
	 * @return \OC\User\Session
866
	 */
867
	public function getUserSession() {
868
		return $this->query('UserSession');
869
	}
870
871
	/**
872
	 * @return \OCP\ISession
873
	 */
874
	public function getSession() {
875
		return $this->query('UserSession')->getSession();
876
	}
877
878
	/**
879
	 * @param \OCP\ISession $session
880
	 */
881
	public function setSession(\OCP\ISession $session) {
882
		return $this->query('UserSession')->setSession($session);
883
	}
884
885
	/**
886
	 * @return \OC\Authentication\TwoFactorAuth\Manager
887
	 */
888
	public function getTwoFactorAuthManager() {
889
		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
890
	}
891
892
	/**
893
	 * @return \OC\NavigationManager
894
	 */
895
	public function getNavigationManager() {
896
		return $this->query('NavigationManager');
897
	}
898
899
	/**
900
	 * @return \OCP\IConfig
901
	 */
902
	public function getConfig() {
903
		return $this->query('AllConfig');
904
	}
905
906
	/**
907
	 * @internal For internal use only
908
	 * @return \OC\SystemConfig
909
	 */
910
	public function getSystemConfig() {
911
		return $this->query('SystemConfig');
912
	}
913
914
	/**
915
	 * Returns the app config manager
916
	 *
917
	 * @return \OCP\IAppConfig
918
	 */
919
	public function getAppConfig() {
920
		return $this->query('AppConfig');
921
	}
922
923
	/**
924
	 * @return \OCP\L10N\IFactory
925
	 */
926
	public function getL10NFactory() {
927
		return $this->query('L10NFactory');
928
	}
929
930
	/**
931
	 * get an L10N instance
932
	 *
933
	 * @param string $app appid
934
	 * @param string $lang
935
	 * @return IL10N
936
	 */
937
	public function getL10N($app, $lang = null) {
938
		return $this->getL10NFactory()->get($app, $lang);
939
	}
940
941
	/**
942
	 * @return \OCP\IURLGenerator
943
	 */
944
	public function getURLGenerator() {
945
		return $this->query('URLGenerator');
946
	}
947
948
	/**
949
	 * @return \OCP\IHelper
950
	 */
951
	public function getHelper() {
952
		return $this->query('AppHelper');
953
	}
954
955
	/**
956
	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
957
	 * getMemCacheFactory() instead.
958
	 *
959
	 * @return \OCP\ICache
960
	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
961
	 */
962
	public function getCache() {
963
		return $this->query('UserCache');
964
	}
965
966
	/**
967
	 * Returns an \OCP\CacheFactory instance
968
	 *
969
	 * @return \OCP\ICacheFactory
970
	 */
971
	public function getMemCacheFactory() {
972
		return $this->query('MemCacheFactory');
973
	}
974
975
	/**
976
	 * Returns an \OC\RedisFactory instance
977
	 *
978
	 * @return \OC\RedisFactory
979
	 */
980
	public function getGetRedisFactory() {
981
		return $this->query('RedisFactory');
982
	}
983
984
985
	/**
986
	 * Returns the current session
987
	 *
988
	 * @return \OCP\IDBConnection
989
	 */
990
	public function getDatabaseConnection() {
991
		return $this->query('DatabaseConnection');
992
	}
993
994
	/**
995
	 * Returns the activity manager
996
	 *
997
	 * @return \OCP\Activity\IManager
998
	 */
999
	public function getActivityManager() {
1000
		return $this->query('ActivityManager');
1001
	}
1002
1003
	/**
1004
	 * Returns an job list for controlling background jobs
1005
	 *
1006
	 * @return \OCP\BackgroundJob\IJobList
1007
	 */
1008
	public function getJobList() {
1009
		return $this->query('JobList');
1010
	}
1011
1012
	/**
1013
	 * Returns a logger instance
1014
	 *
1015
	 * @return \OCP\ILogger
1016
	 */
1017
	public function getLogger() {
1018
		return $this->query('Logger');
1019
	}
1020
1021
	/**
1022
	 * Returns a router for generating and matching urls
1023
	 *
1024
	 * @return \OCP\Route\IRouter
1025
	 */
1026
	public function getRouter() {
1027
		return $this->query('Router');
1028
	}
1029
1030
	/**
1031
	 * Returns a search instance
1032
	 *
1033
	 * @return \OCP\ISearch
1034
	 */
1035
	public function getSearch() {
1036
		return $this->query('Search');
1037
	}
1038
1039
	/**
1040
	 * Returns a SecureRandom instance
1041
	 *
1042
	 * @return \OCP\Security\ISecureRandom
1043
	 */
1044
	public function getSecureRandom() {
1045
		return $this->query('SecureRandom');
1046
	}
1047
1048
	/**
1049
	 * Returns a Crypto instance
1050
	 *
1051
	 * @return \OCP\Security\ICrypto
1052
	 */
1053
	public function getCrypto() {
1054
		return $this->query('Crypto');
1055
	}
1056
1057
	/**
1058
	 * Returns a Hasher instance
1059
	 *
1060
	 * @return \OCP\Security\IHasher
1061
	 */
1062
	public function getHasher() {
1063
		return $this->query('Hasher');
1064
	}
1065
1066
	/**
1067
	 * Returns a CredentialsManager instance
1068
	 *
1069
	 * @return \OCP\Security\ICredentialsManager
1070
	 */
1071
	public function getCredentialsManager() {
1072
		return $this->query('CredentialsManager');
1073
	}
1074
1075
	/**
1076
	 * Returns an instance of the db facade
1077
	 *
1078
	 * @deprecated use getDatabaseConnection, will be removed in ownCloud 10
1079
	 * @return \OCP\IDb
1080
	 */
1081
	public function getDb() {
1082
		return $this->query('Db');
1083
	}
1084
1085
	/**
1086
	 * Returns an instance of the HTTP helper class
1087
	 *
1088
	 * @deprecated Use getHTTPClientService()
1089
	 * @return \OC\HTTPHelper
1090
	 */
1091
	public function getHTTPHelper() {
1092
		return $this->query('HTTPHelper');
1093
	}
1094
1095
	/**
1096
	 * Get the certificate manager for the user
1097
	 *
1098
	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1099
	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1100
	 */
1101
	public function getCertificateManager($userId = '') {
1102 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...
1103
			$userSession = $this->getUserSession();
1104
			$user = $userSession->getUser();
1105
			if (is_null($user)) {
1106
				return null;
1107
			}
1108
			$userId = $user->getUID();
1109
		}
1110
		return new CertificateManager($userId, new View(), $this->getConfig());
1111
	}
1112
1113
	/**
1114
	 * Returns an instance of the HTTP client service
1115
	 *
1116
	 * @return \OCP\Http\Client\IClientService
1117
	 */
1118
	public function getHTTPClientService() {
1119
		return $this->query('HttpClientService');
1120
	}
1121
1122
	/**
1123
	 * Create a new event source
1124
	 *
1125
	 * @return \OCP\IEventSource
1126
	 */
1127
	public function createEventSource() {
1128
		return new \OC_EventSource();
1129
	}
1130
1131
	/**
1132
	 * Get the active event logger
1133
	 *
1134
	 * The returned logger only logs data when debug mode is enabled
1135
	 *
1136
	 * @return \OCP\Diagnostics\IEventLogger
1137
	 */
1138
	public function getEventLogger() {
1139
		return $this->query('EventLogger');
1140
	}
1141
1142
	/**
1143
	 * Get the active query logger
1144
	 *
1145
	 * The returned logger only logs data when debug mode is enabled
1146
	 *
1147
	 * @return \OCP\Diagnostics\IQueryLogger
1148
	 */
1149
	public function getQueryLogger() {
1150
		return $this->query('QueryLogger');
1151
	}
1152
1153
	/**
1154
	 * Get the manager for temporary files and folders
1155
	 *
1156
	 * @return \OCP\ITempManager
1157
	 */
1158
	public function getTempManager() {
1159
		return $this->query('TempManager');
1160
	}
1161
1162
	/**
1163
	 * Get the app manager
1164
	 *
1165
	 * @return \OCP\App\IAppManager
1166
	 */
1167
	public function getAppManager() {
1168
		return $this->query('AppManager');
1169
	}
1170
1171
	/**
1172
	 * Creates a new mailer
1173
	 *
1174
	 * @return \OCP\Mail\IMailer
1175
	 */
1176
	public function getMailer() {
1177
		return $this->query('Mailer');
1178
	}
1179
1180
	/**
1181
	 * Get the webroot
1182
	 *
1183
	 * @return string
1184
	 */
1185
	public function getWebRoot() {
1186
		return $this->webRoot;
1187
	}
1188
1189
	/**
1190
	 * @return \OC\OCSClient
1191
	 */
1192
	public function getOcsClient() {
1193
		return $this->query('OcsClient');
1194
	}
1195
1196
	/**
1197
	 * @return \OCP\IDateTimeZone
1198
	 */
1199
	public function getDateTimeZone() {
1200
		return $this->query('DateTimeZone');
1201
	}
1202
1203
	/**
1204
	 * @return \OCP\IDateTimeFormatter
1205
	 */
1206
	public function getDateTimeFormatter() {
1207
		return $this->query('DateTimeFormatter');
1208
	}
1209
1210
	/**
1211
	 * @return \OCP\Files\Config\IMountProviderCollection
1212
	 */
1213
	public function getMountProviderCollection() {
1214
		return $this->query('MountConfigManager');
1215
	}
1216
1217
	/**
1218
	 * Get the IniWrapper
1219
	 *
1220
	 * @return IniGetWrapper
1221
	 */
1222
	public function getIniWrapper() {
1223
		return $this->query('IniWrapper');
1224
	}
1225
1226
	/**
1227
	 * @return \OCP\Command\IBus
1228
	 */
1229
	public function getCommandBus() {
1230
		return $this->query('AsyncCommandBus');
1231
	}
1232
1233
	/**
1234
	 * Get the trusted domain helper
1235
	 *
1236
	 * @return TrustedDomainHelper
1237
	 */
1238
	public function getTrustedDomainHelper() {
1239
		return $this->query('TrustedDomainHelper');
1240
	}
1241
1242
	/**
1243
	 * Get the locking provider
1244
	 *
1245
	 * @return \OCP\Lock\ILockingProvider
1246
	 * @since 8.1.0
1247
	 */
1248
	public function getLockingProvider() {
1249
		return $this->query('LockingProvider');
1250
	}
1251
1252
	/**
1253
	 * @return \OCP\Files\Mount\IMountManager
1254
	 **/
1255
	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...
1256
		return $this->query('MountManager');
1257
	}
1258
1259
	/**
1260
	 * Get the MimeTypeDetector
1261
	 *
1262
	 * @return \OCP\Files\IMimeTypeDetector
1263
	 */
1264
	public function getMimeTypeDetector() {
1265
		return $this->query('MimeTypeDetector');
1266
	}
1267
1268
	/**
1269
	 * Get the MimeTypeLoader
1270
	 *
1271
	 * @return \OCP\Files\IMimeTypeLoader
1272
	 */
1273
	public function getMimeTypeLoader() {
1274
		return $this->query('MimeTypeLoader');
1275
	}
1276
1277
	/**
1278
	 * Get the manager of all the capabilities
1279
	 *
1280
	 * @return \OC\CapabilitiesManager
1281
	 */
1282
	public function getCapabilitiesManager() {
1283
		return $this->query('CapabilitiesManager');
1284
	}
1285
1286
	/**
1287
	 * Get the EventDispatcher
1288
	 *
1289
	 * @return EventDispatcherInterface
1290
	 * @since 8.2.0
1291
	 */
1292
	public function getEventDispatcher() {
1293
		return $this->query('EventDispatcher');
1294
	}
1295
1296
	/**
1297
	 * Get the Notification Manager
1298
	 *
1299
	 * @return \OCP\Notification\IManager
1300
	 * @since 8.2.0
1301
	 */
1302
	public function getNotificationManager() {
1303
		return $this->query('NotificationManager');
1304
	}
1305
1306
	/**
1307
	 * @return \OCP\Comments\ICommentsManager
1308
	 */
1309
	public function getCommentsManager() {
1310
		return $this->query('CommentsManager');
1311
	}
1312
1313
	/**
1314
	 * @internal Not public by intention.
1315
	 * @return \OC_Defaults
1316
	 */
1317
	public function getThemingDefaults() {
1318
		return $this->query('ThemingDefaults');
1319
	}
1320
1321
	/**
1322
	 * @return \OC\IntegrityCheck\Checker
1323
	 */
1324
	public function getIntegrityCodeChecker() {
1325
		return $this->query('IntegrityCodeChecker');
1326
	}
1327
1328
	/**
1329
	 * @return \OC\Session\CryptoWrapper
1330
	 */
1331
	public function getSessionCryptoWrapper() {
1332
		return $this->query('CryptoWrapper');
1333
	}
1334
1335
	/**
1336
	 * @return CsrfTokenManager
1337
	 */
1338
	public function getCsrfTokenManager() {
1339
		return $this->query('CsrfTokenManager');
1340
	}
1341
1342
	/**
1343
	 * @return Throttler
1344
	 */
1345
	public function getBruteForceThrottler() {
1346
		return $this->query('Throttler');
1347
	}
1348
1349
	/**
1350
	 * @return IContentSecurityPolicyManager
1351
	 */
1352
	public function getContentSecurityPolicyManager() {
1353
		return $this->query('ContentSecurityPolicyManager');
1354
	}
1355
1356
	/**
1357
	 * Not a public API as of 8.2, wait for 9.0
1358
	 *
1359
	 * @return \OCA\Files_External\Service\BackendService
1360
	 */
1361
	public function getStoragesBackendService() {
1362
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\BackendService');
1363
	}
1364
1365
	/**
1366
	 * Not a public API as of 8.2, wait for 9.0
1367
	 *
1368
	 * @return \OCA\Files_External\Service\GlobalStoragesService
1369
	 */
1370
	public function getGlobalStoragesService() {
1371
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1372
	}
1373
1374
	/**
1375
	 * Not a public API as of 8.2, wait for 9.0
1376
	 *
1377
	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1378
	 */
1379
	public function getUserGlobalStoragesService() {
1380
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1381
	}
1382
1383
	/**
1384
	 * Not a public API as of 8.2, wait for 9.0
1385
	 *
1386
	 * @return \OCA\Files_External\Service\UserStoragesService
1387
	 */
1388
	public function getUserStoragesService() {
1389
		return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserStoragesService');
1390
	}
1391
1392
	/**
1393
	 * @return \OCP\Share\IManager
1394
	 */
1395
	public function getShareManager() {
1396
		return $this->query('ShareManager');
1397
	}
1398
1399
}
1400