Server   F
last analyzed

Complexity

Total Complexity 135

Size/Duplication

Total Lines 2094
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 872
c 1
b 0
f 0
dl 0
loc 2094
rs 1.728
wmc 135

98 Methods

Rating   Name   Duplication   Size   Complexity  
A getCommentsManager() 0 2 1
A getOcsClient() 0 2 1
A getStoragesBackendService() 0 2 1
A getTempManager() 0 2 1
A getUserMountCache() 0 2 1
A getAppDataDir() 0 4 1
A getAppManager() 0 2 1
A getGlobalScaleConfig() 0 2 1
A getIniWrapper() 0 2 1
A registerDeprecatedAlias() 0 12 2
A getUserGlobalStoragesService() 0 2 1
A getLockingProvider() 0 2 1
A getGeneratorHelper() 0 2 1
A getCloudFederationFactory() 0 2 1
A getCapabilitiesManager() 0 2 1
A getNotificationManager() 0 2 1
A getCsrfTokenManager() 0 2 1
A getMountProviderCollection() 0 2 1
A getCloudFederationProviderManager() 0 2 1
A getShareManager() 0 2 1
A getRemoteInstanceFactory() 0 2 1
A getEventDispatcher() 0 2 1
A getQueryLogger() 0 2 1
A getSessionCryptoWrapper() 0 2 1
A getContentSecurityPolicyManager() 0 2 1
A getMimeTypeLoader() 0 2 1
A getDateTimeZone() 0 2 1
A getBruteForceThrottler() 0 2 1
A getMimeTypeDetector() 0 2 1
A getContentSecurityPolicyNonceManager() 0 2 1
A getMountManager() 0 2 1
A getGlobalStoragesService() 0 2 1
A getUserStoragesService() 0 2 1
A getIntegrityCodeChecker() 0 2 1
A getThemingDefaults() 0 2 1
A getDateTimeFormatter() 0 2 1
A getLDAPProvider() 0 2 1
A getWebRoot() 0 2 1
A getStorageFactory() 0 2 1
A getSettingsManager() 0 2 1
A getEventLogger() 0 2 1
A getMailer() 0 2 1
A getTrustedDomainHelper() 0 2 1
A getCloudIdManager() 0 2 1
A getLockdownManager() 0 2 1
A getCollaboratorSearch() 0 2 1
A getCommandBus() 0 2 1
A getAutoCompleteManager() 0 2 1
A getRemoteApiFactory() 0 2 1
A getGroupManager() 0 2 1
A getL10N() 0 2 1
A getEncryptionManager() 0 2 1
A getCalendarResourceBackendManager() 0 2 1
A getSession() 0 2 1
A getL10NFactory() 0 2 1
A getURLGenerator() 0 2 1
F __construct() 0 1180 35
A getUserSession() 0 2 1
A getNavigationManager() 0 2 1
A getHTTPClientService() 0 2 1
A getAppConfig() 0 2 1
A getEncryptionFilesHelper() 0 2 1
A getJobList() 0 2 1
A getTagManager() 0 2 1
A setSession() 0 4 1
A getEncryptionKeyStorage() 0 2 1
A getRequest() 0 2 1
A getTwoFactorAuthManager() 0 2 1
A getLazyRootFolder() 0 2 1
A getSystemTagObjectMapper() 0 2 1
A connectDispatcher() 0 7 1
A getSystemConfig() 0 2 1
A getCache() 0 2 1
A getCrypto() 0 2 1
A boot() 0 4 1
A getSystemTagManager() 0 2 1
A getLogFactory() 0 2 1
A getSecureRandom() 0 2 1
A getConfig() 0 2 1
A getUserFolder() 0 10 3
A getAppFetcher() 0 2 1
A getLogger() 0 2 1
A getActivityManager() 0 2 1
A getCredentialsManager() 0 2 1
A getRootFolder() 0 2 1
A getContactsManager() 0 2 1
A getCalendarManager() 0 2 1
A getRouter() 0 2 1
A getMemCacheFactory() 0 2 1
A getCalendarRoomBackendManager() 0 2 1
A getHasher() 0 2 1
A getCertificateManager() 0 2 1
A getUserManager() 0 2 1
A getGetRedisFactory() 0 2 1
A getSearch() 0 2 1
A getDatabaseConnection() 0 2 1
A getAvatarManager() 0 2 1
A getPreviewManager() 0 2 1

How to fix   Complexity   

Complex Class

Complex classes like Server often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Server, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 * @copyright Copyright (c) 2016, Lukas Reschke <[email protected]>
5
 *
6
 * @author Arne Hamann <[email protected]>
7
 * @author Arthur Schiwon <[email protected]>
8
 * @author Bart Visscher <[email protected]>
9
 * @author Bernhard Posselt <[email protected]>
10
 * @author Bernhard Reiter <[email protected]>
11
 * @author Bjoern Schiessle <[email protected]>
12
 * @author Björn Schießle <[email protected]>
13
 * @author Christopher Schäpers <[email protected]>
14
 * @author Christoph Wurst <[email protected]>
15
 * @author Damjan Georgievski <[email protected]>
16
 * @author Daniel Kesselberg <[email protected]>
17
 * @author Georg Ehrke <[email protected]>
18
 * @author Joas Schilling <[email protected]>
19
 * @author John Molakvoæ <[email protected]>
20
 * @author Jörn Friedrich Dreyer <[email protected]>
21
 * @author Julius Haertl <[email protected]>
22
 * @author Julius Härtl <[email protected]>
23
 * @author Lionel Elie Mamane <[email protected]>
24
 * @author Lukas Reschke <[email protected]>
25
 * @author Maxence Lange <[email protected]>
26
 * @author Michael Weimann <[email protected]>
27
 * @author Morris Jobke <[email protected]>
28
 * @author Piotr Mrówczyński <[email protected]>
29
 * @author Robin Appelman <[email protected]>
30
 * @author Robin McCorkell <[email protected]>
31
 * @author Roeland Jago Douma <[email protected]>
32
 * @author root <[email protected]>
33
 * @author Thomas Müller <[email protected]>
34
 * @author Thomas Tanghus <[email protected]>
35
 * @author Tobia De Koninck <[email protected]>
36
 * @author Vincent Petry <[email protected]>
37
 *
38
 * @license AGPL-3.0
39
 *
40
 * This code is free software: you can redistribute it and/or modify
41
 * it under the terms of the GNU Affero General Public License, version 3,
42
 * as published by the Free Software Foundation.
43
 *
44
 * This program is distributed in the hope that it will be useful,
45
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47
 * GNU Affero General Public License for more details.
48
 *
49
 * You should have received a copy of the GNU Affero General Public License, version 3,
50
 * along with this program. If not, see <http://www.gnu.org/licenses/>
51
 *
52
 */
53
namespace OC;
54
55
use bantu\IniGetWrapper\IniGetWrapper;
56
use OC\Accounts\AccountManager;
57
use OC\App\AppManager;
58
use OC\App\AppStore\Bundles\BundleFetcher;
59
use OC\App\AppStore\Fetcher\AppFetcher;
60
use OC\App\AppStore\Fetcher\CategoryFetcher;
61
use OC\AppFramework\Bootstrap\Coordinator;
62
use OC\AppFramework\Http\Request;
63
use OC\AppFramework\Http\RequestId;
64
use OC\AppFramework\Utility\TimeFactory;
65
use OC\Authentication\Events\LoginFailed;
66
use OC\Authentication\Listeners\LoginFailedListener;
67
use OC\Authentication\Listeners\UserLoggedInListener;
68
use OC\Authentication\LoginCredentials\Store;
69
use OC\Authentication\Token\IProvider;
70
use OC\Avatar\AvatarManager;
71
use OC\Collaboration\Collaborators\GroupPlugin;
72
use OC\Collaboration\Collaborators\MailPlugin;
73
use OC\Collaboration\Collaborators\RemoteGroupPlugin;
74
use OC\Collaboration\Collaborators\RemotePlugin;
75
use OC\Collaboration\Collaborators\UserPlugin;
76
use OC\Collaboration\Reference\ReferenceManager;
77
use OC\Command\CronBus;
78
use OC\Comments\ManagerFactory as CommentsManagerFactory;
79
use OC\Contacts\ContactsMenu\ActionFactory;
80
use OC\Contacts\ContactsMenu\ContactsStore;
81
use OC\DB\Connection;
82
use OC\DB\ConnectionAdapter;
83
use OC\Diagnostics\EventLogger;
84
use OC\Diagnostics\QueryLogger;
85
use OC\EventDispatcher\SymfonyAdapter;
86
use OC\Federation\CloudFederationFactory;
87
use OC\Federation\CloudFederationProviderManager;
88
use OC\Federation\CloudIdManager;
89
use OC\Files\Config\MountProviderCollection;
90
use OC\Files\Config\UserMountCache;
91
use OC\Files\Config\UserMountCacheListener;
92
use OC\Files\Lock\LockManager;
93
use OC\Files\Mount\CacheMountProvider;
94
use OC\Files\Mount\LocalHomeMountProvider;
95
use OC\Files\Mount\ObjectHomeMountProvider;
96
use OC\Files\Mount\ObjectStorePreviewCacheMountProvider;
97
use OC\Files\Mount\RootMountProvider;
98
use OC\Files\Node\HookConnector;
99
use OC\Files\Node\LazyRoot;
100
use OC\Files\Node\Root;
101
use OC\Files\SetupManager;
102
use OC\Files\Storage\StorageFactory;
103
use OC\Files\Template\TemplateManager;
104
use OC\Files\Type\Loader;
105
use OC\Files\View;
106
use OC\FullTextSearch\FullTextSearchManager;
107
use OC\Http\Client\ClientService;
108
use OC\Http\Client\NegativeDnsCache;
109
use OC\IntegrityCheck\Checker;
110
use OC\IntegrityCheck\Helpers\AppLocator;
111
use OC\IntegrityCheck\Helpers\EnvironmentHelper;
112
use OC\IntegrityCheck\Helpers\FileAccessHelper;
113
use OC\LDAP\NullLDAPProviderFactory;
114
use OC\KnownUser\KnownUserService;
115
use OC\Lock\DBLockingProvider;
116
use OC\Lock\MemcacheLockingProvider;
117
use OC\Lock\NoopLockingProvider;
118
use OC\Lockdown\LockdownManager;
119
use OC\Log\LogFactory;
120
use OC\Log\PsrLoggerAdapter;
121
use OC\Mail\Mailer;
122
use OC\Memcache\ArrayCache;
123
use OC\Memcache\Factory;
124
use OC\Metadata\Capabilities as MetadataCapabilities;
125
use OC\Metadata\IMetadataManager;
126
use OC\Metadata\MetadataManager;
127
use OC\Notification\Manager;
128
use OC\OCS\DiscoveryService;
129
use OC\Preview\GeneratorHelper;
130
use OC\Preview\IMagickSupport;
131
use OC\Remote\Api\ApiFactory;
132
use OC\Remote\InstanceFactory;
133
use OC\RichObjectStrings\Validator;
134
use OC\Route\CachingRouter;
135
use OC\Route\Router;
136
use OC\Security\Bruteforce\Throttler;
137
use OC\Security\CertificateManager;
138
use OC\Security\CredentialsManager;
139
use OC\Security\Crypto;
140
use OC\Security\CSP\ContentSecurityPolicyManager;
141
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
142
use OC\Security\CSRF\CsrfTokenManager;
143
use OC\Security\CSRF\TokenStorage\SessionStorage;
144
use OC\Security\Hasher;
145
use OC\Security\SecureRandom;
146
use OC\Security\TrustedDomainHelper;
147
use OC\Security\VerificationToken\VerificationToken;
148
use OC\Session\CryptoWrapper;
149
use OC\Share20\ProviderFactory;
150
use OC\Share20\ShareHelper;
151
use OC\SpeechToText\SpeechToTextManager;
152
use OC\SystemTag\ManagerFactory as SystemTagManagerFactory;
153
use OC\Tagging\TagMapper;
154
use OC\Talk\Broker;
155
use OC\Template\JSCombiner;
156
use OC\Translation\TranslationManager;
157
use OC\User\DisplayNameCache;
158
use OC\User\Listeners\BeforeUserDeletedListener;
159
use OC\User\Listeners\UserChangedListener;
160
use OC\User\Session;
161
use OCA\Theming\ImageManager;
162
use OCA\Theming\ThemingDefaults;
163
use OCA\Theming\Util;
164
use OCP\Accounts\IAccountManager;
165
use OCP\App\IAppManager;
166
use OCP\Authentication\LoginCredentials\IStore;
167
use OCP\Authentication\Token\IProvider as OCPIProvider;
168
use OCP\BackgroundJob\IJobList;
169
use OCP\Collaboration\AutoComplete\IManager;
170
use OCP\Collaboration\Reference\IReferenceManager;
171
use OCP\Command\IBus;
172
use OCP\Comments\ICommentsManager;
173
use OCP\Contacts\ContactsMenu\IActionFactory;
174
use OCP\Contacts\ContactsMenu\IContactsStore;
175
use OCP\Defaults;
176
use OCP\Diagnostics\IEventLogger;
177
use OCP\Diagnostics\IQueryLogger;
178
use OCP\Encryption\IFile;
179
use OCP\Encryption\Keys\IStorage;
180
use OCP\EventDispatcher\IEventDispatcher;
181
use OCP\Federation\ICloudFederationFactory;
182
use OCP\Federation\ICloudFederationProviderManager;
183
use OCP\Federation\ICloudIdManager;
184
use OCP\Files\Config\IMountProviderCollection;
185
use OCP\Files\Config\IUserMountCache;
186
use OCP\Files\IMimeTypeDetector;
187
use OCP\Files\IMimeTypeLoader;
188
use OCP\Files\IRootFolder;
189
use OCP\Files\Lock\ILockManager;
190
use OCP\Files\Mount\IMountManager;
191
use OCP\Files\Storage\IStorageFactory;
192
use OCP\Files\Template\ITemplateManager;
193
use OCP\FullTextSearch\IFullTextSearchManager;
194
use OCP\GlobalScale\IConfig;
195
use OCP\Group\Events\BeforeGroupCreatedEvent;
196
use OCP\Group\Events\BeforeGroupDeletedEvent;
197
use OCP\Group\Events\BeforeUserAddedEvent;
198
use OCP\Group\Events\BeforeUserRemovedEvent;
199
use OCP\Group\Events\GroupCreatedEvent;
200
use OCP\Group\Events\GroupDeletedEvent;
201
use OCP\Group\Events\UserAddedEvent;
202
use OCP\Group\Events\UserRemovedEvent;
203
use OCP\Group\ISubAdmin;
204
use OCP\Http\Client\IClientService;
205
use OCP\IAppConfig;
206
use OCP\IAvatarManager;
207
use OCP\ICache;
208
use OCP\ICacheFactory;
209
use OCP\ICertificateManager;
210
use OCP\IBinaryFinder;
211
use OCP\IDateTimeFormatter;
212
use OCP\IDateTimeZone;
213
use OCP\IDBConnection;
214
use OCP\IEventSourceFactory;
215
use OCP\IGroupManager;
216
use OCP\IInitialStateService;
217
use OCP\IL10N;
218
use OCP\ILogger;
219
use OCP\INavigationManager;
220
use OCP\IPreview;
221
use OCP\IRequest;
222
use OCP\IRequestId;
223
use OCP\ISearch;
224
use OCP\IServerContainer;
225
use OCP\ISession;
226
use OCP\ITagManager;
227
use OCP\ITempManager;
228
use OCP\IURLGenerator;
229
use OCP\IUserManager;
230
use OCP\IUserSession;
231
use OCP\L10N\IFactory;
232
use OCP\LDAP\ILDAPProvider;
233
use OCP\LDAP\ILDAPProviderFactory;
234
use OCP\Lock\ILockingProvider;
235
use OCP\Lockdown\ILockdownManager;
236
use OCP\Log\ILogFactory;
237
use OCP\Mail\IMailer;
238
use OCP\Remote\Api\IApiFactory;
239
use OCP\Remote\IInstanceFactory;
240
use OCP\RichObjectStrings\IValidator;
241
use OCP\Route\IRouter;
242
use OCP\Security\Bruteforce\IThrottler;
243
use OCP\Security\IContentSecurityPolicyManager;
244
use OCP\Security\ICredentialsManager;
245
use OCP\Security\ICrypto;
246
use OCP\Security\IHasher;
247
use OCP\Security\ISecureRandom;
248
use OCP\Security\ITrustedDomainHelper;
249
use OCP\Security\VerificationToken\IVerificationToken;
250
use OCP\Share\IShareHelper;
251
use OCP\SpeechToText\ISpeechToTextManager;
252
use OCP\SystemTag\ISystemTagManager;
253
use OCP\SystemTag\ISystemTagObjectMapper;
254
use OCP\Talk\IBroker;
255
use OCP\Translation\ITranslationManager;
256
use OCP\User\Events\BeforePasswordUpdatedEvent;
257
use OCP\User\Events\BeforeUserDeletedEvent;
258
use OCP\User\Events\BeforeUserLoggedInEvent;
259
use OCP\User\Events\BeforeUserLoggedInWithCookieEvent;
260
use OCP\User\Events\BeforeUserLoggedOutEvent;
261
use OCP\User\Events\PasswordUpdatedEvent;
262
use OCP\User\Events\PostLoginEvent;
263
use OCP\User\Events\UserChangedEvent;
264
use OCP\User\Events\UserLoggedInEvent;
265
use OCP\User\Events\UserLoggedInWithCookieEvent;
266
use OCP\User\Events\UserLoggedOutEvent;
267
use Psr\Container\ContainerExceptionInterface;
268
use Psr\Container\ContainerInterface;
269
use Psr\Log\LoggerInterface;
270
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
271
use Symfony\Component\EventDispatcher\GenericEvent;
272
use OCA\Files_External\Service\UserStoragesService;
273
use OCA\Files_External\Service\UserGlobalStoragesService;
274
use OCA\Files_External\Service\GlobalStoragesService;
275
use OCA\Files_External\Service\BackendService;
276
use OCP\Profiler\IProfiler;
277
use OC\Profiler\Profiler;
278
279
/**
280
 * Class Server
281
 *
282
 * @package OC
283
 *
284
 * TODO: hookup all manager classes
285
 */
286
class Server extends ServerContainer implements IServerContainer {
0 ignored issues
show
Deprecated Code introduced by
The interface OCP\IServerContainer has been deprecated: 20.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

286
class Server extends ServerContainer implements /** @scrutinizer ignore-deprecated */ IServerContainer {

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

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

Loading history...
287
	/** @var string */
288
	private $webRoot;
289
290
	/**
291
	 * @param string $webRoot
292
	 * @param \OC\Config $config
293
	 */
294
	public function __construct($webRoot, \OC\Config $config) {
295
		parent::__construct();
296
		$this->webRoot = $webRoot;
297
298
		// To find out if we are running from CLI or not
299
		$this->registerParameter('isCLI', \OC::$CLI);
300
		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
301
302
		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
303
			return $c;
304
		});
305
		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
306
			return $c;
307
		});
308
309
		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
310
		/** @deprecated 19.0.0 */
311
		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
312
313
		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
314
		/** @deprecated 19.0.0 */
315
		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
316
317
		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
318
		/** @deprecated 19.0.0 */
319
		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
320
321
		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
322
		/** @deprecated 19.0.0 */
323
		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
324
325
		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
326
		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
327
328
		$this->registerAlias(IActionFactory::class, ActionFactory::class);
329
330
		$this->registerService(View::class, function (Server $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

330
		$this->registerService(View::class, function (/** @scrutinizer ignore-unused */ Server $c) {

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

Loading history...
331
			return new View();
332
		}, false);
333
334
		$this->registerService(IPreview::class, function (ContainerInterface $c) {
335
			return new PreviewManager(
336
				$c->get(\OCP\IConfig::class),
337
				$c->get(IRootFolder::class),
338
				new \OC\Preview\Storage\Root(
339
					$c->get(IRootFolder::class),
340
					$c->get(SystemConfig::class)
341
				),
342
				$c->get(IEventDispatcher::class),
343
				$c->get(SymfonyAdapter::class),
344
				$c->get(GeneratorHelper::class),
345
				$c->get(ISession::class)->get('user_id'),
346
				$c->get(Coordinator::class),
347
				$c->get(IServerContainer::class),
348
				$c->get(IBinaryFinder::class),
349
				$c->get(IMagickSupport::class)
350
			);
351
		});
352
		/** @deprecated 19.0.0 */
353
		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
354
355
		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
356
			return new \OC\Preview\Watcher(
357
				new \OC\Preview\Storage\Root(
358
					$c->get(IRootFolder::class),
359
					$c->get(SystemConfig::class)
360
				)
361
			);
362
		});
363
364
		$this->registerService(IProfiler::class, function (Server $c) {
365
			return new Profiler($c->get(SystemConfig::class));
366
		});
367
368
		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
369
			$view = new View();
370
			$util = new Encryption\Util(
371
				$view,
372
				$c->get(IUserManager::class),
373
				$c->get(IGroupManager::class),
374
				$c->get(\OCP\IConfig::class)
375
			);
376
			return new Encryption\Manager(
377
				$c->get(\OCP\IConfig::class),
378
				$c->get(LoggerInterface::class),
379
				$c->getL10N('core'),
380
				new View(),
381
				$util,
382
				new ArrayCache()
383
			);
384
		});
385
		/** @deprecated 19.0.0 */
386
		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
387
388
		/** @deprecated 21.0.0 */
389
		$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
390
		$this->registerService(IFile::class, function (ContainerInterface $c) {
391
			$util = new Encryption\Util(
392
				new View(),
393
				$c->get(IUserManager::class),
394
				$c->get(IGroupManager::class),
395
				$c->get(\OCP\IConfig::class)
396
			);
397
			return new Encryption\File(
398
				$util,
399
				$c->get(IRootFolder::class),
400
				$c->get(\OCP\Share\IManager::class)
401
			);
402
		});
403
404
		/** @deprecated 21.0.0 */
405
		$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
406
		$this->registerService(IStorage::class, function (ContainerInterface $c) {
407
			$view = new View();
408
			$util = new Encryption\Util(
409
				$view,
410
				$c->get(IUserManager::class),
411
				$c->get(IGroupManager::class),
412
				$c->get(\OCP\IConfig::class)
413
			);
414
415
			return new Encryption\Keys\Storage(
416
				$view,
417
				$util,
418
				$c->get(ICrypto::class),
419
				$c->get(\OCP\IConfig::class)
420
			);
421
		});
422
		/** @deprecated 20.0.0 */
423
		$this->registerDeprecatedAlias('TagMapper', TagMapper::class);
424
425
		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
426
		/** @deprecated 19.0.0 */
427
		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
428
429
		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
430
			/** @var \OCP\IConfig $config */
431
			$config = $c->get(\OCP\IConfig::class);
432
			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
433
			return new $factoryClass($this);
434
		});
435
		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
436
			return $c->get('SystemTagManagerFactory')->getManager();
437
		});
438
		/** @deprecated 19.0.0 */
439
		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
440
441
		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
442
			return $c->get('SystemTagManagerFactory')->getObjectMapper();
443
		});
444
		$this->registerService('RootFolder', function (ContainerInterface $c) {
445
			$manager = \OC\Files\Filesystem::getMountManager();
446
			$view = new View();
447
			$root = new Root(
448
				$manager,
449
				$view,
450
				null,
451
				$c->get(IUserMountCache::class),
452
				$this->get(LoggerInterface::class),
453
				$this->get(IUserManager::class),
454
				$this->get(IEventDispatcher::class),
455
			);
456
457
			$previewConnector = new \OC\Preview\WatcherConnector(
458
				$root,
459
				$c->get(SystemConfig::class)
460
			);
461
			$previewConnector->connectWatcher();
462
463
			return $root;
464
		});
465
		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
466
			return new HookConnector(
467
				$c->get(IRootFolder::class),
468
				new View(),
469
				$c->get(\OC\EventDispatcher\SymfonyAdapter::class),
470
				$c->get(IEventDispatcher::class)
471
			);
472
		});
473
474
		/** @deprecated 19.0.0 */
475
		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
476
477
		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
478
			return new LazyRoot(function () use ($c) {
479
				return $c->get('RootFolder');
480
			});
481
		});
482
		/** @deprecated 19.0.0 */
483
		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
484
485
		/** @deprecated 19.0.0 */
486
		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
487
		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
488
489
		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
490
			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
491
		});
492
493
		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
494
			$groupManager = new \OC\Group\Manager(
495
				$this->get(IUserManager::class),
496
				$c->get(SymfonyAdapter::class),
497
				$this->get(LoggerInterface::class),
498
				$this->get(ICacheFactory::class)
499
			);
500
			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
501
				/** @var IEventDispatcher $dispatcher */
502
				$dispatcher = $this->get(IEventDispatcher::class);
503
				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
504
			});
505
			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
506
				/** @var IEventDispatcher $dispatcher */
507
				$dispatcher = $this->get(IEventDispatcher::class);
508
				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
509
			});
510
			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
511
				/** @var IEventDispatcher $dispatcher */
512
				$dispatcher = $this->get(IEventDispatcher::class);
513
				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
514
			});
515
			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
516
				/** @var IEventDispatcher $dispatcher */
517
				$dispatcher = $this->get(IEventDispatcher::class);
518
				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
519
			});
520
			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
521
				/** @var IEventDispatcher $dispatcher */
522
				$dispatcher = $this->get(IEventDispatcher::class);
523
				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
524
			});
525
			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
526
				/** @var IEventDispatcher $dispatcher */
527
				$dispatcher = $this->get(IEventDispatcher::class);
528
				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
529
			});
530
			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
531
				/** @var IEventDispatcher $dispatcher */
532
				$dispatcher = $this->get(IEventDispatcher::class);
533
				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
0 ignored issues
show
Deprecated Code introduced by
The class OCP\Group\Events\BeforeUserRemovedEvent has been deprecated: 20.0.0 - it can't be guaranteed that this event is triggered in all case (e.g. for LDAP users this isn't possible) - if there is a valid use case please reach out in the issue tracker at https://github.com/nextcloud/server/issues ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

533
				$dispatcher->dispatchTyped(/** @scrutinizer ignore-deprecated */ new BeforeUserRemovedEvent($group, $user));
Loading history...
534
			});
535
			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
536
				/** @var IEventDispatcher $dispatcher */
537
				$dispatcher = $this->get(IEventDispatcher::class);
538
				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
539
			});
540
			return $groupManager;
541
		});
542
		/** @deprecated 19.0.0 */
543
		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
544
545
		$this->registerService(Store::class, function (ContainerInterface $c) {
546
			$session = $c->get(ISession::class);
547
			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
548
				$tokenProvider = $c->get(IProvider::class);
549
			} else {
550
				$tokenProvider = null;
551
			}
552
			$logger = $c->get(LoggerInterface::class);
553
			return new Store($session, $logger, $tokenProvider);
554
		});
555
		$this->registerAlias(IStore::class, Store::class);
556
		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
557
		$this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
558
559
		$this->registerService(\OC\User\Session::class, function (Server $c) {
560
			$manager = $c->get(IUserManager::class);
561
			$session = new \OC\Session\Memory('');
562
			$timeFactory = new TimeFactory();
563
			// Token providers might require a working database. This code
564
			// might however be called when Nextcloud is not yet setup.
565
			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
566
				$provider = $c->get(IProvider::class);
567
			} else {
568
				$provider = null;
569
			}
570
571
			$legacyDispatcher = $c->get(SymfonyAdapter::class);
572
573
			$userSession = new \OC\User\Session(
574
				$manager,
575
				$session,
576
				$timeFactory,
577
				$provider,
578
				$c->get(\OCP\IConfig::class),
579
				$c->get(ISecureRandom::class),
580
				$c->getLockdownManager(),
581
				$c->get(LoggerInterface::class),
582
				$c->get(IEventDispatcher::class)
583
			);
584
			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
585
			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
586
				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
587
			});
588
			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
589
			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
590
				/** @var \OC\User\User $user */
591
				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
592
			});
593
			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
594
			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
595
				/** @var \OC\User\User $user */
596
				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
597
				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
598
			});
599
			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
600
			$userSession->listen('\OC\User', 'postDelete', function ($user) {
601
				/** @var \OC\User\User $user */
602
				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
603
			});
604
			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
605
				/** @var \OC\User\User $user */
606
				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
607
608
				/** @var IEventDispatcher $dispatcher */
609
				$dispatcher = $this->get(IEventDispatcher::class);
610
				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
611
			});
612
			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
613
				/** @var \OC\User\User $user */
614
				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
615
616
				/** @var IEventDispatcher $dispatcher */
617
				$dispatcher = $this->get(IEventDispatcher::class);
618
				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
619
			});
620
			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
621
				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
622
623
				/** @var IEventDispatcher $dispatcher */
624
				$dispatcher = $this->get(IEventDispatcher::class);
625
				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
626
			});
627
			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
628
				/** @var \OC\User\User $user */
629
				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
630
631
				/** @var IEventDispatcher $dispatcher */
632
				$dispatcher = $this->get(IEventDispatcher::class);
633
				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
634
			});
635
			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
636
				/** @var IEventDispatcher $dispatcher */
637
				$dispatcher = $this->get(IEventDispatcher::class);
638
				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
639
			});
640
			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
641
				/** @var \OC\User\User $user */
642
				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
643
644
				/** @var IEventDispatcher $dispatcher */
645
				$dispatcher = $this->get(IEventDispatcher::class);
646
				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
647
			});
648
			$userSession->listen('\OC\User', 'logout', function ($user) {
649
				\OC_Hook::emit('OC_User', 'logout', []);
650
651
				/** @var IEventDispatcher $dispatcher */
652
				$dispatcher = $this->get(IEventDispatcher::class);
653
				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
654
			});
655
			$userSession->listen('\OC\User', 'postLogout', function ($user) {
656
				/** @var IEventDispatcher $dispatcher */
657
				$dispatcher = $this->get(IEventDispatcher::class);
658
				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
659
			});
660
			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
661
				/** @var \OC\User\User $user */
662
				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
663
664
				/** @var IEventDispatcher $dispatcher */
665
				$dispatcher = $this->get(IEventDispatcher::class);
666
				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
667
			});
668
			return $userSession;
669
		});
670
		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
671
		/** @deprecated 19.0.0 */
672
		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
673
674
		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
675
676
		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
677
		/** @deprecated 19.0.0 */
678
		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
679
680
		/** @deprecated 19.0.0 */
681
		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
682
		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
683
684
		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

684
		$this->registerService(\OC\SystemConfig::class, function (/** @scrutinizer ignore-unused */ $c) use ($config) {

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

Loading history...
685
			return new \OC\SystemConfig($config);
686
		});
687
		/** @deprecated 19.0.0 */
688
		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
689
690
		/** @deprecated 19.0.0 */
691
		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
692
		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
693
694
		$this->registerService(IFactory::class, function (Server $c) {
695
			return new \OC\L10N\Factory(
696
				$c->get(\OCP\IConfig::class),
697
				$c->getRequest(),
698
				$c->get(IUserSession::class),
699
				$c->get(ICacheFactory::class),
700
				\OC::$SERVERROOT
701
			);
702
		});
703
		/** @deprecated 19.0.0 */
704
		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
705
706
		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
707
		/** @deprecated 19.0.0 */
708
		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
709
710
		/** @deprecated 19.0.0 */
711
		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
712
		/** @deprecated 19.0.0 */
713
		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
714
715
		$this->registerService(ICache::class, function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

715
		$this->registerService(ICache::class, function (/** @scrutinizer ignore-unused */ $c) {

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

Loading history...
716
			return new Cache\File();
717
		});
718
		/** @deprecated 19.0.0 */
719
		$this->registerDeprecatedAlias('UserCache', ICache::class);
720
721
		$this->registerService(Factory::class, function (Server $c) {
722
			$profiler = $c->get(IProfiler::class);
723
			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
724
				$profiler,
725
				ArrayCache::class,
726
				ArrayCache::class,
727
				ArrayCache::class
728
			);
729
			/** @var \OCP\IConfig $config */
730
			$config = $c->get(\OCP\IConfig::class);
731
732
			if ($config->getSystemValueBool('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
0 ignored issues
show
Bug introduced by
The constant OC\PHPUNIT_RUN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
733
				if (!$config->getSystemValueBool('log_query')) {
734
					try {
735
						$v = \OC_App::getAppVersions();
736
					} catch (\Doctrine\DBAL\Exception $e) {
737
						// Database service probably unavailable
738
						// Probably related to https://github.com/nextcloud/server/issues/37424
739
						return $arrayCacheFactory;
740
					}
741
				} else {
742
					// If the log_query is enabled, we can not get the app versions
743
					// as that does a query, which will be logged and the logging
744
					// depends on redis and here we are back again in the same function.
745
					$v = [
746
						'log_query' => 'enabled',
747
					];
748
				}
749
				$v['core'] = implode(',', \OC_Util::getVersion());
750
				$version = implode(',', $v);
751
				$instanceId = \OC_Util::getInstanceId();
752
				$path = \OC::$SERVERROOT;
753
				$prefix = md5($instanceId . '-' . $version . '-' . $path);
754
				return new \OC\Memcache\Factory($prefix,
755
					$c->get(LoggerInterface::class),
756
					$profiler,
757
					$config->getSystemValue('memcache.local', null),
758
					$config->getSystemValue('memcache.distributed', null),
759
					$config->getSystemValue('memcache.locking', null),
760
					$config->getSystemValueString('redis_log_file')
761
				);
762
			}
763
			return $arrayCacheFactory;
764
		});
765
		/** @deprecated 19.0.0 */
766
		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
767
		$this->registerAlias(ICacheFactory::class, Factory::class);
768
769
		$this->registerService('RedisFactory', function (Server $c) {
770
			$systemConfig = $c->get(SystemConfig::class);
771
			return new RedisFactory($systemConfig, $c->getEventLogger());
772
		});
773
774
		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
775
			$l10n = $this->get(IFactory::class)->get('lib');
776
			return new \OC\Activity\Manager(
777
				$c->getRequest(),
778
				$c->get(IUserSession::class),
779
				$c->get(\OCP\IConfig::class),
780
				$c->get(IValidator::class),
781
				$l10n
782
			);
783
		});
784
		/** @deprecated 19.0.0 */
785
		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
786
787
		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
788
			return new \OC\Activity\EventMerger(
789
				$c->getL10N('lib')
790
			);
791
		});
792
		$this->registerAlias(IValidator::class, Validator::class);
793
794
		$this->registerService(AvatarManager::class, function (Server $c) {
795
			return new AvatarManager(
796
				$c->get(IUserSession::class),
797
				$c->get(\OC\User\Manager::class),
798
				$c->getAppDataDir('avatar'),
799
				$c->getL10N('lib'),
800
				$c->get(LoggerInterface::class),
801
				$c->get(\OCP\IConfig::class),
802
				$c->get(IAccountManager::class),
803
				$c->get(KnownUserService::class)
804
			);
805
		});
806
807
		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
808
		/** @deprecated 19.0.0 */
809
		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
810
811
		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
812
		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
813
		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
814
815
		$this->registerService(\OC\Log::class, function (Server $c) {
816
			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
817
			$factory = new LogFactory($c, $this->get(SystemConfig::class));
818
			$logger = $factory->get($logType);
819
			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
820
821
			return new Log($logger, $this->get(SystemConfig::class), null, $registry);
822
		});
823
		$this->registerAlias(ILogger::class, \OC\Log::class);
824
		/** @deprecated 19.0.0 */
825
		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
826
		// PSR-3 logger
827
		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
828
829
		$this->registerService(ILogFactory::class, function (Server $c) {
830
			return new LogFactory($c, $this->get(SystemConfig::class));
831
		});
832
833
		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
834
		/** @deprecated 19.0.0 */
835
		$this->registerDeprecatedAlias('JobList', IJobList::class);
836
837
		$this->registerService(Router::class, function (Server $c) {
838
			$cacheFactory = $c->get(ICacheFactory::class);
839
			if ($cacheFactory->isLocalCacheAvailable()) {
840
				$router = $c->resolve(CachingRouter::class);
841
			} else {
842
				$router = $c->resolve(Router::class);
843
			}
844
			return $router;
845
		});
846
		$this->registerAlias(IRouter::class, Router::class);
847
		/** @deprecated 19.0.0 */
848
		$this->registerDeprecatedAlias('Router', IRouter::class);
849
850
		$this->registerAlias(ISearch::class, Search::class);
851
		/** @deprecated 19.0.0 */
852
		$this->registerDeprecatedAlias('Search', ISearch::class);
853
854
		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
855
			$cacheFactory = $c->get(ICacheFactory::class);
856
			if ($cacheFactory->isAvailable()) {
857
				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
858
					$c->get(AllConfig::class),
859
					$this->get(ICacheFactory::class),
860
					new \OC\AppFramework\Utility\TimeFactory()
861
				);
862
			} else {
863
				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
864
					$c->get(AllConfig::class),
865
					$c->get(IDBConnection::class),
866
					new \OC\AppFramework\Utility\TimeFactory()
867
				);
868
			}
869
870
			return $backend;
871
		});
872
873
		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
874
		/** @deprecated 19.0.0 */
875
		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
876
		$this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
877
		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
878
879
		$this->registerAlias(ICrypto::class, Crypto::class);
880
		/** @deprecated 19.0.0 */
881
		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
882
883
		$this->registerAlias(IHasher::class, Hasher::class);
884
		/** @deprecated 19.0.0 */
885
		$this->registerDeprecatedAlias('Hasher', IHasher::class);
886
887
		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
888
		/** @deprecated 19.0.0 */
889
		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
890
891
		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
892
		$this->registerService(Connection::class, function (Server $c) {
893
			$systemConfig = $c->get(SystemConfig::class);
894
			$factory = new \OC\DB\ConnectionFactory($systemConfig);
895
			$type = $systemConfig->getValue('dbtype', 'sqlite');
896
			if (!$factory->isValidType($type)) {
897
				throw new \OC\DatabaseException('Invalid database type');
898
			}
899
			$connectionParams = $factory->createConnectionParams();
900
			$connection = $factory->getConnection($type, $connectionParams);
901
			return $connection;
902
		});
903
		/** @deprecated 19.0.0 */
904
		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
905
906
		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
907
		$this->registerAlias(IClientService::class, ClientService::class);
908
		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
909
			return new NegativeDnsCache(
910
				$c->get(ICacheFactory::class),
911
			);
912
		});
913
		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
914
		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
915
			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
916
		});
917
		/** @deprecated 19.0.0 */
918
		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
919
920
		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
921
			$queryLogger = new QueryLogger();
922
			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
923
				// In debug mode, module is being activated by default
924
				$queryLogger->activate();
925
			}
926
			return $queryLogger;
927
		});
928
		/** @deprecated 19.0.0 */
929
		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
930
931
		/** @deprecated 19.0.0 */
932
		$this->registerDeprecatedAlias('TempManager', TempManager::class);
933
		$this->registerAlias(ITempManager::class, TempManager::class);
934
935
		$this->registerService(AppManager::class, function (ContainerInterface $c) {
936
			// TODO: use auto-wiring
937
			return new \OC\App\AppManager(
938
				$c->get(IUserSession::class),
939
				$c->get(\OCP\IConfig::class),
940
				$c->get(\OC\AppConfig::class),
941
				$c->get(IGroupManager::class),
942
				$c->get(ICacheFactory::class),
943
				$c->get(SymfonyAdapter::class),
944
				$c->get(IEventDispatcher::class),
945
				$c->get(LoggerInterface::class)
946
			);
947
		});
948
		/** @deprecated 19.0.0 */
949
		$this->registerDeprecatedAlias('AppManager', AppManager::class);
950
		$this->registerAlias(IAppManager::class, AppManager::class);
951
952
		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
953
		/** @deprecated 19.0.0 */
954
		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
955
956
		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
957
			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
958
959
			return new DateTimeFormatter(
960
				$c->get(IDateTimeZone::class)->getTimeZone(),
961
				$c->getL10N('lib', $language)
962
			);
963
		});
964
		/** @deprecated 19.0.0 */
965
		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
966
967
		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
968
			$mountCache = $c->get(UserMountCache::class);
969
			$listener = new UserMountCacheListener($mountCache);
970
			$listener->listen($c->get(IUserManager::class));
971
			return $mountCache;
972
		});
973
		/** @deprecated 19.0.0 */
974
		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
975
976
		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
977
			$loader = $c->get(IStorageFactory::class);
978
			$mountCache = $c->get(IUserMountCache::class);
979
			$eventLogger = $c->get(IEventLogger::class);
980
			$manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
981
982
			// builtin providers
983
984
			$config = $c->get(\OCP\IConfig::class);
985
			$logger = $c->get(LoggerInterface::class);
986
			$manager->registerProvider(new CacheMountProvider($config));
987
			$manager->registerHomeProvider(new LocalHomeMountProvider());
988
			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
989
			$manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
990
			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
991
992
			return $manager;
993
		});
994
		/** @deprecated 19.0.0 */
995
		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
996
997
		/** @deprecated 20.0.0 */
998
		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
999
		$this->registerService(IBus::class, function (ContainerInterface $c) {
1000
			$busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
1001
			if ($busClass) {
1002
				[$app, $class] = explode('::', $busClass, 2);
1003
				if ($c->get(IAppManager::class)->isInstalled($app)) {
1004
					\OC_App::loadApp($app);
1005
					return $c->get($class);
1006
				} else {
1007
					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
1008
				}
1009
			} else {
1010
				$jobList = $c->get(IJobList::class);
1011
				return new CronBus($jobList);
1012
			}
1013
		});
1014
		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
1015
		/** @deprecated 20.0.0 */
1016
		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1017
		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1018
		/** @deprecated 19.0.0 */
1019
		$this->registerDeprecatedAlias('Throttler', Throttler::class);
1020
		$this->registerAlias(IThrottler::class, Throttler::class);
1021
		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1022
			// IConfig and IAppManager requires a working database. This code
1023
			// might however be called when ownCloud is not yet setup.
1024
			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1025
				$config = $c->get(\OCP\IConfig::class);
1026
				$appManager = $c->get(IAppManager::class);
1027
			} else {
1028
				$config = null;
1029
				$appManager = null;
1030
			}
1031
1032
			return new Checker(
1033
				new EnvironmentHelper(),
1034
				new FileAccessHelper(),
1035
				new AppLocator(),
1036
				$config,
1037
				$c->get(ICacheFactory::class),
1038
				$appManager,
1039
				$c->get(IMimeTypeDetector::class)
1040
			);
1041
		});
1042
		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1042
		$this->registerService(\OCP\IRequest::class, function (/** @scrutinizer ignore-unused */ ContainerInterface $c) {

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

Loading history...
1043
			if (isset($this['urlParams'])) {
1044
				$urlParams = $this['urlParams'];
1045
			} else {
1046
				$urlParams = [];
1047
			}
1048
1049
			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
0 ignored issues
show
Bug introduced by
The constant OC\PHPUNIT_RUN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1050
				&& in_array('fakeinput', stream_get_wrappers())
1051
			) {
1052
				$stream = 'fakeinput://data';
1053
			} else {
1054
				$stream = 'php://input';
1055
			}
1056
1057
			return new Request(
1058
				[
1059
					'get' => $_GET,
1060
					'post' => $_POST,
1061
					'files' => $_FILES,
1062
					'server' => $_SERVER,
1063
					'env' => $_ENV,
1064
					'cookies' => $_COOKIE,
1065
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1066
						? $_SERVER['REQUEST_METHOD']
1067
						: '',
1068
					'urlParams' => $urlParams,
1069
				],
1070
				$this->get(IRequestId::class),
1071
				$this->get(\OCP\IConfig::class),
1072
				$this->get(CsrfTokenManager::class),
1073
				$stream
1074
			);
1075
		});
1076
		/** @deprecated 19.0.0 */
1077
		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1078
1079
		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1079
		$this->registerService(IRequestId::class, function (/** @scrutinizer ignore-unused */ ContainerInterface $c): IRequestId {

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

Loading history...
1080
			return new RequestId(
1081
				$_SERVER['UNIQUE_ID'] ?? '',
1082
				$this->get(ISecureRandom::class)
1083
			);
1084
		});
1085
1086
		$this->registerService(IMailer::class, function (Server $c) {
1087
			return new Mailer(
1088
				$c->get(\OCP\IConfig::class),
1089
				$c->get(LoggerInterface::class),
1090
				$c->get(Defaults::class),
1091
				$c->get(IURLGenerator::class),
1092
				$c->getL10N('lib'),
1093
				$c->get(IEventDispatcher::class),
1094
				$c->get(IFactory::class)
1095
			);
1096
		});
1097
		/** @deprecated 19.0.0 */
1098
		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1099
1100
		/** @deprecated 21.0.0 */
1101
		$this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1102
1103
		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1104
			$config = $c->get(\OCP\IConfig::class);
1105
			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1106
			if (is_null($factoryClass) || !class_exists($factoryClass)) {
1107
				return new NullLDAPProviderFactory($this);
1108
			}
1109
			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1110
			return new $factoryClass($this);
1111
		});
1112
		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1113
			$factory = $c->get(ILDAPProviderFactory::class);
1114
			return $factory->getLDAPProvider();
1115
		});
1116
		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1117
			$ini = $c->get(IniGetWrapper::class);
1118
			$config = $c->get(\OCP\IConfig::class);
1119
			$ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1120
			if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
0 ignored issues
show
Bug introduced by
The constant OC\PHPUNIT_RUN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
1121
				/** @var \OC\Memcache\Factory $memcacheFactory */
1122
				$memcacheFactory = $c->get(ICacheFactory::class);
1123
				$memcache = $memcacheFactory->createLocking('lock');
1124
				if (!($memcache instanceof \OC\Memcache\NullCache)) {
0 ignored issues
show
introduced by
$memcache is never a sub-type of OC\Memcache\NullCache.
Loading history...
1125
					return new MemcacheLockingProvider($memcache, $ttl);
1126
				}
1127
				return new DBLockingProvider(
1128
					$c->get(IDBConnection::class),
1129
					new TimeFactory(),
1130
					$ttl,
1131
					!\OC::$CLI
1132
				);
1133
			}
1134
			return new NoopLockingProvider();
1135
		});
1136
		/** @deprecated 19.0.0 */
1137
		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1138
1139
		$this->registerService(ILockManager::class, function (Server $c): LockManager {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1139
		$this->registerService(ILockManager::class, function (/** @scrutinizer ignore-unused */ Server $c): LockManager {

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

Loading history...
1140
			return new LockManager();
1141
		});
1142
1143
		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
1144
		$this->registerService(SetupManager::class, function ($c) {
1145
			// create the setupmanager through the mount manager to resolve the cyclic dependency
1146
			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1147
		});
1148
		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1149
		/** @deprecated 19.0.0 */
1150
		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1151
1152
		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1153
			return new \OC\Files\Type\Detection(
1154
				$c->get(IURLGenerator::class),
1155
				$c->get(LoggerInterface::class),
1156
				\OC::$configDir,
1157
				\OC::$SERVERROOT . '/resources/config/'
1158
			);
1159
		});
1160
		/** @deprecated 19.0.0 */
1161
		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1162
1163
		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1164
		/** @deprecated 19.0.0 */
1165
		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1166
		$this->registerService(BundleFetcher::class, function () {
1167
			return new BundleFetcher($this->getL10N('lib'));
1168
		});
1169
		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1170
		/** @deprecated 19.0.0 */
1171
		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1172
1173
		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1174
			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1175
			$manager->registerCapability(function () use ($c) {
1176
				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1177
			});
1178
			$manager->registerCapability(function () use ($c) {
1179
				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1180
			});
1181
			$manager->registerCapability(function () use ($c) {
1182
				return $c->get(MetadataCapabilities::class);
1183
			});
1184
			return $manager;
1185
		});
1186
		/** @deprecated 19.0.0 */
1187
		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1188
1189
		$this->registerService(ICommentsManager::class, function (Server $c) {
1190
			$config = $c->get(\OCP\IConfig::class);
1191
			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1192
			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1193
			$factory = new $factoryClass($this);
1194
			$manager = $factory->getManager();
1195
1196
			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1197
				$manager = $c->get(IUserManager::class);
1198
				$userDisplayName = $manager->getDisplayName($id);
1199
				if ($userDisplayName === null) {
1200
					$l = $c->get(IFactory::class)->get('core');
1201
					return $l->t('Unknown user');
1202
				}
1203
				return $userDisplayName;
1204
			});
1205
1206
			return $manager;
1207
		});
1208
		/** @deprecated 19.0.0 */
1209
		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1210
1211
		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1212
		$this->registerService('ThemingDefaults', function (Server $c) {
1213
			try {
1214
				$classExists = class_exists('OCA\Theming\ThemingDefaults');
1215
			} catch (\OCP\AutoloadNotAllowedException $e) {
1216
				// App disabled or in maintenance mode
1217
				$classExists = false;
1218
			}
1219
1220
			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1221
				$imageManager = new ImageManager(
1222
					$c->get(\OCP\IConfig::class),
1223
					$c->getAppDataDir('theming'),
1224
					$c->get(IURLGenerator::class),
1225
					$this->get(ICacheFactory::class),
1226
					$this->get(ILogger::class),
1227
					$this->get(ITempManager::class)
1228
				);
1229
				return new ThemingDefaults(
1230
					$c->get(\OCP\IConfig::class),
1231
					$c->getL10N('theming'),
1232
					$c->get(IUserSession::class),
1233
					$c->get(IURLGenerator::class),
1234
					$c->get(ICacheFactory::class),
1235
					new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1236
					$imageManager,
1237
					$c->get(IAppManager::class),
1238
					$c->get(INavigationManager::class)
1239
				);
1240
			}
1241
			return new \OC_Defaults();
1242
		});
1243
		$this->registerService(JSCombiner::class, function (Server $c) {
1244
			return new JSCombiner(
1245
				$c->getAppDataDir('js'),
1246
				$c->get(IURLGenerator::class),
1247
				$this->get(ICacheFactory::class),
1248
				$c->get(SystemConfig::class),
1249
				$c->get(LoggerInterface::class)
1250
			);
1251
		});
1252
		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1253
		/** @deprecated 19.0.0 */
1254
		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1255
		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1256
1257
		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1258
			// FIXME: Instantiated here due to cyclic dependency
1259
			$request = new Request(
1260
				[
1261
					'get' => $_GET,
1262
					'post' => $_POST,
1263
					'files' => $_FILES,
1264
					'server' => $_SERVER,
1265
					'env' => $_ENV,
1266
					'cookies' => $_COOKIE,
1267
					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1268
						? $_SERVER['REQUEST_METHOD']
1269
						: null,
1270
				],
1271
				$c->get(IRequestId::class),
1272
				$c->get(\OCP\IConfig::class)
1273
			);
1274
1275
			return new CryptoWrapper(
1276
				$c->get(\OCP\IConfig::class),
1277
				$c->get(ICrypto::class),
1278
				$c->get(ISecureRandom::class),
1279
				$request
1280
			);
1281
		});
1282
		/** @deprecated 19.0.0 */
1283
		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1284
		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1285
			return new SessionStorage($c->get(ISession::class));
1286
		});
1287
		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1288
		/** @deprecated 19.0.0 */
1289
		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1290
1291
		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1292
			$config = $c->get(\OCP\IConfig::class);
1293
			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1294
			/** @var \OCP\Share\IProviderFactory $factory */
1295
			$factory = new $factoryClass($this);
1296
1297
			$manager = new \OC\Share20\Manager(
1298
				$c->get(LoggerInterface::class),
1299
				$c->get(\OCP\IConfig::class),
1300
				$c->get(ISecureRandom::class),
1301
				$c->get(IHasher::class),
1302
				$c->get(IMountManager::class),
1303
				$c->get(IGroupManager::class),
1304
				$c->getL10N('lib'),
1305
				$c->get(IFactory::class),
1306
				$factory,
1307
				$c->get(IUserManager::class),
1308
				$c->get(IRootFolder::class),
1309
				$c->get(SymfonyAdapter::class),
1310
				$c->get(IMailer::class),
1311
				$c->get(IURLGenerator::class),
1312
				$c->get('ThemingDefaults'),
1313
				$c->get(IEventDispatcher::class),
1314
				$c->get(IUserSession::class),
1315
				$c->get(KnownUserService::class)
1316
			);
1317
1318
			return $manager;
1319
		});
1320
		/** @deprecated 19.0.0 */
1321
		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1322
1323
		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1324
			$instance = new Collaboration\Collaborators\Search($c);
1325
1326
			// register default plugins
1327
			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1328
			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1329
			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1330
			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1331
			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1332
1333
			return $instance;
1334
		});
1335
		/** @deprecated 19.0.0 */
1336
		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1337
		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1338
1339
		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1340
1341
		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1342
		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1343
1344
		$this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1345
1346
		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1347
		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1348
		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1349
			return new \OC\Files\AppData\Factory(
1350
				$c->get(IRootFolder::class),
1351
				$c->get(SystemConfig::class)
1352
			);
1353
		});
1354
1355
		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1356
			return new LockdownManager(function () use ($c) {
1357
				return $c->get(ISession::class);
1358
			});
1359
		});
1360
1361
		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1362
			return new DiscoveryService(
1363
				$c->get(ICacheFactory::class),
1364
				$c->get(IClientService::class)
1365
			);
1366
		});
1367
1368
		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1369
			return new CloudIdManager(
1370
				$c->get(\OCP\Contacts\IManager::class),
1371
				$c->get(IURLGenerator::class),
1372
				$c->get(IUserManager::class),
1373
				$c->get(ICacheFactory::class),
1374
				$c->get(IEventDispatcher::class),
1375
			);
1376
		});
1377
1378
		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1379
1380
		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1381
			return new CloudFederationProviderManager(
1382
				$c->get(IAppManager::class),
1383
				$c->get(IClientService::class),
1384
				$c->get(ICloudIdManager::class),
1385
				$c->get(LoggerInterface::class)
1386
			);
1387
		});
1388
1389
		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

1389
		$this->registerService(ICloudFederationFactory::class, function (/** @scrutinizer ignore-unused */ Server $c) {

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

Loading history...
1390
			return new CloudFederationFactory();
1391
		});
1392
1393
		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1394
		/** @deprecated 19.0.0 */
1395
		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1396
1397
		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1398
		$this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1399
		/** @deprecated 19.0.0 */
1400
		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1401
1402
		$this->registerService(Defaults::class, function (Server $c) {
1403
			return new Defaults(
1404
				$c->getThemingDefaults()
1405
			);
1406
		});
1407
		/** @deprecated 19.0.0 */
1408
		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1409
1410
		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1411
			return $c->get(\OCP\IUserSession::class)->getSession();
1412
		}, false);
1413
1414
		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1415
			return new ShareHelper(
1416
				$c->get(\OCP\Share\IManager::class)
1417
			);
1418
		});
1419
1420
		$this->registerService(Installer::class, function (ContainerInterface $c) {
1421
			return new Installer(
1422
				$c->get(AppFetcher::class),
1423
				$c->get(IClientService::class),
1424
				$c->get(ITempManager::class),
1425
				$c->get(LoggerInterface::class),
1426
				$c->get(\OCP\IConfig::class),
1427
				\OC::$CLI
1428
			);
1429
		});
1430
1431
		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1432
			return new ApiFactory($c->get(IClientService::class));
1433
		});
1434
1435
		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1436
			$memcacheFactory = $c->get(ICacheFactory::class);
1437
			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1438
		});
1439
1440
		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1441
		$this->registerAlias(IAccountManager::class, AccountManager::class);
1442
1443
		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1444
1445
		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1446
1447
		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1448
1449
		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1450
1451
		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1452
1453
		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1454
1455
		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1456
1457
		$this->registerAlias(IBroker::class, Broker::class);
1458
1459
		$this->registerAlias(IMetadataManager::class, MetadataManager::class);
1460
1461
		$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1462
1463
		$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1464
1465
		$this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1466
1467
		$this->registerAlias(ITranslationManager::class, TranslationManager::class);
1468
1469
		$this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
1470
1471
		$this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
1472
1473
		$this->connectDispatcher();
1474
	}
1475
1476
	public function boot() {
1477
		/** @var HookConnector $hookConnector */
1478
		$hookConnector = $this->get(HookConnector::class);
1479
		$hookConnector->viewToNode();
1480
	}
1481
1482
	/**
1483
	 * @return \OCP\Calendar\IManager
1484
	 * @deprecated 20.0.0
1485
	 */
1486
	public function getCalendarManager() {
1487
		return $this->get(\OC\Calendar\Manager::class);
1488
	}
1489
1490
	/**
1491
	 * @return \OCP\Calendar\Resource\IManager
1492
	 * @deprecated 20.0.0
1493
	 */
1494
	public function getCalendarResourceBackendManager() {
1495
		return $this->get(\OC\Calendar\Resource\Manager::class);
1496
	}
1497
1498
	/**
1499
	 * @return \OCP\Calendar\Room\IManager
1500
	 * @deprecated 20.0.0
1501
	 */
1502
	public function getCalendarRoomBackendManager() {
1503
		return $this->get(\OC\Calendar\Room\Manager::class);
1504
	}
1505
1506
	private function connectDispatcher(): void {
1507
		/** @var IEventDispatcher $eventDispatcher */
1508
		$eventDispatcher = $this->get(IEventDispatcher::class);
1509
		$eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1510
		$eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1511
		$eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1512
		$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1513
	}
1514
1515
	/**
1516
	 * @return \OCP\Contacts\IManager
1517
	 * @deprecated 20.0.0
1518
	 */
1519
	public function getContactsManager() {
1520
		return $this->get(\OCP\Contacts\IManager::class);
1521
	}
1522
1523
	/**
1524
	 * @return \OC\Encryption\Manager
1525
	 * @deprecated 20.0.0
1526
	 */
1527
	public function getEncryptionManager() {
1528
		return $this->get(\OCP\Encryption\IManager::class);
1529
	}
1530
1531
	/**
1532
	 * @return \OC\Encryption\File
1533
	 * @deprecated 20.0.0
1534
	 */
1535
	public function getEncryptionFilesHelper() {
1536
		return $this->get(IFile::class);
1537
	}
1538
1539
	/**
1540
	 * @return \OCP\Encryption\Keys\IStorage
1541
	 * @deprecated 20.0.0
1542
	 */
1543
	public function getEncryptionKeyStorage() {
1544
		return $this->get(IStorage::class);
1545
	}
1546
1547
	/**
1548
	 * The current request object holding all information about the request
1549
	 * currently being processed is returned from this method.
1550
	 * In case the current execution was not initiated by a web request null is returned
1551
	 *
1552
	 * @return \OCP\IRequest
1553
	 * @deprecated 20.0.0
1554
	 */
1555
	public function getRequest() {
1556
		return $this->get(IRequest::class);
1557
	}
1558
1559
	/**
1560
	 * Returns the preview manager which can create preview images for a given file
1561
	 *
1562
	 * @return IPreview
1563
	 * @deprecated 20.0.0
1564
	 */
1565
	public function getPreviewManager() {
1566
		return $this->get(IPreview::class);
1567
	}
1568
1569
	/**
1570
	 * Returns the tag manager which can get and set tags for different object types
1571
	 *
1572
	 * @see \OCP\ITagManager::load()
1573
	 * @return ITagManager
1574
	 * @deprecated 20.0.0
1575
	 */
1576
	public function getTagManager() {
1577
		return $this->get(ITagManager::class);
1578
	}
1579
1580
	/**
1581
	 * Returns the system-tag manager
1582
	 *
1583
	 * @return ISystemTagManager
1584
	 *
1585
	 * @since 9.0.0
1586
	 * @deprecated 20.0.0
1587
	 */
1588
	public function getSystemTagManager() {
1589
		return $this->get(ISystemTagManager::class);
1590
	}
1591
1592
	/**
1593
	 * Returns the system-tag object mapper
1594
	 *
1595
	 * @return ISystemTagObjectMapper
1596
	 *
1597
	 * @since 9.0.0
1598
	 * @deprecated 20.0.0
1599
	 */
1600
	public function getSystemTagObjectMapper() {
1601
		return $this->get(ISystemTagObjectMapper::class);
1602
	}
1603
1604
	/**
1605
	 * Returns the avatar manager, used for avatar functionality
1606
	 *
1607
	 * @return IAvatarManager
1608
	 * @deprecated 20.0.0
1609
	 */
1610
	public function getAvatarManager() {
1611
		return $this->get(IAvatarManager::class);
1612
	}
1613
1614
	/**
1615
	 * Returns the root folder of ownCloud's data directory
1616
	 *
1617
	 * @return IRootFolder
1618
	 * @deprecated 20.0.0
1619
	 */
1620
	public function getRootFolder() {
1621
		return $this->get(IRootFolder::class);
1622
	}
1623
1624
	/**
1625
	 * Returns the root folder of ownCloud's data directory
1626
	 * This is the lazy variant so this gets only initialized once it
1627
	 * is actually used.
1628
	 *
1629
	 * @return IRootFolder
1630
	 * @deprecated 20.0.0
1631
	 */
1632
	public function getLazyRootFolder() {
1633
		return $this->get(IRootFolder::class);
1634
	}
1635
1636
	/**
1637
	 * Returns a view to ownCloud's files folder
1638
	 *
1639
	 * @param string $userId user ID
1640
	 * @return \OCP\Files\Folder|null
1641
	 * @deprecated 20.0.0
1642
	 */
1643
	public function getUserFolder($userId = null) {
1644
		if ($userId === null) {
1645
			$user = $this->get(IUserSession::class)->getUser();
1646
			if (!$user) {
1647
				return null;
1648
			}
1649
			$userId = $user->getUID();
1650
		}
1651
		$root = $this->get(IRootFolder::class);
1652
		return $root->getUserFolder($userId);
1653
	}
1654
1655
	/**
1656
	 * @return \OC\User\Manager
1657
	 * @deprecated 20.0.0
1658
	 */
1659
	public function getUserManager() {
1660
		return $this->get(IUserManager::class);
1661
	}
1662
1663
	/**
1664
	 * @return \OC\Group\Manager
1665
	 * @deprecated 20.0.0
1666
	 */
1667
	public function getGroupManager() {
1668
		return $this->get(IGroupManager::class);
1669
	}
1670
1671
	/**
1672
	 * @return \OC\User\Session
1673
	 * @deprecated 20.0.0
1674
	 */
1675
	public function getUserSession() {
1676
		return $this->get(IUserSession::class);
1677
	}
1678
1679
	/**
1680
	 * @return \OCP\ISession
1681
	 * @deprecated 20.0.0
1682
	 */
1683
	public function getSession() {
1684
		return $this->get(Session::class)->getSession();
1685
	}
1686
1687
	/**
1688
	 * @param \OCP\ISession $session
1689
	 */
1690
	public function setSession(\OCP\ISession $session) {
1691
		$this->get(SessionStorage::class)->setSession($session);
1692
		$this->get(Session::class)->setSession($session);
1693
		$this->get(Store::class)->setSession($session);
1694
	}
1695
1696
	/**
1697
	 * @return \OC\Authentication\TwoFactorAuth\Manager
1698
	 * @deprecated 20.0.0
1699
	 */
1700
	public function getTwoFactorAuthManager() {
1701
		return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1702
	}
1703
1704
	/**
1705
	 * @return \OC\NavigationManager
1706
	 * @deprecated 20.0.0
1707
	 */
1708
	public function getNavigationManager() {
1709
		return $this->get(INavigationManager::class);
1710
	}
1711
1712
	/**
1713
	 * @return \OCP\IConfig
1714
	 * @deprecated 20.0.0
1715
	 */
1716
	public function getConfig() {
1717
		return $this->get(AllConfig::class);
1718
	}
1719
1720
	/**
1721
	 * @return \OC\SystemConfig
1722
	 * @deprecated 20.0.0
1723
	 */
1724
	public function getSystemConfig() {
1725
		return $this->get(SystemConfig::class);
1726
	}
1727
1728
	/**
1729
	 * Returns the app config manager
1730
	 *
1731
	 * @return IAppConfig
1732
	 * @deprecated 20.0.0
1733
	 */
1734
	public function getAppConfig() {
1735
		return $this->get(IAppConfig::class);
1736
	}
1737
1738
	/**
1739
	 * @return IFactory
1740
	 * @deprecated 20.0.0
1741
	 */
1742
	public function getL10NFactory() {
1743
		return $this->get(IFactory::class);
1744
	}
1745
1746
	/**
1747
	 * get an L10N instance
1748
	 *
1749
	 * @param string $app appid
1750
	 * @param string $lang
1751
	 * @return IL10N
1752
	 * @deprecated 20.0.0
1753
	 */
1754
	public function getL10N($app, $lang = null) {
1755
		return $this->get(IFactory::class)->get($app, $lang);
1756
	}
1757
1758
	/**
1759
	 * @return IURLGenerator
1760
	 * @deprecated 20.0.0
1761
	 */
1762
	public function getURLGenerator() {
1763
		return $this->get(IURLGenerator::class);
1764
	}
1765
1766
	/**
1767
	 * @return AppFetcher
1768
	 * @deprecated 20.0.0
1769
	 */
1770
	public function getAppFetcher() {
1771
		return $this->get(AppFetcher::class);
1772
	}
1773
1774
	/**
1775
	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1776
	 * getMemCacheFactory() instead.
1777
	 *
1778
	 * @return ICache
1779
	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1780
	 */
1781
	public function getCache() {
1782
		return $this->get(ICache::class);
1783
	}
1784
1785
	/**
1786
	 * Returns an \OCP\CacheFactory instance
1787
	 *
1788
	 * @return \OCP\ICacheFactory
1789
	 * @deprecated 20.0.0
1790
	 */
1791
	public function getMemCacheFactory() {
1792
		return $this->get(ICacheFactory::class);
1793
	}
1794
1795
	/**
1796
	 * Returns an \OC\RedisFactory instance
1797
	 *
1798
	 * @return \OC\RedisFactory
1799
	 * @deprecated 20.0.0
1800
	 */
1801
	public function getGetRedisFactory() {
1802
		return $this->get('RedisFactory');
1803
	}
1804
1805
1806
	/**
1807
	 * Returns the current session
1808
	 *
1809
	 * @return \OCP\IDBConnection
1810
	 * @deprecated 20.0.0
1811
	 */
1812
	public function getDatabaseConnection() {
1813
		return $this->get(IDBConnection::class);
1814
	}
1815
1816
	/**
1817
	 * Returns the activity manager
1818
	 *
1819
	 * @return \OCP\Activity\IManager
1820
	 * @deprecated 20.0.0
1821
	 */
1822
	public function getActivityManager() {
1823
		return $this->get(\OCP\Activity\IManager::class);
1824
	}
1825
1826
	/**
1827
	 * Returns an job list for controlling background jobs
1828
	 *
1829
	 * @return IJobList
1830
	 * @deprecated 20.0.0
1831
	 */
1832
	public function getJobList() {
1833
		return $this->get(IJobList::class);
1834
	}
1835
1836
	/**
1837
	 * Returns a logger instance
1838
	 *
1839
	 * @return ILogger
1840
	 * @deprecated 20.0.0
1841
	 */
1842
	public function getLogger() {
1843
		return $this->get(ILogger::class);
1844
	}
1845
1846
	/**
1847
	 * @return ILogFactory
1848
	 * @throws \OCP\AppFramework\QueryException
1849
	 * @deprecated 20.0.0
1850
	 */
1851
	public function getLogFactory() {
1852
		return $this->get(ILogFactory::class);
1853
	}
1854
1855
	/**
1856
	 * Returns a router for generating and matching urls
1857
	 *
1858
	 * @return IRouter
1859
	 * @deprecated 20.0.0
1860
	 */
1861
	public function getRouter() {
1862
		return $this->get(IRouter::class);
1863
	}
1864
1865
	/**
1866
	 * Returns a search instance
1867
	 *
1868
	 * @return ISearch
1869
	 * @deprecated 20.0.0
1870
	 */
1871
	public function getSearch() {
1872
		return $this->get(ISearch::class);
1873
	}
1874
1875
	/**
1876
	 * Returns a SecureRandom instance
1877
	 *
1878
	 * @return \OCP\Security\ISecureRandom
1879
	 * @deprecated 20.0.0
1880
	 */
1881
	public function getSecureRandom() {
1882
		return $this->get(ISecureRandom::class);
1883
	}
1884
1885
	/**
1886
	 * Returns a Crypto instance
1887
	 *
1888
	 * @return ICrypto
1889
	 * @deprecated 20.0.0
1890
	 */
1891
	public function getCrypto() {
1892
		return $this->get(ICrypto::class);
1893
	}
1894
1895
	/**
1896
	 * Returns a Hasher instance
1897
	 *
1898
	 * @return IHasher
1899
	 * @deprecated 20.0.0
1900
	 */
1901
	public function getHasher() {
1902
		return $this->get(IHasher::class);
1903
	}
1904
1905
	/**
1906
	 * Returns a CredentialsManager instance
1907
	 *
1908
	 * @return ICredentialsManager
1909
	 * @deprecated 20.0.0
1910
	 */
1911
	public function getCredentialsManager() {
1912
		return $this->get(ICredentialsManager::class);
1913
	}
1914
1915
	/**
1916
	 * Get the certificate manager
1917
	 *
1918
	 * @return \OCP\ICertificateManager
1919
	 */
1920
	public function getCertificateManager() {
1921
		return $this->get(ICertificateManager::class);
1922
	}
1923
1924
	/**
1925
	 * Returns an instance of the HTTP client service
1926
	 *
1927
	 * @return IClientService
1928
	 * @deprecated 20.0.0
1929
	 */
1930
	public function getHTTPClientService() {
1931
		return $this->get(IClientService::class);
1932
	}
1933
1934
	/**
1935
	 * Get the active event logger
1936
	 *
1937
	 * The returned logger only logs data when debug mode is enabled
1938
	 *
1939
	 * @return IEventLogger
1940
	 * @deprecated 20.0.0
1941
	 */
1942
	public function getEventLogger() {
1943
		return $this->get(IEventLogger::class);
1944
	}
1945
1946
	/**
1947
	 * Get the active query logger
1948
	 *
1949
	 * The returned logger only logs data when debug mode is enabled
1950
	 *
1951
	 * @return IQueryLogger
1952
	 * @deprecated 20.0.0
1953
	 */
1954
	public function getQueryLogger() {
1955
		return $this->get(IQueryLogger::class);
1956
	}
1957
1958
	/**
1959
	 * Get the manager for temporary files and folders
1960
	 *
1961
	 * @return \OCP\ITempManager
1962
	 * @deprecated 20.0.0
1963
	 */
1964
	public function getTempManager() {
1965
		return $this->get(ITempManager::class);
1966
	}
1967
1968
	/**
1969
	 * Get the app manager
1970
	 *
1971
	 * @return \OCP\App\IAppManager
1972
	 * @deprecated 20.0.0
1973
	 */
1974
	public function getAppManager() {
1975
		return $this->get(IAppManager::class);
1976
	}
1977
1978
	/**
1979
	 * Creates a new mailer
1980
	 *
1981
	 * @return IMailer
1982
	 * @deprecated 20.0.0
1983
	 */
1984
	public function getMailer() {
1985
		return $this->get(IMailer::class);
1986
	}
1987
1988
	/**
1989
	 * Get the webroot
1990
	 *
1991
	 * @return string
1992
	 * @deprecated 20.0.0
1993
	 */
1994
	public function getWebRoot() {
1995
		return $this->webRoot;
1996
	}
1997
1998
	/**
1999
	 * @return \OC\OCSClient
0 ignored issues
show
Bug introduced by
The type OC\OCSClient was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
2000
	 * @deprecated 20.0.0
2001
	 */
2002
	public function getOcsClient() {
2003
		return $this->get('OcsClient');
2004
	}
2005
2006
	/**
2007
	 * @return IDateTimeZone
2008
	 * @deprecated 20.0.0
2009
	 */
2010
	public function getDateTimeZone() {
2011
		return $this->get(IDateTimeZone::class);
2012
	}
2013
2014
	/**
2015
	 * @return IDateTimeFormatter
2016
	 * @deprecated 20.0.0
2017
	 */
2018
	public function getDateTimeFormatter() {
2019
		return $this->get(IDateTimeFormatter::class);
2020
	}
2021
2022
	/**
2023
	 * @return IMountProviderCollection
2024
	 * @deprecated 20.0.0
2025
	 */
2026
	public function getMountProviderCollection() {
2027
		return $this->get(IMountProviderCollection::class);
2028
	}
2029
2030
	/**
2031
	 * Get the IniWrapper
2032
	 *
2033
	 * @return IniGetWrapper
2034
	 * @deprecated 20.0.0
2035
	 */
2036
	public function getIniWrapper() {
2037
		return $this->get(IniGetWrapper::class);
2038
	}
2039
2040
	/**
2041
	 * @return \OCP\Command\IBus
2042
	 * @deprecated 20.0.0
2043
	 */
2044
	public function getCommandBus() {
2045
		return $this->get(IBus::class);
2046
	}
2047
2048
	/**
2049
	 * Get the trusted domain helper
2050
	 *
2051
	 * @return TrustedDomainHelper
2052
	 * @deprecated 20.0.0
2053
	 */
2054
	public function getTrustedDomainHelper() {
2055
		return $this->get(TrustedDomainHelper::class);
2056
	}
2057
2058
	/**
2059
	 * Get the locking provider
2060
	 *
2061
	 * @return ILockingProvider
2062
	 * @since 8.1.0
2063
	 * @deprecated 20.0.0
2064
	 */
2065
	public function getLockingProvider() {
2066
		return $this->get(ILockingProvider::class);
2067
	}
2068
2069
	/**
2070
	 * @return IMountManager
2071
	 * @deprecated 20.0.0
2072
	 **/
2073
	public function getMountManager() {
2074
		return $this->get(IMountManager::class);
2075
	}
2076
2077
	/**
2078
	 * @return IUserMountCache
2079
	 * @deprecated 20.0.0
2080
	 */
2081
	public function getUserMountCache() {
2082
		return $this->get(IUserMountCache::class);
2083
	}
2084
2085
	/**
2086
	 * Get the MimeTypeDetector
2087
	 *
2088
	 * @return IMimeTypeDetector
2089
	 * @deprecated 20.0.0
2090
	 */
2091
	public function getMimeTypeDetector() {
2092
		return $this->get(IMimeTypeDetector::class);
2093
	}
2094
2095
	/**
2096
	 * Get the MimeTypeLoader
2097
	 *
2098
	 * @return IMimeTypeLoader
2099
	 * @deprecated 20.0.0
2100
	 */
2101
	public function getMimeTypeLoader() {
2102
		return $this->get(IMimeTypeLoader::class);
2103
	}
2104
2105
	/**
2106
	 * Get the manager of all the capabilities
2107
	 *
2108
	 * @return CapabilitiesManager
2109
	 * @deprecated 20.0.0
2110
	 */
2111
	public function getCapabilitiesManager() {
2112
		return $this->get(CapabilitiesManager::class);
2113
	}
2114
2115
	/**
2116
	 * Get the EventDispatcher
2117
	 *
2118
	 * @return EventDispatcherInterface
2119
	 * @since 8.2.0
2120
	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2121
	 */
2122
	public function getEventDispatcher() {
2123
		return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2124
	}
2125
2126
	/**
2127
	 * Get the Notification Manager
2128
	 *
2129
	 * @return \OCP\Notification\IManager
2130
	 * @since 8.2.0
2131
	 * @deprecated 20.0.0
2132
	 */
2133
	public function getNotificationManager() {
2134
		return $this->get(\OCP\Notification\IManager::class);
2135
	}
2136
2137
	/**
2138
	 * @return ICommentsManager
2139
	 * @deprecated 20.0.0
2140
	 */
2141
	public function getCommentsManager() {
2142
		return $this->get(ICommentsManager::class);
2143
	}
2144
2145
	/**
2146
	 * @return \OCA\Theming\ThemingDefaults
2147
	 * @deprecated 20.0.0
2148
	 */
2149
	public function getThemingDefaults() {
2150
		return $this->get('ThemingDefaults');
2151
	}
2152
2153
	/**
2154
	 * @return \OC\IntegrityCheck\Checker
2155
	 * @deprecated 20.0.0
2156
	 */
2157
	public function getIntegrityCodeChecker() {
2158
		return $this->get('IntegrityCodeChecker');
2159
	}
2160
2161
	/**
2162
	 * @return \OC\Session\CryptoWrapper
2163
	 * @deprecated 20.0.0
2164
	 */
2165
	public function getSessionCryptoWrapper() {
2166
		return $this->get('CryptoWrapper');
2167
	}
2168
2169
	/**
2170
	 * @return CsrfTokenManager
2171
	 * @deprecated 20.0.0
2172
	 */
2173
	public function getCsrfTokenManager() {
2174
		return $this->get(CsrfTokenManager::class);
2175
	}
2176
2177
	/**
2178
	 * @return Throttler
2179
	 * @deprecated 20.0.0
2180
	 */
2181
	public function getBruteForceThrottler() {
2182
		return $this->get(Throttler::class);
2183
	}
2184
2185
	/**
2186
	 * @return IContentSecurityPolicyManager
2187
	 * @deprecated 20.0.0
2188
	 */
2189
	public function getContentSecurityPolicyManager() {
2190
		return $this->get(ContentSecurityPolicyManager::class);
2191
	}
2192
2193
	/**
2194
	 * @return ContentSecurityPolicyNonceManager
2195
	 * @deprecated 20.0.0
2196
	 */
2197
	public function getContentSecurityPolicyNonceManager() {
2198
		return $this->get(ContentSecurityPolicyNonceManager::class);
2199
	}
2200
2201
	/**
2202
	 * Not a public API as of 8.2, wait for 9.0
2203
	 *
2204
	 * @return \OCA\Files_External\Service\BackendService
2205
	 * @deprecated 20.0.0
2206
	 */
2207
	public function getStoragesBackendService() {
2208
		return $this->get(BackendService::class);
2209
	}
2210
2211
	/**
2212
	 * Not a public API as of 8.2, wait for 9.0
2213
	 *
2214
	 * @return \OCA\Files_External\Service\GlobalStoragesService
2215
	 * @deprecated 20.0.0
2216
	 */
2217
	public function getGlobalStoragesService() {
2218
		return $this->get(GlobalStoragesService::class);
2219
	}
2220
2221
	/**
2222
	 * Not a public API as of 8.2, wait for 9.0
2223
	 *
2224
	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2225
	 * @deprecated 20.0.0
2226
	 */
2227
	public function getUserGlobalStoragesService() {
2228
		return $this->get(UserGlobalStoragesService::class);
2229
	}
2230
2231
	/**
2232
	 * Not a public API as of 8.2, wait for 9.0
2233
	 *
2234
	 * @return \OCA\Files_External\Service\UserStoragesService
2235
	 * @deprecated 20.0.0
2236
	 */
2237
	public function getUserStoragesService() {
2238
		return $this->get(UserStoragesService::class);
2239
	}
2240
2241
	/**
2242
	 * @return \OCP\Share\IManager
2243
	 * @deprecated 20.0.0
2244
	 */
2245
	public function getShareManager() {
2246
		return $this->get(\OCP\Share\IManager::class);
2247
	}
2248
2249
	/**
2250
	 * @return \OCP\Collaboration\Collaborators\ISearch
2251
	 * @deprecated 20.0.0
2252
	 */
2253
	public function getCollaboratorSearch() {
2254
		return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2255
	}
2256
2257
	/**
2258
	 * @return \OCP\Collaboration\AutoComplete\IManager
2259
	 * @deprecated 20.0.0
2260
	 */
2261
	public function getAutoCompleteManager() {
2262
		return $this->get(IManager::class);
2263
	}
2264
2265
	/**
2266
	 * Returns the LDAP Provider
2267
	 *
2268
	 * @return \OCP\LDAP\ILDAPProvider
2269
	 * @deprecated 20.0.0
2270
	 */
2271
	public function getLDAPProvider() {
2272
		return $this->get('LDAPProvider');
2273
	}
2274
2275
	/**
2276
	 * @return \OCP\Settings\IManager
2277
	 * @deprecated 20.0.0
2278
	 */
2279
	public function getSettingsManager() {
2280
		return $this->get(\OC\Settings\Manager::class);
2281
	}
2282
2283
	/**
2284
	 * @return \OCP\Files\IAppData
2285
	 * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
2286
	 */
2287
	public function getAppDataDir($app) {
2288
		/** @var \OC\Files\AppData\Factory $factory */
2289
		$factory = $this->get(\OC\Files\AppData\Factory::class);
2290
		return $factory->get($app);
2291
	}
2292
2293
	/**
2294
	 * @return \OCP\Lockdown\ILockdownManager
2295
	 * @deprecated 20.0.0
2296
	 */
2297
	public function getLockdownManager() {
2298
		return $this->get('LockdownManager');
2299
	}
2300
2301
	/**
2302
	 * @return \OCP\Federation\ICloudIdManager
2303
	 * @deprecated 20.0.0
2304
	 */
2305
	public function getCloudIdManager() {
2306
		return $this->get(ICloudIdManager::class);
2307
	}
2308
2309
	/**
2310
	 * @return \OCP\GlobalScale\IConfig
2311
	 * @deprecated 20.0.0
2312
	 */
2313
	public function getGlobalScaleConfig() {
2314
		return $this->get(IConfig::class);
2315
	}
2316
2317
	/**
2318
	 * @return \OCP\Federation\ICloudFederationProviderManager
2319
	 * @deprecated 20.0.0
2320
	 */
2321
	public function getCloudFederationProviderManager() {
2322
		return $this->get(ICloudFederationProviderManager::class);
2323
	}
2324
2325
	/**
2326
	 * @return \OCP\Remote\Api\IApiFactory
2327
	 * @deprecated 20.0.0
2328
	 */
2329
	public function getRemoteApiFactory() {
2330
		return $this->get(IApiFactory::class);
2331
	}
2332
2333
	/**
2334
	 * @return \OCP\Federation\ICloudFederationFactory
2335
	 * @deprecated 20.0.0
2336
	 */
2337
	public function getCloudFederationFactory() {
2338
		return $this->get(ICloudFederationFactory::class);
2339
	}
2340
2341
	/**
2342
	 * @return \OCP\Remote\IInstanceFactory
2343
	 * @deprecated 20.0.0
2344
	 */
2345
	public function getRemoteInstanceFactory() {
2346
		return $this->get(IInstanceFactory::class);
2347
	}
2348
2349
	/**
2350
	 * @return IStorageFactory
2351
	 * @deprecated 20.0.0
2352
	 */
2353
	public function getStorageFactory() {
2354
		return $this->get(IStorageFactory::class);
2355
	}
2356
2357
	/**
2358
	 * Get the Preview GeneratorHelper
2359
	 *
2360
	 * @return GeneratorHelper
2361
	 * @since 17.0.0
2362
	 * @deprecated 20.0.0
2363
	 */
2364
	public function getGeneratorHelper() {
2365
		return $this->get(\OC\Preview\GeneratorHelper::class);
2366
	}
2367
2368
	private function registerDeprecatedAlias(string $alias, string $target) {
2369
		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2370
			try {
2371
				/** @var LoggerInterface $logger */
2372
				$logger = $container->get(LoggerInterface::class);
2373
				$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2374
			} catch (ContainerExceptionInterface $e) {
2375
				// Could not get logger. Continue
2376
			}
2377
2378
			return $container->get($target);
2379
		}, false);
2380
	}
2381
}
2382