Passed
Push — master ( 14685e...6cfd53 )
by Julius
15:11 queued 13s
created
core/Controller/TranslationApiController.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -35,32 +35,32 @@
 block discarded – undo
35 35
 use RuntimeException;
36 36
 
37 37
 class TranslationApiController extends \OCP\AppFramework\OCSController {
38
-	private ITranslationManager $translationManager;
38
+    private ITranslationManager $translationManager;
39 39
 
40
-	public function __construct($appName, IRequest $request, ITranslationManager $translationManager) {
41
-		parent::__construct($appName, $request);
40
+    public function __construct($appName, IRequest $request, ITranslationManager $translationManager) {
41
+        parent::__construct($appName, $request);
42 42
 
43
-		$this->translationManager = $translationManager;
44
-	}
43
+        $this->translationManager = $translationManager;
44
+    }
45 45
 
46
-	public function languages(): DataResponse {
47
-		return new DataResponse([
48
-			'languages' => $this->translationManager->getLanguages(),
49
-			'languageDetection' => $this->translationManager->canDetectLanguage(),
50
-		]);
51
-	}
46
+    public function languages(): DataResponse {
47
+        return new DataResponse([
48
+            'languages' => $this->translationManager->getLanguages(),
49
+            'languageDetection' => $this->translationManager->canDetectLanguage(),
50
+        ]);
51
+    }
52 52
 
53
-	public function translate(string $text, ?string $fromLanguage, string $toLanguage): DataResponse {
54
-		try {
55
-			return new DataResponse([
56
-				'text' => $this->translationManager->translate($text, $fromLanguage, $toLanguage)
57
-			]);
58
-		} catch (PreConditionNotMetException) {
59
-			return new DataResponse(['message' => 'No translation provider available'], Http::STATUS_PRECONDITION_FAILED);
60
-		} catch (InvalidArgumentException) {
61
-			return new DataResponse(['message' => 'Could not detect language', Http::STATUS_NOT_FOUND]);
62
-		} catch (RuntimeException) {
63
-			return new DataResponse(['message' => 'Unable to translate', Http::STATUS_INTERNAL_SERVER_ERROR]);
64
-		}
65
-	}
53
+    public function translate(string $text, ?string $fromLanguage, string $toLanguage): DataResponse {
54
+        try {
55
+            return new DataResponse([
56
+                'text' => $this->translationManager->translate($text, $fromLanguage, $toLanguage)
57
+            ]);
58
+        } catch (PreConditionNotMetException) {
59
+            return new DataResponse(['message' => 'No translation provider available'], Http::STATUS_PRECONDITION_FAILED);
60
+        } catch (InvalidArgumentException) {
61
+            return new DataResponse(['message' => 'Could not detect language', Http::STATUS_NOT_FOUND]);
62
+        } catch (RuntimeException) {
63
+            return new DataResponse(['message' => 'Unable to translate', Http::STATUS_INTERNAL_SERVER_ERROR]);
64
+        }
65
+    }
66 66
 }
Please login to merge, or discard this patch.
core/routes.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -39,113 +39,113 @@  discard block
 block discarded – undo
39 39
 /** @var Application $application */
40 40
 $application = \OC::$server->query(Application::class);
41 41
 $application->registerRoutes($this, [
42
-	'routes' => [
43
-		['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
44
-		['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
45
-		['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
46
-		['name' => 'ProfilePage#index', 'url' => '/u/{targetUserId}', 'verb' => 'GET'],
47
-		['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
48
-		['name' => 'avatar#getAvatarDark', 'url' => '/avatar/{userId}/{size}/dark', 'verb' => 'GET'],
49
-		['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
50
-		['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
51
-		['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
52
-		['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
53
-		['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
54
-		['name' => 'GuestAvatar#getAvatarDark', 'url' => '/avatar/guest/{guestName}/{size}/dark', 'verb' => 'GET'],
55
-		['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'],
56
-		['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
57
-		['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
58
-		['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
59
-		['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
60
-		['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
61
-
62
-		// Original login flow used by all clients
63
-		['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
64
-		['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
65
-		['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
66
-		['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'],
67
-
68
-		// NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example)
69
-		['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'],
70
-		['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'],
71
-		['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'],
72
-		['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'],
73
-		['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'],
74
-		['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'],
75
-		['name' => 'ClientFlowLoginV2#apptokenRedirect', 'url' => '/login/v2/apptoken', 'verb' => 'POST'],
76
-		['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
77
-		['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
78
-		['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
79
-		['name' => 'TwoFactorChallenge#setupProviders', 'url' => 'login/setupchallenge', 'verb' => 'GET'],
80
-		['name' => 'TwoFactorChallenge#setupProvider', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'GET'],
81
-		['name' => 'TwoFactorChallenge#confirmProviderSetup', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'POST'],
82
-		['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
83
-		['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
84
-		['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
85
-		['name' => 'RecommendedApps#index', 'url' => '/core/apps/recommended', 'verb' => 'GET'],
86
-		['name' => 'Reference#preview', 'url' => '/core/references/preview/{referenceId}', 'verb' => 'GET'],
87
-		['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
88
-		['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
89
-		['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
90
-		['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
91
-		['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
92
-		['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
93
-		['name' => 'Wipe#checkWipe', 'url' => '/core/wipe/check', 'verb' => 'POST'],
94
-		['name' => 'Wipe#wipeDone', 'url' => '/core/wipe/success', 'verb' => 'POST'],
95
-
96
-		// Logins for passwordless auth
97
-		['name' => 'WebAuthn#startAuthentication', 'url' => 'login/webauthn/start', 'verb' => 'POST'],
98
-		['name' => 'WebAuthn#finishAuthentication', 'url' => 'login/webauthn/finish', 'verb' => 'POST'],
99
-
100
-		['name' => 'Error#error404', 'url' => 'error/404'],
101
-		['name' => 'Error#error403', 'url' => 'error/403'],
102
-
103
-		// Well known requests https://tools.ietf.org/html/rfc5785
104
-		['name' => 'WellKnown#handle', 'url' => '.well-known/{service}'],
105
-
106
-		// Unsupported browser
107
-		['name' => 'UnsupportedBrowser#index', 'url' => 'unsupported'],
108
-	],
109
-	'ocs' => [
110
-		['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
111
-		['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
112
-		['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
113
-		['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
114
-		['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
115
-		['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
116
-		['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
117
-		['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'],
118
-		['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'],
119
-		['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'],
120
-		['root' => '/core', 'name' => 'AppPassword#rotateAppPassword', 'url' => '/apppassword/rotate', 'verb' => 'POST'],
121
-		['root' => '/core', 'name' => 'AppPassword#deleteAppPassword', 'url' => '/apppassword', 'verb' => 'DELETE'],
122
-
123
-		['root' => '/hovercard', 'name' => 'HoverCard#getUser', 'url' => '/v1/{userId}', 'verb' => 'GET'],
124
-
125
-		['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'],
126
-		['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'],
127
-		['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'],
128
-		['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'],
129
-
130
-		['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'],
131
-		['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'],
132
-		['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'],
133
-
134
-		['root' => '/references', 'name' => 'ReferenceApi#resolveOne', 'url' => '/resolve', 'verb' => 'GET'],
135
-		['root' => '/references', 'name' => 'ReferenceApi#extract', 'url' => '/extract', 'verb' => 'POST'],
136
-		['root' => '/references', 'name' => 'ReferenceApi#resolve', 'url' => '/resolve', 'verb' => 'POST'],
137
-		['root' => '/references', 'name' => 'ReferenceApi#getProvidersInfo', 'url' => '/providers', 'verb' => 'GET'],
138
-		['root' => '/references', 'name' => 'ReferenceApi#touchProvider', 'url' => '/provider/{providerId}', 'verb' => 'PUT'],
139
-
140
-		['root' => '/profile', 'name' => 'ProfileApi#setVisibility', 'url' => '/{targetUserId}', 'verb' => 'PUT'],
141
-
142
-		// Unified search
143
-		['root' => '/search', 'name' => 'UnifiedSearch#getProviders', 'url' => '/providers', 'verb' => 'GET'],
144
-		['root' => '/search', 'name' => 'UnifiedSearch#search', 'url' => '/providers/{providerId}/search', 'verb' => 'GET'],
145
-
146
-		['root' => '/translation', 'name' => 'TranslationApi#languages', 'url' => '/languages', 'verb' => 'GET'],
147
-		['root' => '/translation', 'name' => 'TranslationApi#translate', 'url' => '/translate', 'verb' => 'POST'],
148
-	],
42
+    'routes' => [
43
+        ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
44
+        ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
45
+        ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
46
+        ['name' => 'ProfilePage#index', 'url' => '/u/{targetUserId}', 'verb' => 'GET'],
47
+        ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
48
+        ['name' => 'avatar#getAvatarDark', 'url' => '/avatar/{userId}/{size}/dark', 'verb' => 'GET'],
49
+        ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
50
+        ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
51
+        ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
52
+        ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
53
+        ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
54
+        ['name' => 'GuestAvatar#getAvatarDark', 'url' => '/avatar/guest/{guestName}/{size}/dark', 'verb' => 'GET'],
55
+        ['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'],
56
+        ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
57
+        ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
58
+        ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
59
+        ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
60
+        ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
61
+
62
+        // Original login flow used by all clients
63
+        ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
64
+        ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
65
+        ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
66
+        ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'],
67
+
68
+        // NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example)
69
+        ['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'],
70
+        ['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'],
71
+        ['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'],
72
+        ['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'],
73
+        ['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'],
74
+        ['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'],
75
+        ['name' => 'ClientFlowLoginV2#apptokenRedirect', 'url' => '/login/v2/apptoken', 'verb' => 'POST'],
76
+        ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
77
+        ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
78
+        ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
79
+        ['name' => 'TwoFactorChallenge#setupProviders', 'url' => 'login/setupchallenge', 'verb' => 'GET'],
80
+        ['name' => 'TwoFactorChallenge#setupProvider', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'GET'],
81
+        ['name' => 'TwoFactorChallenge#confirmProviderSetup', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'POST'],
82
+        ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
83
+        ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
84
+        ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
85
+        ['name' => 'RecommendedApps#index', 'url' => '/core/apps/recommended', 'verb' => 'GET'],
86
+        ['name' => 'Reference#preview', 'url' => '/core/references/preview/{referenceId}', 'verb' => 'GET'],
87
+        ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
88
+        ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
89
+        ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
90
+        ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
91
+        ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
92
+        ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
93
+        ['name' => 'Wipe#checkWipe', 'url' => '/core/wipe/check', 'verb' => 'POST'],
94
+        ['name' => 'Wipe#wipeDone', 'url' => '/core/wipe/success', 'verb' => 'POST'],
95
+
96
+        // Logins for passwordless auth
97
+        ['name' => 'WebAuthn#startAuthentication', 'url' => 'login/webauthn/start', 'verb' => 'POST'],
98
+        ['name' => 'WebAuthn#finishAuthentication', 'url' => 'login/webauthn/finish', 'verb' => 'POST'],
99
+
100
+        ['name' => 'Error#error404', 'url' => 'error/404'],
101
+        ['name' => 'Error#error403', 'url' => 'error/403'],
102
+
103
+        // Well known requests https://tools.ietf.org/html/rfc5785
104
+        ['name' => 'WellKnown#handle', 'url' => '.well-known/{service}'],
105
+
106
+        // Unsupported browser
107
+        ['name' => 'UnsupportedBrowser#index', 'url' => 'unsupported'],
108
+    ],
109
+    'ocs' => [
110
+        ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
111
+        ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
112
+        ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
113
+        ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
114
+        ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
115
+        ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
116
+        ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
117
+        ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'],
118
+        ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'],
119
+        ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'],
120
+        ['root' => '/core', 'name' => 'AppPassword#rotateAppPassword', 'url' => '/apppassword/rotate', 'verb' => 'POST'],
121
+        ['root' => '/core', 'name' => 'AppPassword#deleteAppPassword', 'url' => '/apppassword', 'verb' => 'DELETE'],
122
+
123
+        ['root' => '/hovercard', 'name' => 'HoverCard#getUser', 'url' => '/v1/{userId}', 'verb' => 'GET'],
124
+
125
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'],
126
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'],
127
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'],
128
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'],
129
+
130
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'],
131
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'],
132
+        ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'],
133
+
134
+        ['root' => '/references', 'name' => 'ReferenceApi#resolveOne', 'url' => '/resolve', 'verb' => 'GET'],
135
+        ['root' => '/references', 'name' => 'ReferenceApi#extract', 'url' => '/extract', 'verb' => 'POST'],
136
+        ['root' => '/references', 'name' => 'ReferenceApi#resolve', 'url' => '/resolve', 'verb' => 'POST'],
137
+        ['root' => '/references', 'name' => 'ReferenceApi#getProvidersInfo', 'url' => '/providers', 'verb' => 'GET'],
138
+        ['root' => '/references', 'name' => 'ReferenceApi#touchProvider', 'url' => '/provider/{providerId}', 'verb' => 'PUT'],
139
+
140
+        ['root' => '/profile', 'name' => 'ProfileApi#setVisibility', 'url' => '/{targetUserId}', 'verb' => 'PUT'],
141
+
142
+        // Unified search
143
+        ['root' => '/search', 'name' => 'UnifiedSearch#getProviders', 'url' => '/providers', 'verb' => 'GET'],
144
+        ['root' => '/search', 'name' => 'UnifiedSearch#search', 'url' => '/providers/{providerId}/search', 'verb' => 'GET'],
145
+
146
+        ['root' => '/translation', 'name' => 'TranslationApi#languages', 'url' => '/languages', 'verb' => 'GET'],
147
+        ['root' => '/translation', 'name' => 'TranslationApi#translate', 'url' => '/translate', 'verb' => 'POST'],
148
+    ],
149 149
 ]);
150 150
 
151 151
 // Post installation check
@@ -154,4 +154,4 @@  discard block
 block discarded – undo
154 154
 // Core ajax actions
155 155
 // Routing
156 156
 $this->create('core_ajax_update', '/core/ajax/update.php')
157
-	->actionInclude('core/ajax/update.php');
157
+    ->actionInclude('core/ajax/update.php');
Please login to merge, or discard this patch.
lib/public/Translation/ITranslationProvider.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@
 block discarded – undo
32 32
  * @since 26.0.0
33 33
  */
34 34
 interface ITranslationProvider {
35
-	/**
36
-	 * @since 26.0.0
37
-	 */
38
-	public function getName(): string;
39
-
40
-	/**
41
-	 * @since 26.0.0
42
-	 */
43
-	public function getAvailableLanguages(): array;
44
-
45
-	/**
46
-	 * @since 26.0.0
47
-	 * @throws RuntimeException If the text could not be translated
48
-	 */
49
-	public function translate(?string $fromLanguage, string $toLanguage, string $text): string;
35
+    /**
36
+     * @since 26.0.0
37
+     */
38
+    public function getName(): string;
39
+
40
+    /**
41
+     * @since 26.0.0
42
+     */
43
+    public function getAvailableLanguages(): array;
44
+
45
+    /**
46
+     * @since 26.0.0
47
+     * @throws RuntimeException If the text could not be translated
48
+     */
49
+    public function translate(?string $fromLanguage, string $toLanguage, string $text): string;
50 50
 }
Please login to merge, or discard this patch.
lib/public/Translation/IDetectLanguageProvider.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@
 block discarded – undo
30 30
  * @since 26.0.0
31 31
  */
32 32
 interface IDetectLanguageProvider {
33
-	/**
34
-	 * Try to detect the language of a given string
35
-	 *
36
-	 * @since 26.0.0
37
-	 */
38
-	public function detectLanguage(string $text): ?string;
33
+    /**
34
+     * Try to detect the language of a given string
35
+     *
36
+     * @since 26.0.0
37
+     */
38
+    public function detectLanguage(string $text): ?string;
39 39
 }
Please login to merge, or discard this patch.
lib/public/Translation/ITranslationManager.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -34,27 +34,27 @@
 block discarded – undo
34 34
  * @since 26.0.0
35 35
  */
36 36
 interface ITranslationManager {
37
-	/**
38
-	 * @since 26.0.0
39
-	 */
40
-	public function hasProviders(): bool;
41
-
42
-	/**
43
-	 * @since 26.0.0
44
-	 */
45
-	public function canDetectLanguage(): bool;
46
-
47
-	/**
48
-	 * @since 26.0.0
49
-	 * @return LanguageTuple[]
50
-	 */
51
-	public function getLanguages(): array;
52
-
53
-	/**
54
-	 * @since 26.0.0
55
-	 * @throws PreConditionNotMetException If no provider was registered but this method was still called
56
-	 * @throws InvalidArgumentException If no matching provider was found that can detect a language
57
-	 * @throws RuntimeException If the translation failed for other reasons
58
-	 */
59
-	public function translate(string $text, ?string $fromLanguage, string $toLanguage): string;
37
+    /**
38
+     * @since 26.0.0
39
+     */
40
+    public function hasProviders(): bool;
41
+
42
+    /**
43
+     * @since 26.0.0
44
+     */
45
+    public function canDetectLanguage(): bool;
46
+
47
+    /**
48
+     * @since 26.0.0
49
+     * @return LanguageTuple[]
50
+     */
51
+    public function getLanguages(): array;
52
+
53
+    /**
54
+     * @since 26.0.0
55
+     * @throws PreConditionNotMetException If no provider was registered but this method was still called
56
+     * @throws InvalidArgumentException If no matching provider was found that can detect a language
57
+     * @throws RuntimeException If the translation failed for other reasons
58
+     */
59
+    public function translate(string $text, ?string $fromLanguage, string $toLanguage): string;
60 60
 }
Please login to merge, or discard this patch.
lib/public/Translation/LanguageTuple.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -32,38 +32,38 @@
 block discarded – undo
32 32
  * @since 26.0.0
33 33
  */
34 34
 class LanguageTuple implements JsonSerializable {
35
-	/**
36
-	 * @since 26.0.0
37
-	 */
38
-	public function __construct(
39
-		private string $from,
40
-		private string $fromLabel,
41
-		private string $to,
42
-		private string $toLabel
43
-	) {
44
-	}
35
+    /**
36
+     * @since 26.0.0
37
+     */
38
+    public function __construct(
39
+        private string $from,
40
+        private string $fromLabel,
41
+        private string $to,
42
+        private string $toLabel
43
+    ) {
44
+    }
45 45
 
46
-	/**
47
-	 * @since 26.0.0
48
-	 */
49
-	public function jsonSerialize(): array {
50
-		return [
51
-			'from' => $this->from,
52
-			'fromLabel' => $this->fromLabel,
53
-			'to' => $this->to,
54
-			'toLabel' => $this->toLabel,
55
-		];
56
-	}
46
+    /**
47
+     * @since 26.0.0
48
+     */
49
+    public function jsonSerialize(): array {
50
+        return [
51
+            'from' => $this->from,
52
+            'fromLabel' => $this->fromLabel,
53
+            'to' => $this->to,
54
+            'toLabel' => $this->toLabel,
55
+        ];
56
+    }
57 57
 
58
-	/**
59
-	 * @since 26.0.0
60
-	 */
61
-	public static function fromArray(array $data): LanguageTuple {
62
-		return new self(
63
-			$data['from'],
64
-			$data['fromLabel'],
65
-			$data['to'],
66
-			$data['toLabel'],
67
-		);
68
-	}
58
+    /**
59
+     * @since 26.0.0
60
+     */
61
+    public static function fromArray(array $data): LanguageTuple {
62
+        return new self(
63
+            $data['from'],
64
+            $data['fromLabel'],
65
+            $data['to'],
66
+            $data['toLabel'],
67
+        );
68
+    }
69 69
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Bootstrap/IRegistrationContext.php 1 patch
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -48,305 +48,305 @@
 block discarded – undo
48 48
  * @see IBootstrap::register()
49 49
  */
50 50
 interface IRegistrationContext {
51
-	/**
52
-	 * @param string $capability
53
-	 * @psalm-param class-string<ICapability> $capability
54
-	 * @see IAppContainer::registerCapability
55
-	 *
56
-	 * @since 20.0.0
57
-	 */
58
-	public function registerCapability(string $capability): void;
51
+    /**
52
+     * @param string $capability
53
+     * @psalm-param class-string<ICapability> $capability
54
+     * @see IAppContainer::registerCapability
55
+     *
56
+     * @since 20.0.0
57
+     */
58
+    public function registerCapability(string $capability): void;
59 59
 
60
-	/**
61
-	 * Register an implementation of \OCP\Support\CrashReport\IReporter that
62
-	 * will receive unhandled exceptions and throwables
63
-	 *
64
-	 * @param string $reporterClass
65
-	 * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass
66
-	 * @return void
67
-	 * @since 20.0.0
68
-	 */
69
-	public function registerCrashReporter(string $reporterClass): void;
60
+    /**
61
+     * Register an implementation of \OCP\Support\CrashReport\IReporter that
62
+     * will receive unhandled exceptions and throwables
63
+     *
64
+     * @param string $reporterClass
65
+     * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass
66
+     * @return void
67
+     * @since 20.0.0
68
+     */
69
+    public function registerCrashReporter(string $reporterClass): void;
70 70
 
71
-	/**
72
-	 * Register an implementation of \OCP\Dashboard\IWidget that
73
-	 * will handle the implementation of a dashboard widget
74
-	 *
75
-	 * @param string $widgetClass
76
-	 * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass
77
-	 * @return void
78
-	 * @since 20.0.0
79
-	 */
80
-	public function registerDashboardWidget(string $widgetClass): void;
71
+    /**
72
+     * Register an implementation of \OCP\Dashboard\IWidget that
73
+     * will handle the implementation of a dashboard widget
74
+     *
75
+     * @param string $widgetClass
76
+     * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass
77
+     * @return void
78
+     * @since 20.0.0
79
+     */
80
+    public function registerDashboardWidget(string $widgetClass): void;
81 81
 
82
-	/**
83
-	 * Register a service
84
-	 *
85
-	 * @param string $name
86
-	 * @param callable $factory
87
-	 * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory
88
-	 * @param bool $shared
89
-	 *
90
-	 * @return void
91
-	 * @see IContainer::registerService()
92
-	 *
93
-	 * @since 20.0.0
94
-	 */
95
-	public function registerService(string $name, callable $factory, bool $shared = true): void;
82
+    /**
83
+     * Register a service
84
+     *
85
+     * @param string $name
86
+     * @param callable $factory
87
+     * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory
88
+     * @param bool $shared
89
+     *
90
+     * @return void
91
+     * @see IContainer::registerService()
92
+     *
93
+     * @since 20.0.0
94
+     */
95
+    public function registerService(string $name, callable $factory, bool $shared = true): void;
96 96
 
97
-	/**
98
-	 * @param string $alias
99
-	 * @psalm-param string|class-string $alias
100
-	 * @param string $target
101
-	 * @psalm-param string|class-string $target
102
-	 *
103
-	 * @return void
104
-	 * @see IContainer::registerAlias()
105
-	 *
106
-	 * @since 20.0.0
107
-	 */
108
-	public function registerServiceAlias(string $alias, string $target): void;
97
+    /**
98
+     * @param string $alias
99
+     * @psalm-param string|class-string $alias
100
+     * @param string $target
101
+     * @psalm-param string|class-string $target
102
+     *
103
+     * @return void
104
+     * @see IContainer::registerAlias()
105
+     *
106
+     * @since 20.0.0
107
+     */
108
+    public function registerServiceAlias(string $alias, string $target): void;
109 109
 
110
-	/**
111
-	 * @param string $name
112
-	 * @param mixed $value
113
-	 *
114
-	 * @return void
115
-	 * @see IContainer::registerParameter()
116
-	 *
117
-	 * @since 20.0.0
118
-	 */
119
-	public function registerParameter(string $name, $value): void;
110
+    /**
111
+     * @param string $name
112
+     * @param mixed $value
113
+     *
114
+     * @return void
115
+     * @see IContainer::registerParameter()
116
+     *
117
+     * @since 20.0.0
118
+     */
119
+    public function registerParameter(string $name, $value): void;
120 120
 
121
-	/**
122
-	 * Register a service listener
123
-	 *
124
-	 * This is equivalent to calling IEventDispatcher::addServiceListener
125
-	 *
126
-	 * @psalm-template T of \OCP\EventDispatcher\Event
127
-	 * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
128
-	 * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for
129
-	 * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
130
-	 * @psalm-param class-string<\OCP\EventDispatcher\IEventListener> $listener fully qualified class name that can be built by the DI container
131
-	 * @param int $priority The higher this value, the earlier an event
132
-	 *                      listener will be triggered in the chain (defaults to 0)
133
-	 *
134
-	 * @see IEventDispatcher::addServiceListener()
135
-	 *
136
-	 * @since 20.0.0
137
-	 */
138
-	public function registerEventListener(string $event, string $listener, int $priority = 0): void;
121
+    /**
122
+     * Register a service listener
123
+     *
124
+     * This is equivalent to calling IEventDispatcher::addServiceListener
125
+     *
126
+     * @psalm-template T of \OCP\EventDispatcher\Event
127
+     * @param string $event preferably the fully-qualified class name of the Event sub class to listen for
128
+     * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for
129
+     * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
130
+     * @psalm-param class-string<\OCP\EventDispatcher\IEventListener> $listener fully qualified class name that can be built by the DI container
131
+     * @param int $priority The higher this value, the earlier an event
132
+     *                      listener will be triggered in the chain (defaults to 0)
133
+     *
134
+     * @see IEventDispatcher::addServiceListener()
135
+     *
136
+     * @since 20.0.0
137
+     */
138
+    public function registerEventListener(string $event, string $listener, int $priority = 0): void;
139 139
 
140
-	/**
141
-	 * @param string $class
142
-	 * @param bool $global load this middleware also for requests of other apps? Added in Nextcloud 26
143
-	 * @psalm-param class-string<\OCP\AppFramework\Middleware> $class
144
-	 *
145
-	 * @return void
146
-	 * @see IAppContainer::registerMiddleWare()
147
-	 *
148
-	 * @since 20.0.0
149
-	 * @since 26.0.0 Added optional argument $global
150
-	 */
151
-	public function registerMiddleware(string $class, bool $global = false): void;
140
+    /**
141
+     * @param string $class
142
+     * @param bool $global load this middleware also for requests of other apps? Added in Nextcloud 26
143
+     * @psalm-param class-string<\OCP\AppFramework\Middleware> $class
144
+     *
145
+     * @return void
146
+     * @see IAppContainer::registerMiddleWare()
147
+     *
148
+     * @since 20.0.0
149
+     * @since 26.0.0 Added optional argument $global
150
+     */
151
+    public function registerMiddleware(string $class, bool $global = false): void;
152 152
 
153
-	/**
154
-	 * Register a search provider for the unified search
155
-	 *
156
-	 * It is allowed to register more than one provider per app as the search
157
-	 * results can go into distinct sections, e.g. "Files" and "Files shared
158
-	 * with you" in the Files app.
159
-	 *
160
-	 * @param string $class
161
-	 * @psalm-param class-string<\OCP\Search\IProvider> $class
162
-	 *
163
-	 * @return void
164
-	 *
165
-	 * @since 20.0.0
166
-	 */
167
-	public function registerSearchProvider(string $class): void;
153
+    /**
154
+     * Register a search provider for the unified search
155
+     *
156
+     * It is allowed to register more than one provider per app as the search
157
+     * results can go into distinct sections, e.g. "Files" and "Files shared
158
+     * with you" in the Files app.
159
+     *
160
+     * @param string $class
161
+     * @psalm-param class-string<\OCP\Search\IProvider> $class
162
+     *
163
+     * @return void
164
+     *
165
+     * @since 20.0.0
166
+     */
167
+    public function registerSearchProvider(string $class): void;
168 168
 
169
-	/**
170
-	 * Register an alternative login option
171
-	 *
172
-	 * It is allowed to register more than one option per app.
173
-	 *
174
-	 * @param string $class
175
-	 * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class
176
-	 *
177
-	 * @return void
178
-	 *
179
-	 * @since 20.0.0
180
-	 */
181
-	public function registerAlternativeLogin(string $class): void;
169
+    /**
170
+     * Register an alternative login option
171
+     *
172
+     * It is allowed to register more than one option per app.
173
+     *
174
+     * @param string $class
175
+     * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class
176
+     *
177
+     * @return void
178
+     *
179
+     * @since 20.0.0
180
+     */
181
+    public function registerAlternativeLogin(string $class): void;
182 182
 
183
-	/**
184
-	 * Register an initialstate provider
185
-	 *
186
-	 * It is allowed to register more than one provider per app.
187
-	 *
188
-	 * @param string $class
189
-	 * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class
190
-	 *
191
-	 * @return void
192
-	 *
193
-	 * @since 21.0.0
194
-	 */
195
-	public function registerInitialStateProvider(string $class): void;
183
+    /**
184
+     * Register an initialstate provider
185
+     *
186
+     * It is allowed to register more than one provider per app.
187
+     *
188
+     * @param string $class
189
+     * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class
190
+     *
191
+     * @return void
192
+     *
193
+     * @since 21.0.0
194
+     */
195
+    public function registerInitialStateProvider(string $class): void;
196 196
 
197
-	/**
198
-	 * Register a well known protocol handler
199
-	 *
200
-	 * It is allowed to register more than one handler per app.
201
-	 *
202
-	 * @param string $class
203
-	 * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class
204
-	 *
205
-	 * @return void
206
-	 *
207
-	 * @since 21.0.0
208
-	 */
209
-	public function registerWellKnownHandler(string $class): void;
197
+    /**
198
+     * Register a well known protocol handler
199
+     *
200
+     * It is allowed to register more than one handler per app.
201
+     *
202
+     * @param string $class
203
+     * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class
204
+     *
205
+     * @return void
206
+     *
207
+     * @since 21.0.0
208
+     */
209
+    public function registerWellKnownHandler(string $class): void;
210 210
 
211
-	/**
212
-	 * Register a custom template provider class that is able to inject custom templates
213
-	 * in addition to the user defined ones
214
-	 *
215
-	 * @param string $providerClass
216
-	 * @psalm-param class-string<ICustomTemplateProvider> $providerClass
217
-	 * @since 21.0.0
218
-	 */
219
-	public function registerTemplateProvider(string $providerClass): void;
211
+    /**
212
+     * Register a custom template provider class that is able to inject custom templates
213
+     * in addition to the user defined ones
214
+     *
215
+     * @param string $providerClass
216
+     * @psalm-param class-string<ICustomTemplateProvider> $providerClass
217
+     * @since 21.0.0
218
+     */
219
+    public function registerTemplateProvider(string $providerClass): void;
220 220
 
221
-	/**
222
-	 * Register a custom translation provider class that can provide translation
223
-	 * between languages through the OCP\Translation APIs
224
-	 *
225
-	 * @param string $providerClass
226
-	 * @psalm-param class-string<ITranslationProvider> $providerClass
227
-	 * @since 21.0.0
228
-	 */
229
-	public function registerTranslationProvider(string $providerClass): void;
221
+    /**
222
+     * Register a custom translation provider class that can provide translation
223
+     * between languages through the OCP\Translation APIs
224
+     *
225
+     * @param string $providerClass
226
+     * @psalm-param class-string<ITranslationProvider> $providerClass
227
+     * @since 21.0.0
228
+     */
229
+    public function registerTranslationProvider(string $providerClass): void;
230 230
 
231
-	/**
232
-	 * Register an INotifier class
233
-	 *
234
-	 * @param string $notifierClass
235
-	 * @psalm-param class-string<INotifier> $notifierClass
236
-	 * @since 22.0.0
237
-	 */
238
-	public function registerNotifierService(string $notifierClass): void;
231
+    /**
232
+     * Register an INotifier class
233
+     *
234
+     * @param string $notifierClass
235
+     * @psalm-param class-string<INotifier> $notifierClass
236
+     * @since 22.0.0
237
+     */
238
+    public function registerNotifierService(string $notifierClass): void;
239 239
 
240
-	/**
241
-	 * Register a two-factor provider
242
-	 *
243
-	 * @param string $twoFactorProviderClass
244
-	 * @psalm-param class-string<IProvider> $twoFactorProviderClass
245
-	 * @since 22.0.0
246
-	 */
247
-	public function registerTwoFactorProvider(string $twoFactorProviderClass): void;
240
+    /**
241
+     * Register a two-factor provider
242
+     *
243
+     * @param string $twoFactorProviderClass
244
+     * @psalm-param class-string<IProvider> $twoFactorProviderClass
245
+     * @since 22.0.0
246
+     */
247
+    public function registerTwoFactorProvider(string $twoFactorProviderClass): void;
248 248
 
249
-	/**
250
-	 * Register a preview provider
251
-	 *
252
-	 * It is allowed to register more than one provider per app.
253
-	 *
254
-	 * @param string $previewProviderClass
255
-	 * @param string $mimeTypeRegex
256
-	 * @psalm-param class-string<IProviderV2> $previewProviderClass
257
-	 * @since 23.0.0
258
-	 */
259
-	public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void;
249
+    /**
250
+     * Register a preview provider
251
+     *
252
+     * It is allowed to register more than one provider per app.
253
+     *
254
+     * @param string $previewProviderClass
255
+     * @param string $mimeTypeRegex
256
+     * @psalm-param class-string<IProviderV2> $previewProviderClass
257
+     * @since 23.0.0
258
+     */
259
+    public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void;
260 260
 
261
-	/**
262
-	 * Register a calendar provider
263
-	 *
264
-	 * @param string $class
265
-	 * @psalm-param class-string<ICalendarProvider> $class
266
-	 * @since 23.0.0
267
-	 */
268
-	public function registerCalendarProvider(string $class): void;
261
+    /**
262
+     * Register a calendar provider
263
+     *
264
+     * @param string $class
265
+     * @psalm-param class-string<ICalendarProvider> $class
266
+     * @since 23.0.0
267
+     */
268
+    public function registerCalendarProvider(string $class): void;
269 269
 
270
-	/**
271
-	 * Register a reference provider
272
-	 *
273
-	 * @param string $class
274
-	 * @psalm-param class-string<IReferenceProvider> $class
275
-	 * @since 25.0.0
276
-	 */
277
-	public function registerReferenceProvider(string $class): void;
270
+    /**
271
+     * Register a reference provider
272
+     *
273
+     * @param string $class
274
+     * @psalm-param class-string<IReferenceProvider> $class
275
+     * @since 25.0.0
276
+     */
277
+    public function registerReferenceProvider(string $class): void;
278 278
 
279
-	/**
280
-	 * Register an implementation of \OCP\Profile\ILinkAction that
281
-	 * will handle the implementation of a profile link action
282
-	 *
283
-	 * @param string $actionClass
284
-	 * @psalm-param class-string<\OCP\Profile\ILinkAction> $actionClass
285
-	 * @return void
286
-	 * @since 23.0.0
287
-	 */
288
-	public function registerProfileLinkAction(string $actionClass): void;
279
+    /**
280
+     * Register an implementation of \OCP\Profile\ILinkAction that
281
+     * will handle the implementation of a profile link action
282
+     *
283
+     * @param string $actionClass
284
+     * @psalm-param class-string<\OCP\Profile\ILinkAction> $actionClass
285
+     * @return void
286
+     * @since 23.0.0
287
+     */
288
+    public function registerProfileLinkAction(string $actionClass): void;
289 289
 
290
-	/**
291
-	 * Register the backend of the Talk app
292
-	 *
293
-	 * This service must only be used by the Talk app
294
-	 *
295
-	 * @param string $backend
296
-	 * @return void
297
-	 * @since 24.0.0
298
-	 */
299
-	public function registerTalkBackend(string $backend): void;
290
+    /**
291
+     * Register the backend of the Talk app
292
+     *
293
+     * This service must only be used by the Talk app
294
+     *
295
+     * @param string $backend
296
+     * @return void
297
+     * @since 24.0.0
298
+     */
299
+    public function registerTalkBackend(string $backend): void;
300 300
 
301
-	/**
302
-	 * Register a resource backend for the DAV server
303
-	 *
304
-	 * @param string $actionClass
305
-	 * @psalm-param class-string<\OCP\Calendar\Resource\IBackend> $actionClass
306
-	 * @return void
307
-	 * @since 24.0.0
308
-	 */
309
-	public function registerCalendarResourceBackend(string $class): void;
301
+    /**
302
+     * Register a resource backend for the DAV server
303
+     *
304
+     * @param string $actionClass
305
+     * @psalm-param class-string<\OCP\Calendar\Resource\IBackend> $actionClass
306
+     * @return void
307
+     * @since 24.0.0
308
+     */
309
+    public function registerCalendarResourceBackend(string $class): void;
310 310
 
311
-	/**
312
-	 * Register a room backend for the DAV server
313
-	 *
314
-	 * @param string $actionClass
315
-	 * @psalm-param class-string<\OCP\Calendar\Room\IBackend> $actionClass
316
-	 * @return void
317
-	 * @since 24.0.0
318
-	 */
319
-	public function registerCalendarRoomBackend(string $class): void;
311
+    /**
312
+     * Register a room backend for the DAV server
313
+     *
314
+     * @param string $actionClass
315
+     * @psalm-param class-string<\OCP\Calendar\Room\IBackend> $actionClass
316
+     * @return void
317
+     * @since 24.0.0
318
+     */
319
+    public function registerCalendarRoomBackend(string $class): void;
320 320
 
321
-	/**
322
-	 * Register an implementation of \OCP\UserMigration\IMigrator that
323
-	 * will handle the implementation of a migrator
324
-	 *
325
-	 * @param string $migratorClass
326
-	 * @psalm-param class-string<\OCP\UserMigration\IMigrator> $migratorClass
327
-	 * @return void
328
-	 * @since 24.0.0
329
-	 */
330
-	public function registerUserMigrator(string $migratorClass): void;
321
+    /**
322
+     * Register an implementation of \OCP\UserMigration\IMigrator that
323
+     * will handle the implementation of a migrator
324
+     *
325
+     * @param string $migratorClass
326
+     * @psalm-param class-string<\OCP\UserMigration\IMigrator> $migratorClass
327
+     * @return void
328
+     * @since 24.0.0
329
+     */
330
+    public function registerUserMigrator(string $migratorClass): void;
331 331
 
332
-	/**
333
-	 * Announce methods of classes that may contain sensitive values, which
334
-	 * should be obfuscated before being logged.
335
-	 *
336
-	 * @param string $class
337
-	 * @param string[] $methods
338
-	 * @return void
339
-	 * @since 25.0.0
340
-	 */
341
-	public function registerSensitiveMethods(string $class, array $methods): void;
332
+    /**
333
+     * Announce methods of classes that may contain sensitive values, which
334
+     * should be obfuscated before being logged.
335
+     *
336
+     * @param string $class
337
+     * @param string[] $methods
338
+     * @return void
339
+     * @since 25.0.0
340
+     */
341
+    public function registerSensitiveMethods(string $class, array $methods): void;
342 342
 
343
-	/**
344
-	 * Register an implementation of IPublicShareTemplateProvider.
345
-	 *
346
-	 * @param string $class
347
-	 * @psalm-param class-string<\OCP\Share\IPublicShareTemplateProvider> $class
348
-	 * @return void
349
-	 * @since 26.0.0
350
-	 */
351
-	public function registerPublicShareTemplateProvider(string $class): void;
343
+    /**
344
+     * Register an implementation of IPublicShareTemplateProvider.
345
+     *
346
+     * @param string $class
347
+     * @psalm-param class-string<\OCP\Share\IPublicShareTemplateProvider> $class
348
+     * @return void
349
+     * @since 26.0.0
350
+     */
351
+    public function registerPublicShareTemplateProvider(string $class): void;
352 352
 }
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +2090 added lines, -2090 removed lines patch added patch discarded remove patch
@@ -280,2099 +280,2099 @@
 block discarded – undo
280 280
  * TODO: hookup all manager classes
281 281
  */
282 282
 class Server extends ServerContainer implements IServerContainer {
283
-	/** @var string */
284
-	private $webRoot;
285
-
286
-	/**
287
-	 * @param string $webRoot
288
-	 * @param \OC\Config $config
289
-	 */
290
-	public function __construct($webRoot, \OC\Config $config) {
291
-		parent::__construct();
292
-		$this->webRoot = $webRoot;
293
-
294
-		// To find out if we are running from CLI or not
295
-		$this->registerParameter('isCLI', \OC::$CLI);
296
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
297
-
298
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
299
-			return $c;
300
-		});
301
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
302
-			return $c;
303
-		});
304
-
305
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
306
-		/** @deprecated 19.0.0 */
307
-		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
308
-
309
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
310
-		/** @deprecated 19.0.0 */
311
-		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
312
-
313
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
314
-		/** @deprecated 19.0.0 */
315
-		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
316
-
317
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
318
-		/** @deprecated 19.0.0 */
319
-		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
320
-
321
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
322
-		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
323
-
324
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
325
-
326
-		$this->registerService(View::class, function (Server $c) {
327
-			return new View();
328
-		}, false);
329
-
330
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
331
-			return new PreviewManager(
332
-				$c->get(\OCP\IConfig::class),
333
-				$c->get(IRootFolder::class),
334
-				new \OC\Preview\Storage\Root(
335
-					$c->get(IRootFolder::class),
336
-					$c->get(SystemConfig::class)
337
-				),
338
-				$c->get(IEventDispatcher::class),
339
-				$c->get(SymfonyAdapter::class),
340
-				$c->get(GeneratorHelper::class),
341
-				$c->get(ISession::class)->get('user_id'),
342
-				$c->get(Coordinator::class),
343
-				$c->get(IServerContainer::class),
344
-				$c->get(IBinaryFinder::class),
345
-				$c->get(IMagickSupport::class)
346
-			);
347
-		});
348
-		/** @deprecated 19.0.0 */
349
-		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
350
-
351
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
352
-			return new \OC\Preview\Watcher(
353
-				new \OC\Preview\Storage\Root(
354
-					$c->get(IRootFolder::class),
355
-					$c->get(SystemConfig::class)
356
-				)
357
-			);
358
-		});
359
-
360
-		$this->registerService(IProfiler::class, function (Server $c) {
361
-			return new Profiler($c->get(SystemConfig::class));
362
-		});
363
-
364
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
365
-			$view = new View();
366
-			$util = new Encryption\Util(
367
-				$view,
368
-				$c->get(IUserManager::class),
369
-				$c->get(IGroupManager::class),
370
-				$c->get(\OCP\IConfig::class)
371
-			);
372
-			return new Encryption\Manager(
373
-				$c->get(\OCP\IConfig::class),
374
-				$c->get(LoggerInterface::class),
375
-				$c->getL10N('core'),
376
-				new View(),
377
-				$util,
378
-				new ArrayCache()
379
-			);
380
-		});
381
-		/** @deprecated 19.0.0 */
382
-		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
383
-
384
-		/** @deprecated 21.0.0 */
385
-		$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
386
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
387
-			$util = new Encryption\Util(
388
-				new View(),
389
-				$c->get(IUserManager::class),
390
-				$c->get(IGroupManager::class),
391
-				$c->get(\OCP\IConfig::class)
392
-			);
393
-			return new Encryption\File(
394
-				$util,
395
-				$c->get(IRootFolder::class),
396
-				$c->get(\OCP\Share\IManager::class)
397
-			);
398
-		});
399
-
400
-		/** @deprecated 21.0.0 */
401
-		$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
402
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
403
-			$view = new View();
404
-			$util = new Encryption\Util(
405
-				$view,
406
-				$c->get(IUserManager::class),
407
-				$c->get(IGroupManager::class),
408
-				$c->get(\OCP\IConfig::class)
409
-			);
410
-
411
-			return new Encryption\Keys\Storage(
412
-				$view,
413
-				$util,
414
-				$c->get(ICrypto::class),
415
-				$c->get(\OCP\IConfig::class)
416
-			);
417
-		});
418
-		/** @deprecated 20.0.0 */
419
-		$this->registerDeprecatedAlias('TagMapper', TagMapper::class);
420
-
421
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
422
-		/** @deprecated 19.0.0 */
423
-		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
424
-
425
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
426
-			/** @var \OCP\IConfig $config */
427
-			$config = $c->get(\OCP\IConfig::class);
428
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
429
-			return new $factoryClass($this);
430
-		});
431
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
432
-			return $c->get('SystemTagManagerFactory')->getManager();
433
-		});
434
-		/** @deprecated 19.0.0 */
435
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
436
-
437
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
438
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
439
-		});
440
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
441
-			$manager = \OC\Files\Filesystem::getMountManager(null);
442
-			$view = new View();
443
-			$root = new Root(
444
-				$manager,
445
-				$view,
446
-				null,
447
-				$c->get(IUserMountCache::class),
448
-				$this->get(LoggerInterface::class),
449
-				$this->get(IUserManager::class),
450
-				$this->get(IEventDispatcher::class),
451
-			);
452
-
453
-			$previewConnector = new \OC\Preview\WatcherConnector(
454
-				$root,
455
-				$c->get(SystemConfig::class)
456
-			);
457
-			$previewConnector->connectWatcher();
458
-
459
-			return $root;
460
-		});
461
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
462
-			return new HookConnector(
463
-				$c->get(IRootFolder::class),
464
-				new View(),
465
-				$c->get(\OC\EventDispatcher\SymfonyAdapter::class),
466
-				$c->get(IEventDispatcher::class)
467
-			);
468
-		});
469
-
470
-		/** @deprecated 19.0.0 */
471
-		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
472
-
473
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
474
-			return new LazyRoot(function () use ($c) {
475
-				return $c->get('RootFolder');
476
-			});
477
-		});
478
-		/** @deprecated 19.0.0 */
479
-		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
480
-
481
-		/** @deprecated 19.0.0 */
482
-		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
483
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
484
-
485
-		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
486
-			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
487
-		});
488
-
489
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
490
-			$groupManager = new \OC\Group\Manager(
491
-				$this->get(IUserManager::class),
492
-				$c->get(SymfonyAdapter::class),
493
-				$this->get(LoggerInterface::class),
494
-				$this->get(ICacheFactory::class)
495
-			);
496
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
497
-				/** @var IEventDispatcher $dispatcher */
498
-				$dispatcher = $this->get(IEventDispatcher::class);
499
-				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
500
-			});
501
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
502
-				/** @var IEventDispatcher $dispatcher */
503
-				$dispatcher = $this->get(IEventDispatcher::class);
504
-				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
505
-			});
506
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
507
-				/** @var IEventDispatcher $dispatcher */
508
-				$dispatcher = $this->get(IEventDispatcher::class);
509
-				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
510
-			});
511
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
512
-				/** @var IEventDispatcher $dispatcher */
513
-				$dispatcher = $this->get(IEventDispatcher::class);
514
-				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
515
-			});
516
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
517
-				/** @var IEventDispatcher $dispatcher */
518
-				$dispatcher = $this->get(IEventDispatcher::class);
519
-				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
520
-			});
521
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
522
-				/** @var IEventDispatcher $dispatcher */
523
-				$dispatcher = $this->get(IEventDispatcher::class);
524
-				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
525
-			});
526
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
527
-				/** @var IEventDispatcher $dispatcher */
528
-				$dispatcher = $this->get(IEventDispatcher::class);
529
-				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
530
-			});
531
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
532
-				/** @var IEventDispatcher $dispatcher */
533
-				$dispatcher = $this->get(IEventDispatcher::class);
534
-				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
535
-			});
536
-			return $groupManager;
537
-		});
538
-		/** @deprecated 19.0.0 */
539
-		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
540
-
541
-		$this->registerService(Store::class, function (ContainerInterface $c) {
542
-			$session = $c->get(ISession::class);
543
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
544
-				$tokenProvider = $c->get(IProvider::class);
545
-			} else {
546
-				$tokenProvider = null;
547
-			}
548
-			$logger = $c->get(LoggerInterface::class);
549
-			return new Store($session, $logger, $tokenProvider);
550
-		});
551
-		$this->registerAlias(IStore::class, Store::class);
552
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
553
-
554
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
555
-			$manager = $c->get(IUserManager::class);
556
-			$session = new \OC\Session\Memory('');
557
-			$timeFactory = new TimeFactory();
558
-			// Token providers might require a working database. This code
559
-			// might however be called when Nextcloud is not yet setup.
560
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
561
-				$provider = $c->get(IProvider::class);
562
-			} else {
563
-				$provider = null;
564
-			}
565
-
566
-			$legacyDispatcher = $c->get(SymfonyAdapter::class);
567
-
568
-			$userSession = new \OC\User\Session(
569
-				$manager,
570
-				$session,
571
-				$timeFactory,
572
-				$provider,
573
-				$c->get(\OCP\IConfig::class),
574
-				$c->get(ISecureRandom::class),
575
-				$c->getLockdownManager(),
576
-				$c->get(LoggerInterface::class),
577
-				$c->get(IEventDispatcher::class)
578
-			);
579
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
580
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
581
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
582
-			});
583
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
584
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
585
-				/** @var \OC\User\User $user */
586
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
587
-			});
588
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
589
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
590
-				/** @var \OC\User\User $user */
591
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
592
-				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
593
-			});
594
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
595
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
596
-				/** @var \OC\User\User $user */
597
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
598
-			});
599
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
600
-				/** @var \OC\User\User $user */
601
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
602
-
603
-				/** @var IEventDispatcher $dispatcher */
604
-				$dispatcher = $this->get(IEventDispatcher::class);
605
-				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
606
-			});
607
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
608
-				/** @var \OC\User\User $user */
609
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
610
-
611
-				/** @var IEventDispatcher $dispatcher */
612
-				$dispatcher = $this->get(IEventDispatcher::class);
613
-				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
614
-			});
615
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
616
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
617
-
618
-				/** @var IEventDispatcher $dispatcher */
619
-				$dispatcher = $this->get(IEventDispatcher::class);
620
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
621
-			});
622
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
623
-				/** @var \OC\User\User $user */
624
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
625
-
626
-				/** @var IEventDispatcher $dispatcher */
627
-				$dispatcher = $this->get(IEventDispatcher::class);
628
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
629
-			});
630
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
631
-				/** @var IEventDispatcher $dispatcher */
632
-				$dispatcher = $this->get(IEventDispatcher::class);
633
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
634
-			});
635
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
636
-				/** @var \OC\User\User $user */
637
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
638
-
639
-				/** @var IEventDispatcher $dispatcher */
640
-				$dispatcher = $this->get(IEventDispatcher::class);
641
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
642
-			});
643
-			$userSession->listen('\OC\User', 'logout', function ($user) {
644
-				\OC_Hook::emit('OC_User', 'logout', []);
645
-
646
-				/** @var IEventDispatcher $dispatcher */
647
-				$dispatcher = $this->get(IEventDispatcher::class);
648
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
649
-			});
650
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
651
-				/** @var IEventDispatcher $dispatcher */
652
-				$dispatcher = $this->get(IEventDispatcher::class);
653
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
654
-			});
655
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
656
-				/** @var \OC\User\User $user */
657
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
658
-
659
-				/** @var IEventDispatcher $dispatcher */
660
-				$dispatcher = $this->get(IEventDispatcher::class);
661
-				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
662
-			});
663
-			return $userSession;
664
-		});
665
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
666
-		/** @deprecated 19.0.0 */
667
-		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
668
-
669
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
670
-
671
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
672
-		/** @deprecated 19.0.0 */
673
-		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
674
-
675
-		/** @deprecated 19.0.0 */
676
-		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
677
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
678
-
679
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
680
-			return new \OC\SystemConfig($config);
681
-		});
682
-		/** @deprecated 19.0.0 */
683
-		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
684
-
685
-		/** @deprecated 19.0.0 */
686
-		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
687
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
688
-
689
-		$this->registerService(IFactory::class, function (Server $c) {
690
-			return new \OC\L10N\Factory(
691
-				$c->get(\OCP\IConfig::class),
692
-				$c->getRequest(),
693
-				$c->get(IUserSession::class),
694
-				$c->get(ICacheFactory::class),
695
-				\OC::$SERVERROOT
696
-			);
697
-		});
698
-		/** @deprecated 19.0.0 */
699
-		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
700
-
701
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
702
-		/** @deprecated 19.0.0 */
703
-		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
704
-
705
-		/** @deprecated 19.0.0 */
706
-		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
707
-		/** @deprecated 19.0.0 */
708
-		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
709
-
710
-		$this->registerService(ICache::class, function ($c) {
711
-			return new Cache\File();
712
-		});
713
-		/** @deprecated 19.0.0 */
714
-		$this->registerDeprecatedAlias('UserCache', ICache::class);
715
-
716
-		$this->registerService(Factory::class, function (Server $c) {
717
-			$profiler = $c->get(IProfiler::class);
718
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
719
-				$profiler,
720
-				ArrayCache::class,
721
-				ArrayCache::class,
722
-				ArrayCache::class
723
-			);
724
-			/** @var \OCP\IConfig $config */
725
-			$config = $c->get(\OCP\IConfig::class);
726
-
727
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
728
-				if (!$config->getSystemValueBool('log_query')) {
729
-					$v = \OC_App::getAppVersions();
730
-				} else {
731
-					// If the log_query is enabled, we can not get the app versions
732
-					// as that does a query, which will be logged and the logging
733
-					// depends on redis and here we are back again in the same function.
734
-					$v = [
735
-						'log_query' => 'enabled',
736
-					];
737
-				}
738
-				$v['core'] = implode(',', \OC_Util::getVersion());
739
-				$version = implode(',', $v);
740
-				$instanceId = \OC_Util::getInstanceId();
741
-				$path = \OC::$SERVERROOT;
742
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
743
-				return new \OC\Memcache\Factory($prefix,
744
-					$c->get(LoggerInterface::class),
745
-					$profiler,
746
-					$config->getSystemValue('memcache.local', null),
747
-					$config->getSystemValue('memcache.distributed', null),
748
-					$config->getSystemValue('memcache.locking', null),
749
-					$config->getSystemValueString('redis_log_file')
750
-				);
751
-			}
752
-			return $arrayCacheFactory;
753
-		});
754
-		/** @deprecated 19.0.0 */
755
-		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
756
-		$this->registerAlias(ICacheFactory::class, Factory::class);
757
-
758
-		$this->registerService('RedisFactory', function (Server $c) {
759
-			$systemConfig = $c->get(SystemConfig::class);
760
-			return new RedisFactory($systemConfig, $c->getEventLogger());
761
-		});
762
-
763
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
764
-			$l10n = $this->get(IFactory::class)->get('lib');
765
-			return new \OC\Activity\Manager(
766
-				$c->getRequest(),
767
-				$c->get(IUserSession::class),
768
-				$c->get(\OCP\IConfig::class),
769
-				$c->get(IValidator::class),
770
-				$l10n
771
-			);
772
-		});
773
-		/** @deprecated 19.0.0 */
774
-		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
775
-
776
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
777
-			return new \OC\Activity\EventMerger(
778
-				$c->getL10N('lib')
779
-			);
780
-		});
781
-		$this->registerAlias(IValidator::class, Validator::class);
782
-
783
-		$this->registerService(AvatarManager::class, function (Server $c) {
784
-			return new AvatarManager(
785
-				$c->get(IUserSession::class),
786
-				$c->get(\OC\User\Manager::class),
787
-				$c->getAppDataDir('avatar'),
788
-				$c->getL10N('lib'),
789
-				$c->get(LoggerInterface::class),
790
-				$c->get(\OCP\IConfig::class),
791
-				$c->get(IAccountManager::class),
792
-				$c->get(KnownUserService::class)
793
-			);
794
-		});
795
-
796
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
797
-		/** @deprecated 19.0.0 */
798
-		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
799
-
800
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
801
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
802
-		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
803
-
804
-		$this->registerService(\OC\Log::class, function (Server $c) {
805
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
806
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
807
-			$logger = $factory->get($logType);
808
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
809
-
810
-			return new Log($logger, $this->get(SystemConfig::class), null, $registry);
811
-		});
812
-		$this->registerAlias(ILogger::class, \OC\Log::class);
813
-		/** @deprecated 19.0.0 */
814
-		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
815
-		// PSR-3 logger
816
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
817
-
818
-		$this->registerService(ILogFactory::class, function (Server $c) {
819
-			return new LogFactory($c, $this->get(SystemConfig::class));
820
-		});
821
-
822
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
823
-		/** @deprecated 19.0.0 */
824
-		$this->registerDeprecatedAlias('JobList', IJobList::class);
825
-
826
-		$this->registerService(Router::class, function (Server $c) {
827
-			$cacheFactory = $c->get(ICacheFactory::class);
828
-			if ($cacheFactory->isLocalCacheAvailable()) {
829
-				$router = $c->resolve(CachingRouter::class);
830
-			} else {
831
-				$router = $c->resolve(Router::class);
832
-			}
833
-			return $router;
834
-		});
835
-		$this->registerAlias(IRouter::class, Router::class);
836
-		/** @deprecated 19.0.0 */
837
-		$this->registerDeprecatedAlias('Router', IRouter::class);
838
-
839
-		$this->registerAlias(ISearch::class, Search::class);
840
-		/** @deprecated 19.0.0 */
841
-		$this->registerDeprecatedAlias('Search', ISearch::class);
842
-
843
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
844
-			$cacheFactory = $c->get(ICacheFactory::class);
845
-			if ($cacheFactory->isAvailable()) {
846
-				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
847
-					$this->get(ICacheFactory::class),
848
-					new \OC\AppFramework\Utility\TimeFactory()
849
-				);
850
-			} else {
851
-				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
852
-					$c->get(IDBConnection::class),
853
-					new \OC\AppFramework\Utility\TimeFactory()
854
-				);
855
-			}
856
-
857
-			return $backend;
858
-		});
859
-
860
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
861
-		/** @deprecated 19.0.0 */
862
-		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
863
-		$this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
864
-		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
865
-
866
-		$this->registerAlias(ICrypto::class, Crypto::class);
867
-		/** @deprecated 19.0.0 */
868
-		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
869
-
870
-		$this->registerAlias(IHasher::class, Hasher::class);
871
-		/** @deprecated 19.0.0 */
872
-		$this->registerDeprecatedAlias('Hasher', IHasher::class);
873
-
874
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
875
-		/** @deprecated 19.0.0 */
876
-		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
877
-
878
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
879
-		$this->registerService(Connection::class, function (Server $c) {
880
-			$systemConfig = $c->get(SystemConfig::class);
881
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
882
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
883
-			if (!$factory->isValidType($type)) {
884
-				throw new \OC\DatabaseException('Invalid database type');
885
-			}
886
-			$connectionParams = $factory->createConnectionParams();
887
-			$connection = $factory->getConnection($type, $connectionParams);
888
-			return $connection;
889
-		});
890
-		/** @deprecated 19.0.0 */
891
-		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
892
-
893
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
894
-		$this->registerAlias(IClientService::class, ClientService::class);
895
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
896
-			return new NegativeDnsCache(
897
-				$c->get(ICacheFactory::class),
898
-			);
899
-		});
900
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
901
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
902
-			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
903
-		});
904
-		/** @deprecated 19.0.0 */
905
-		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
906
-
907
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
908
-			$queryLogger = new QueryLogger();
909
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
910
-				// In debug mode, module is being activated by default
911
-				$queryLogger->activate();
912
-			}
913
-			return $queryLogger;
914
-		});
915
-		/** @deprecated 19.0.0 */
916
-		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
917
-
918
-		/** @deprecated 19.0.0 */
919
-		$this->registerDeprecatedAlias('TempManager', TempManager::class);
920
-		$this->registerAlias(ITempManager::class, TempManager::class);
921
-
922
-		$this->registerService(AppManager::class, function (ContainerInterface $c) {
923
-			// TODO: use auto-wiring
924
-			return new \OC\App\AppManager(
925
-				$c->get(IUserSession::class),
926
-				$c->get(\OCP\IConfig::class),
927
-				$c->get(\OC\AppConfig::class),
928
-				$c->get(IGroupManager::class),
929
-				$c->get(ICacheFactory::class),
930
-				$c->get(SymfonyAdapter::class),
931
-				$c->get(LoggerInterface::class)
932
-			);
933
-		});
934
-		/** @deprecated 19.0.0 */
935
-		$this->registerDeprecatedAlias('AppManager', AppManager::class);
936
-		$this->registerAlias(IAppManager::class, AppManager::class);
937
-
938
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
939
-		/** @deprecated 19.0.0 */
940
-		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
941
-
942
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
943
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
944
-
945
-			return new DateTimeFormatter(
946
-				$c->get(IDateTimeZone::class)->getTimeZone(),
947
-				$c->getL10N('lib', $language)
948
-			);
949
-		});
950
-		/** @deprecated 19.0.0 */
951
-		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
952
-
953
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
954
-			$mountCache = $c->get(UserMountCache::class);
955
-			$listener = new UserMountCacheListener($mountCache);
956
-			$listener->listen($c->get(IUserManager::class));
957
-			return $mountCache;
958
-		});
959
-		/** @deprecated 19.0.0 */
960
-		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
961
-
962
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
963
-			$loader = $c->get(IStorageFactory::class);
964
-			$mountCache = $c->get(IUserMountCache::class);
965
-			$eventLogger = $c->get(IEventLogger::class);
966
-			$manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
967
-
968
-			// builtin providers
969
-
970
-			$config = $c->get(\OCP\IConfig::class);
971
-			$logger = $c->get(LoggerInterface::class);
972
-			$manager->registerProvider(new CacheMountProvider($config));
973
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
974
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
975
-			$manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
976
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
977
-
978
-			return $manager;
979
-		});
980
-		/** @deprecated 19.0.0 */
981
-		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
982
-
983
-		/** @deprecated 20.0.0 */
984
-		$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
985
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
986
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
987
-			if ($busClass) {
988
-				[$app, $class] = explode('::', $busClass, 2);
989
-				if ($c->get(IAppManager::class)->isInstalled($app)) {
990
-					\OC_App::loadApp($app);
991
-					return $c->get($class);
992
-				} else {
993
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
994
-				}
995
-			} else {
996
-				$jobList = $c->get(IJobList::class);
997
-				return new CronBus($jobList);
998
-			}
999
-		});
1000
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
1001
-		/** @deprecated 20.0.0 */
1002
-		$this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1003
-		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1004
-		/** @deprecated 19.0.0 */
1005
-		$this->registerDeprecatedAlias('Throttler', Throttler::class);
1006
-		$this->registerAlias(IThrottler::class, Throttler::class);
1007
-		$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1008
-			// IConfig and IAppManager requires a working database. This code
1009
-			// might however be called when ownCloud is not yet setup.
1010
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1011
-				$config = $c->get(\OCP\IConfig::class);
1012
-				$appManager = $c->get(IAppManager::class);
1013
-			} else {
1014
-				$config = null;
1015
-				$appManager = null;
1016
-			}
1017
-
1018
-			return new Checker(
1019
-				new EnvironmentHelper(),
1020
-				new FileAccessHelper(),
1021
-				new AppLocator(),
1022
-				$config,
1023
-				$c->get(ICacheFactory::class),
1024
-				$appManager,
1025
-				$c->get(IMimeTypeDetector::class)
1026
-			);
1027
-		});
1028
-		$this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1029
-			if (isset($this['urlParams'])) {
1030
-				$urlParams = $this['urlParams'];
1031
-			} else {
1032
-				$urlParams = [];
1033
-			}
1034
-
1035
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1036
-				&& in_array('fakeinput', stream_get_wrappers())
1037
-			) {
1038
-				$stream = 'fakeinput://data';
1039
-			} else {
1040
-				$stream = 'php://input';
1041
-			}
1042
-
1043
-			return new Request(
1044
-				[
1045
-					'get' => $_GET,
1046
-					'post' => $_POST,
1047
-					'files' => $_FILES,
1048
-					'server' => $_SERVER,
1049
-					'env' => $_ENV,
1050
-					'cookies' => $_COOKIE,
1051
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1052
-						? $_SERVER['REQUEST_METHOD']
1053
-						: '',
1054
-					'urlParams' => $urlParams,
1055
-				],
1056
-				$this->get(IRequestId::class),
1057
-				$this->get(\OCP\IConfig::class),
1058
-				$this->get(CsrfTokenManager::class),
1059
-				$stream
1060
-			);
1061
-		});
1062
-		/** @deprecated 19.0.0 */
1063
-		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1064
-
1065
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1066
-			return new RequestId(
1067
-				$_SERVER['UNIQUE_ID'] ?? '',
1068
-				$this->get(ISecureRandom::class)
1069
-			);
1070
-		});
1071
-
1072
-		$this->registerService(IMailer::class, function (Server $c) {
1073
-			return new Mailer(
1074
-				$c->get(\OCP\IConfig::class),
1075
-				$c->get(LoggerInterface::class),
1076
-				$c->get(Defaults::class),
1077
-				$c->get(IURLGenerator::class),
1078
-				$c->getL10N('lib'),
1079
-				$c->get(IEventDispatcher::class),
1080
-				$c->get(IFactory::class)
1081
-			);
1082
-		});
1083
-		/** @deprecated 19.0.0 */
1084
-		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1085
-
1086
-		/** @deprecated 21.0.0 */
1087
-		$this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1088
-
1089
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1090
-			$config = $c->get(\OCP\IConfig::class);
1091
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1092
-			if (is_null($factoryClass) || !class_exists($factoryClass)) {
1093
-				return new NullLDAPProviderFactory($this);
1094
-			}
1095
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1096
-			return new $factoryClass($this);
1097
-		});
1098
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1099
-			$factory = $c->get(ILDAPProviderFactory::class);
1100
-			return $factory->getLDAPProvider();
1101
-		});
1102
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1103
-			$ini = $c->get(IniGetWrapper::class);
1104
-			$config = $c->get(\OCP\IConfig::class);
1105
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1106
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1107
-				/** @var \OC\Memcache\Factory $memcacheFactory */
1108
-				$memcacheFactory = $c->get(ICacheFactory::class);
1109
-				$memcache = $memcacheFactory->createLocking('lock');
1110
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
1111
-					return new MemcacheLockingProvider($memcache, $ttl);
1112
-				}
1113
-				return new DBLockingProvider(
1114
-					$c->get(IDBConnection::class),
1115
-					new TimeFactory(),
1116
-					$ttl,
1117
-					!\OC::$CLI
1118
-				);
1119
-			}
1120
-			return new NoopLockingProvider();
1121
-		});
1122
-		/** @deprecated 19.0.0 */
1123
-		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1124
-
1125
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
1126
-			return new LockManager();
1127
-		});
1128
-
1129
-		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
1130
-		$this->registerService(SetupManager::class, function ($c) {
1131
-			// create the setupmanager through the mount manager to resolve the cyclic dependency
1132
-			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1133
-		});
1134
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1135
-		/** @deprecated 19.0.0 */
1136
-		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1137
-
1138
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1139
-			return new \OC\Files\Type\Detection(
1140
-				$c->get(IURLGenerator::class),
1141
-				$c->get(LoggerInterface::class),
1142
-				\OC::$configDir,
1143
-				\OC::$SERVERROOT . '/resources/config/'
1144
-			);
1145
-		});
1146
-		/** @deprecated 19.0.0 */
1147
-		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1148
-
1149
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
1150
-		/** @deprecated 19.0.0 */
1151
-		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1152
-		$this->registerService(BundleFetcher::class, function () {
1153
-			return new BundleFetcher($this->getL10N('lib'));
1154
-		});
1155
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1156
-		/** @deprecated 19.0.0 */
1157
-		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1158
-
1159
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1160
-			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1161
-			$manager->registerCapability(function () use ($c) {
1162
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1163
-			});
1164
-			$manager->registerCapability(function () use ($c) {
1165
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1166
-			});
1167
-			$manager->registerCapability(function () use ($c) {
1168
-				return $c->get(MetadataCapabilities::class);
1169
-			});
1170
-			return $manager;
1171
-		});
1172
-		/** @deprecated 19.0.0 */
1173
-		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1174
-
1175
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1176
-			$config = $c->get(\OCP\IConfig::class);
1177
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1178
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1179
-			$factory = new $factoryClass($this);
1180
-			$manager = $factory->getManager();
1181
-
1182
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1183
-				$manager = $c->get(IUserManager::class);
1184
-				$userDisplayName = $manager->getDisplayName($id);
1185
-				if ($userDisplayName === null) {
1186
-					$l = $c->get(IFactory::class)->get('core');
1187
-					return $l->t('Unknown user');
1188
-				}
1189
-				return $userDisplayName;
1190
-			});
1191
-
1192
-			return $manager;
1193
-		});
1194
-		/** @deprecated 19.0.0 */
1195
-		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1196
-
1197
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1198
-		$this->registerService('ThemingDefaults', function (Server $c) {
1199
-			/*
283
+    /** @var string */
284
+    private $webRoot;
285
+
286
+    /**
287
+     * @param string $webRoot
288
+     * @param \OC\Config $config
289
+     */
290
+    public function __construct($webRoot, \OC\Config $config) {
291
+        parent::__construct();
292
+        $this->webRoot = $webRoot;
293
+
294
+        // To find out if we are running from CLI or not
295
+        $this->registerParameter('isCLI', \OC::$CLI);
296
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
297
+
298
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
299
+            return $c;
300
+        });
301
+        $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
302
+            return $c;
303
+        });
304
+
305
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
306
+        /** @deprecated 19.0.0 */
307
+        $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
308
+
309
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
310
+        /** @deprecated 19.0.0 */
311
+        $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
312
+
313
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
314
+        /** @deprecated 19.0.0 */
315
+        $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
316
+
317
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
318
+        /** @deprecated 19.0.0 */
319
+        $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
320
+
321
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
322
+        $this->registerAlias(ITemplateManager::class, TemplateManager::class);
323
+
324
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
325
+
326
+        $this->registerService(View::class, function (Server $c) {
327
+            return new View();
328
+        }, false);
329
+
330
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
331
+            return new PreviewManager(
332
+                $c->get(\OCP\IConfig::class),
333
+                $c->get(IRootFolder::class),
334
+                new \OC\Preview\Storage\Root(
335
+                    $c->get(IRootFolder::class),
336
+                    $c->get(SystemConfig::class)
337
+                ),
338
+                $c->get(IEventDispatcher::class),
339
+                $c->get(SymfonyAdapter::class),
340
+                $c->get(GeneratorHelper::class),
341
+                $c->get(ISession::class)->get('user_id'),
342
+                $c->get(Coordinator::class),
343
+                $c->get(IServerContainer::class),
344
+                $c->get(IBinaryFinder::class),
345
+                $c->get(IMagickSupport::class)
346
+            );
347
+        });
348
+        /** @deprecated 19.0.0 */
349
+        $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
350
+
351
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
352
+            return new \OC\Preview\Watcher(
353
+                new \OC\Preview\Storage\Root(
354
+                    $c->get(IRootFolder::class),
355
+                    $c->get(SystemConfig::class)
356
+                )
357
+            );
358
+        });
359
+
360
+        $this->registerService(IProfiler::class, function (Server $c) {
361
+            return new Profiler($c->get(SystemConfig::class));
362
+        });
363
+
364
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
365
+            $view = new View();
366
+            $util = new Encryption\Util(
367
+                $view,
368
+                $c->get(IUserManager::class),
369
+                $c->get(IGroupManager::class),
370
+                $c->get(\OCP\IConfig::class)
371
+            );
372
+            return new Encryption\Manager(
373
+                $c->get(\OCP\IConfig::class),
374
+                $c->get(LoggerInterface::class),
375
+                $c->getL10N('core'),
376
+                new View(),
377
+                $util,
378
+                new ArrayCache()
379
+            );
380
+        });
381
+        /** @deprecated 19.0.0 */
382
+        $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
383
+
384
+        /** @deprecated 21.0.0 */
385
+        $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
386
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
387
+            $util = new Encryption\Util(
388
+                new View(),
389
+                $c->get(IUserManager::class),
390
+                $c->get(IGroupManager::class),
391
+                $c->get(\OCP\IConfig::class)
392
+            );
393
+            return new Encryption\File(
394
+                $util,
395
+                $c->get(IRootFolder::class),
396
+                $c->get(\OCP\Share\IManager::class)
397
+            );
398
+        });
399
+
400
+        /** @deprecated 21.0.0 */
401
+        $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
402
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
403
+            $view = new View();
404
+            $util = new Encryption\Util(
405
+                $view,
406
+                $c->get(IUserManager::class),
407
+                $c->get(IGroupManager::class),
408
+                $c->get(\OCP\IConfig::class)
409
+            );
410
+
411
+            return new Encryption\Keys\Storage(
412
+                $view,
413
+                $util,
414
+                $c->get(ICrypto::class),
415
+                $c->get(\OCP\IConfig::class)
416
+            );
417
+        });
418
+        /** @deprecated 20.0.0 */
419
+        $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
420
+
421
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
422
+        /** @deprecated 19.0.0 */
423
+        $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
424
+
425
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
426
+            /** @var \OCP\IConfig $config */
427
+            $config = $c->get(\OCP\IConfig::class);
428
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
429
+            return new $factoryClass($this);
430
+        });
431
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
432
+            return $c->get('SystemTagManagerFactory')->getManager();
433
+        });
434
+        /** @deprecated 19.0.0 */
435
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
436
+
437
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
438
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
439
+        });
440
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
441
+            $manager = \OC\Files\Filesystem::getMountManager(null);
442
+            $view = new View();
443
+            $root = new Root(
444
+                $manager,
445
+                $view,
446
+                null,
447
+                $c->get(IUserMountCache::class),
448
+                $this->get(LoggerInterface::class),
449
+                $this->get(IUserManager::class),
450
+                $this->get(IEventDispatcher::class),
451
+            );
452
+
453
+            $previewConnector = new \OC\Preview\WatcherConnector(
454
+                $root,
455
+                $c->get(SystemConfig::class)
456
+            );
457
+            $previewConnector->connectWatcher();
458
+
459
+            return $root;
460
+        });
461
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
462
+            return new HookConnector(
463
+                $c->get(IRootFolder::class),
464
+                new View(),
465
+                $c->get(\OC\EventDispatcher\SymfonyAdapter::class),
466
+                $c->get(IEventDispatcher::class)
467
+            );
468
+        });
469
+
470
+        /** @deprecated 19.0.0 */
471
+        $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
472
+
473
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
474
+            return new LazyRoot(function () use ($c) {
475
+                return $c->get('RootFolder');
476
+            });
477
+        });
478
+        /** @deprecated 19.0.0 */
479
+        $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
480
+
481
+        /** @deprecated 19.0.0 */
482
+        $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
483
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
484
+
485
+        $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
486
+            return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
487
+        });
488
+
489
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
490
+            $groupManager = new \OC\Group\Manager(
491
+                $this->get(IUserManager::class),
492
+                $c->get(SymfonyAdapter::class),
493
+                $this->get(LoggerInterface::class),
494
+                $this->get(ICacheFactory::class)
495
+            );
496
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
497
+                /** @var IEventDispatcher $dispatcher */
498
+                $dispatcher = $this->get(IEventDispatcher::class);
499
+                $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
500
+            });
501
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
502
+                /** @var IEventDispatcher $dispatcher */
503
+                $dispatcher = $this->get(IEventDispatcher::class);
504
+                $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
505
+            });
506
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
507
+                /** @var IEventDispatcher $dispatcher */
508
+                $dispatcher = $this->get(IEventDispatcher::class);
509
+                $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
510
+            });
511
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
512
+                /** @var IEventDispatcher $dispatcher */
513
+                $dispatcher = $this->get(IEventDispatcher::class);
514
+                $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
515
+            });
516
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
517
+                /** @var IEventDispatcher $dispatcher */
518
+                $dispatcher = $this->get(IEventDispatcher::class);
519
+                $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
520
+            });
521
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
522
+                /** @var IEventDispatcher $dispatcher */
523
+                $dispatcher = $this->get(IEventDispatcher::class);
524
+                $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
525
+            });
526
+            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
527
+                /** @var IEventDispatcher $dispatcher */
528
+                $dispatcher = $this->get(IEventDispatcher::class);
529
+                $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
530
+            });
531
+            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
532
+                /** @var IEventDispatcher $dispatcher */
533
+                $dispatcher = $this->get(IEventDispatcher::class);
534
+                $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
535
+            });
536
+            return $groupManager;
537
+        });
538
+        /** @deprecated 19.0.0 */
539
+        $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
540
+
541
+        $this->registerService(Store::class, function (ContainerInterface $c) {
542
+            $session = $c->get(ISession::class);
543
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
544
+                $tokenProvider = $c->get(IProvider::class);
545
+            } else {
546
+                $tokenProvider = null;
547
+            }
548
+            $logger = $c->get(LoggerInterface::class);
549
+            return new Store($session, $logger, $tokenProvider);
550
+        });
551
+        $this->registerAlias(IStore::class, Store::class);
552
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
553
+
554
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
555
+            $manager = $c->get(IUserManager::class);
556
+            $session = new \OC\Session\Memory('');
557
+            $timeFactory = new TimeFactory();
558
+            // Token providers might require a working database. This code
559
+            // might however be called when Nextcloud is not yet setup.
560
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
561
+                $provider = $c->get(IProvider::class);
562
+            } else {
563
+                $provider = null;
564
+            }
565
+
566
+            $legacyDispatcher = $c->get(SymfonyAdapter::class);
567
+
568
+            $userSession = new \OC\User\Session(
569
+                $manager,
570
+                $session,
571
+                $timeFactory,
572
+                $provider,
573
+                $c->get(\OCP\IConfig::class),
574
+                $c->get(ISecureRandom::class),
575
+                $c->getLockdownManager(),
576
+                $c->get(LoggerInterface::class),
577
+                $c->get(IEventDispatcher::class)
578
+            );
579
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
580
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
581
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
582
+            });
583
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
584
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
585
+                /** @var \OC\User\User $user */
586
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
587
+            });
588
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
589
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
590
+                /** @var \OC\User\User $user */
591
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
592
+                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
593
+            });
594
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
595
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
596
+                /** @var \OC\User\User $user */
597
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
598
+            });
599
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
600
+                /** @var \OC\User\User $user */
601
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
602
+
603
+                /** @var IEventDispatcher $dispatcher */
604
+                $dispatcher = $this->get(IEventDispatcher::class);
605
+                $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
606
+            });
607
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
608
+                /** @var \OC\User\User $user */
609
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
610
+
611
+                /** @var IEventDispatcher $dispatcher */
612
+                $dispatcher = $this->get(IEventDispatcher::class);
613
+                $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
614
+            });
615
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
616
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
617
+
618
+                /** @var IEventDispatcher $dispatcher */
619
+                $dispatcher = $this->get(IEventDispatcher::class);
620
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
621
+            });
622
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
623
+                /** @var \OC\User\User $user */
624
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
625
+
626
+                /** @var IEventDispatcher $dispatcher */
627
+                $dispatcher = $this->get(IEventDispatcher::class);
628
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
629
+            });
630
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
631
+                /** @var IEventDispatcher $dispatcher */
632
+                $dispatcher = $this->get(IEventDispatcher::class);
633
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
634
+            });
635
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
636
+                /** @var \OC\User\User $user */
637
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
638
+
639
+                /** @var IEventDispatcher $dispatcher */
640
+                $dispatcher = $this->get(IEventDispatcher::class);
641
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
642
+            });
643
+            $userSession->listen('\OC\User', 'logout', function ($user) {
644
+                \OC_Hook::emit('OC_User', 'logout', []);
645
+
646
+                /** @var IEventDispatcher $dispatcher */
647
+                $dispatcher = $this->get(IEventDispatcher::class);
648
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
649
+            });
650
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
651
+                /** @var IEventDispatcher $dispatcher */
652
+                $dispatcher = $this->get(IEventDispatcher::class);
653
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
654
+            });
655
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
656
+                /** @var \OC\User\User $user */
657
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
658
+
659
+                /** @var IEventDispatcher $dispatcher */
660
+                $dispatcher = $this->get(IEventDispatcher::class);
661
+                $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
662
+            });
663
+            return $userSession;
664
+        });
665
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
666
+        /** @deprecated 19.0.0 */
667
+        $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
668
+
669
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
670
+
671
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
672
+        /** @deprecated 19.0.0 */
673
+        $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
674
+
675
+        /** @deprecated 19.0.0 */
676
+        $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
677
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
678
+
679
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
680
+            return new \OC\SystemConfig($config);
681
+        });
682
+        /** @deprecated 19.0.0 */
683
+        $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
684
+
685
+        /** @deprecated 19.0.0 */
686
+        $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
687
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
688
+
689
+        $this->registerService(IFactory::class, function (Server $c) {
690
+            return new \OC\L10N\Factory(
691
+                $c->get(\OCP\IConfig::class),
692
+                $c->getRequest(),
693
+                $c->get(IUserSession::class),
694
+                $c->get(ICacheFactory::class),
695
+                \OC::$SERVERROOT
696
+            );
697
+        });
698
+        /** @deprecated 19.0.0 */
699
+        $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
700
+
701
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
702
+        /** @deprecated 19.0.0 */
703
+        $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
704
+
705
+        /** @deprecated 19.0.0 */
706
+        $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
707
+        /** @deprecated 19.0.0 */
708
+        $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
709
+
710
+        $this->registerService(ICache::class, function ($c) {
711
+            return new Cache\File();
712
+        });
713
+        /** @deprecated 19.0.0 */
714
+        $this->registerDeprecatedAlias('UserCache', ICache::class);
715
+
716
+        $this->registerService(Factory::class, function (Server $c) {
717
+            $profiler = $c->get(IProfiler::class);
718
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
719
+                $profiler,
720
+                ArrayCache::class,
721
+                ArrayCache::class,
722
+                ArrayCache::class
723
+            );
724
+            /** @var \OCP\IConfig $config */
725
+            $config = $c->get(\OCP\IConfig::class);
726
+
727
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
728
+                if (!$config->getSystemValueBool('log_query')) {
729
+                    $v = \OC_App::getAppVersions();
730
+                } else {
731
+                    // If the log_query is enabled, we can not get the app versions
732
+                    // as that does a query, which will be logged and the logging
733
+                    // depends on redis and here we are back again in the same function.
734
+                    $v = [
735
+                        'log_query' => 'enabled',
736
+                    ];
737
+                }
738
+                $v['core'] = implode(',', \OC_Util::getVersion());
739
+                $version = implode(',', $v);
740
+                $instanceId = \OC_Util::getInstanceId();
741
+                $path = \OC::$SERVERROOT;
742
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
743
+                return new \OC\Memcache\Factory($prefix,
744
+                    $c->get(LoggerInterface::class),
745
+                    $profiler,
746
+                    $config->getSystemValue('memcache.local', null),
747
+                    $config->getSystemValue('memcache.distributed', null),
748
+                    $config->getSystemValue('memcache.locking', null),
749
+                    $config->getSystemValueString('redis_log_file')
750
+                );
751
+            }
752
+            return $arrayCacheFactory;
753
+        });
754
+        /** @deprecated 19.0.0 */
755
+        $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
756
+        $this->registerAlias(ICacheFactory::class, Factory::class);
757
+
758
+        $this->registerService('RedisFactory', function (Server $c) {
759
+            $systemConfig = $c->get(SystemConfig::class);
760
+            return new RedisFactory($systemConfig, $c->getEventLogger());
761
+        });
762
+
763
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
764
+            $l10n = $this->get(IFactory::class)->get('lib');
765
+            return new \OC\Activity\Manager(
766
+                $c->getRequest(),
767
+                $c->get(IUserSession::class),
768
+                $c->get(\OCP\IConfig::class),
769
+                $c->get(IValidator::class),
770
+                $l10n
771
+            );
772
+        });
773
+        /** @deprecated 19.0.0 */
774
+        $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
775
+
776
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
777
+            return new \OC\Activity\EventMerger(
778
+                $c->getL10N('lib')
779
+            );
780
+        });
781
+        $this->registerAlias(IValidator::class, Validator::class);
782
+
783
+        $this->registerService(AvatarManager::class, function (Server $c) {
784
+            return new AvatarManager(
785
+                $c->get(IUserSession::class),
786
+                $c->get(\OC\User\Manager::class),
787
+                $c->getAppDataDir('avatar'),
788
+                $c->getL10N('lib'),
789
+                $c->get(LoggerInterface::class),
790
+                $c->get(\OCP\IConfig::class),
791
+                $c->get(IAccountManager::class),
792
+                $c->get(KnownUserService::class)
793
+            );
794
+        });
795
+
796
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
797
+        /** @deprecated 19.0.0 */
798
+        $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
799
+
800
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
801
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
802
+        $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
803
+
804
+        $this->registerService(\OC\Log::class, function (Server $c) {
805
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
806
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
807
+            $logger = $factory->get($logType);
808
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
809
+
810
+            return new Log($logger, $this->get(SystemConfig::class), null, $registry);
811
+        });
812
+        $this->registerAlias(ILogger::class, \OC\Log::class);
813
+        /** @deprecated 19.0.0 */
814
+        $this->registerDeprecatedAlias('Logger', \OC\Log::class);
815
+        // PSR-3 logger
816
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
817
+
818
+        $this->registerService(ILogFactory::class, function (Server $c) {
819
+            return new LogFactory($c, $this->get(SystemConfig::class));
820
+        });
821
+
822
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
823
+        /** @deprecated 19.0.0 */
824
+        $this->registerDeprecatedAlias('JobList', IJobList::class);
825
+
826
+        $this->registerService(Router::class, function (Server $c) {
827
+            $cacheFactory = $c->get(ICacheFactory::class);
828
+            if ($cacheFactory->isLocalCacheAvailable()) {
829
+                $router = $c->resolve(CachingRouter::class);
830
+            } else {
831
+                $router = $c->resolve(Router::class);
832
+            }
833
+            return $router;
834
+        });
835
+        $this->registerAlias(IRouter::class, Router::class);
836
+        /** @deprecated 19.0.0 */
837
+        $this->registerDeprecatedAlias('Router', IRouter::class);
838
+
839
+        $this->registerAlias(ISearch::class, Search::class);
840
+        /** @deprecated 19.0.0 */
841
+        $this->registerDeprecatedAlias('Search', ISearch::class);
842
+
843
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
844
+            $cacheFactory = $c->get(ICacheFactory::class);
845
+            if ($cacheFactory->isAvailable()) {
846
+                $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
847
+                    $this->get(ICacheFactory::class),
848
+                    new \OC\AppFramework\Utility\TimeFactory()
849
+                );
850
+            } else {
851
+                $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
852
+                    $c->get(IDBConnection::class),
853
+                    new \OC\AppFramework\Utility\TimeFactory()
854
+                );
855
+            }
856
+
857
+            return $backend;
858
+        });
859
+
860
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
861
+        /** @deprecated 19.0.0 */
862
+        $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
863
+        $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
864
+        $this->registerAlias(IVerificationToken::class, VerificationToken::class);
865
+
866
+        $this->registerAlias(ICrypto::class, Crypto::class);
867
+        /** @deprecated 19.0.0 */
868
+        $this->registerDeprecatedAlias('Crypto', ICrypto::class);
869
+
870
+        $this->registerAlias(IHasher::class, Hasher::class);
871
+        /** @deprecated 19.0.0 */
872
+        $this->registerDeprecatedAlias('Hasher', IHasher::class);
873
+
874
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
875
+        /** @deprecated 19.0.0 */
876
+        $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
877
+
878
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
879
+        $this->registerService(Connection::class, function (Server $c) {
880
+            $systemConfig = $c->get(SystemConfig::class);
881
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
882
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
883
+            if (!$factory->isValidType($type)) {
884
+                throw new \OC\DatabaseException('Invalid database type');
885
+            }
886
+            $connectionParams = $factory->createConnectionParams();
887
+            $connection = $factory->getConnection($type, $connectionParams);
888
+            return $connection;
889
+        });
890
+        /** @deprecated 19.0.0 */
891
+        $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
892
+
893
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
894
+        $this->registerAlias(IClientService::class, ClientService::class);
895
+        $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
896
+            return new NegativeDnsCache(
897
+                $c->get(ICacheFactory::class),
898
+            );
899
+        });
900
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
901
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
902
+            return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
903
+        });
904
+        /** @deprecated 19.0.0 */
905
+        $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
906
+
907
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
908
+            $queryLogger = new QueryLogger();
909
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
910
+                // In debug mode, module is being activated by default
911
+                $queryLogger->activate();
912
+            }
913
+            return $queryLogger;
914
+        });
915
+        /** @deprecated 19.0.0 */
916
+        $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
917
+
918
+        /** @deprecated 19.0.0 */
919
+        $this->registerDeprecatedAlias('TempManager', TempManager::class);
920
+        $this->registerAlias(ITempManager::class, TempManager::class);
921
+
922
+        $this->registerService(AppManager::class, function (ContainerInterface $c) {
923
+            // TODO: use auto-wiring
924
+            return new \OC\App\AppManager(
925
+                $c->get(IUserSession::class),
926
+                $c->get(\OCP\IConfig::class),
927
+                $c->get(\OC\AppConfig::class),
928
+                $c->get(IGroupManager::class),
929
+                $c->get(ICacheFactory::class),
930
+                $c->get(SymfonyAdapter::class),
931
+                $c->get(LoggerInterface::class)
932
+            );
933
+        });
934
+        /** @deprecated 19.0.0 */
935
+        $this->registerDeprecatedAlias('AppManager', AppManager::class);
936
+        $this->registerAlias(IAppManager::class, AppManager::class);
937
+
938
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
939
+        /** @deprecated 19.0.0 */
940
+        $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
941
+
942
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
943
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
944
+
945
+            return new DateTimeFormatter(
946
+                $c->get(IDateTimeZone::class)->getTimeZone(),
947
+                $c->getL10N('lib', $language)
948
+            );
949
+        });
950
+        /** @deprecated 19.0.0 */
951
+        $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
952
+
953
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
954
+            $mountCache = $c->get(UserMountCache::class);
955
+            $listener = new UserMountCacheListener($mountCache);
956
+            $listener->listen($c->get(IUserManager::class));
957
+            return $mountCache;
958
+        });
959
+        /** @deprecated 19.0.0 */
960
+        $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
961
+
962
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
963
+            $loader = $c->get(IStorageFactory::class);
964
+            $mountCache = $c->get(IUserMountCache::class);
965
+            $eventLogger = $c->get(IEventLogger::class);
966
+            $manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
967
+
968
+            // builtin providers
969
+
970
+            $config = $c->get(\OCP\IConfig::class);
971
+            $logger = $c->get(LoggerInterface::class);
972
+            $manager->registerProvider(new CacheMountProvider($config));
973
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
974
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
975
+            $manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
976
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
977
+
978
+            return $manager;
979
+        });
980
+        /** @deprecated 19.0.0 */
981
+        $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
982
+
983
+        /** @deprecated 20.0.0 */
984
+        $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
985
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
986
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
987
+            if ($busClass) {
988
+                [$app, $class] = explode('::', $busClass, 2);
989
+                if ($c->get(IAppManager::class)->isInstalled($app)) {
990
+                    \OC_App::loadApp($app);
991
+                    return $c->get($class);
992
+                } else {
993
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
994
+                }
995
+            } else {
996
+                $jobList = $c->get(IJobList::class);
997
+                return new CronBus($jobList);
998
+            }
999
+        });
1000
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
1001
+        /** @deprecated 20.0.0 */
1002
+        $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
1003
+        $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
1004
+        /** @deprecated 19.0.0 */
1005
+        $this->registerDeprecatedAlias('Throttler', Throttler::class);
1006
+        $this->registerAlias(IThrottler::class, Throttler::class);
1007
+        $this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
1008
+            // IConfig and IAppManager requires a working database. This code
1009
+            // might however be called when ownCloud is not yet setup.
1010
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
1011
+                $config = $c->get(\OCP\IConfig::class);
1012
+                $appManager = $c->get(IAppManager::class);
1013
+            } else {
1014
+                $config = null;
1015
+                $appManager = null;
1016
+            }
1017
+
1018
+            return new Checker(
1019
+                new EnvironmentHelper(),
1020
+                new FileAccessHelper(),
1021
+                new AppLocator(),
1022
+                $config,
1023
+                $c->get(ICacheFactory::class),
1024
+                $appManager,
1025
+                $c->get(IMimeTypeDetector::class)
1026
+            );
1027
+        });
1028
+        $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
1029
+            if (isset($this['urlParams'])) {
1030
+                $urlParams = $this['urlParams'];
1031
+            } else {
1032
+                $urlParams = [];
1033
+            }
1034
+
1035
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
1036
+                && in_array('fakeinput', stream_get_wrappers())
1037
+            ) {
1038
+                $stream = 'fakeinput://data';
1039
+            } else {
1040
+                $stream = 'php://input';
1041
+            }
1042
+
1043
+            return new Request(
1044
+                [
1045
+                    'get' => $_GET,
1046
+                    'post' => $_POST,
1047
+                    'files' => $_FILES,
1048
+                    'server' => $_SERVER,
1049
+                    'env' => $_ENV,
1050
+                    'cookies' => $_COOKIE,
1051
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1052
+                        ? $_SERVER['REQUEST_METHOD']
1053
+                        : '',
1054
+                    'urlParams' => $urlParams,
1055
+                ],
1056
+                $this->get(IRequestId::class),
1057
+                $this->get(\OCP\IConfig::class),
1058
+                $this->get(CsrfTokenManager::class),
1059
+                $stream
1060
+            );
1061
+        });
1062
+        /** @deprecated 19.0.0 */
1063
+        $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1064
+
1065
+        $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
1066
+            return new RequestId(
1067
+                $_SERVER['UNIQUE_ID'] ?? '',
1068
+                $this->get(ISecureRandom::class)
1069
+            );
1070
+        });
1071
+
1072
+        $this->registerService(IMailer::class, function (Server $c) {
1073
+            return new Mailer(
1074
+                $c->get(\OCP\IConfig::class),
1075
+                $c->get(LoggerInterface::class),
1076
+                $c->get(Defaults::class),
1077
+                $c->get(IURLGenerator::class),
1078
+                $c->getL10N('lib'),
1079
+                $c->get(IEventDispatcher::class),
1080
+                $c->get(IFactory::class)
1081
+            );
1082
+        });
1083
+        /** @deprecated 19.0.0 */
1084
+        $this->registerDeprecatedAlias('Mailer', IMailer::class);
1085
+
1086
+        /** @deprecated 21.0.0 */
1087
+        $this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
1088
+
1089
+        $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
1090
+            $config = $c->get(\OCP\IConfig::class);
1091
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1092
+            if (is_null($factoryClass) || !class_exists($factoryClass)) {
1093
+                return new NullLDAPProviderFactory($this);
1094
+            }
1095
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1096
+            return new $factoryClass($this);
1097
+        });
1098
+        $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
1099
+            $factory = $c->get(ILDAPProviderFactory::class);
1100
+            return $factory->getLDAPProvider();
1101
+        });
1102
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
1103
+            $ini = $c->get(IniGetWrapper::class);
1104
+            $config = $c->get(\OCP\IConfig::class);
1105
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1106
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1107
+                /** @var \OC\Memcache\Factory $memcacheFactory */
1108
+                $memcacheFactory = $c->get(ICacheFactory::class);
1109
+                $memcache = $memcacheFactory->createLocking('lock');
1110
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
1111
+                    return new MemcacheLockingProvider($memcache, $ttl);
1112
+                }
1113
+                return new DBLockingProvider(
1114
+                    $c->get(IDBConnection::class),
1115
+                    new TimeFactory(),
1116
+                    $ttl,
1117
+                    !\OC::$CLI
1118
+                );
1119
+            }
1120
+            return new NoopLockingProvider();
1121
+        });
1122
+        /** @deprecated 19.0.0 */
1123
+        $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1124
+
1125
+        $this->registerService(ILockManager::class, function (Server $c): LockManager {
1126
+            return new LockManager();
1127
+        });
1128
+
1129
+        $this->registerAlias(ILockdownManager::class, 'LockdownManager');
1130
+        $this->registerService(SetupManager::class, function ($c) {
1131
+            // create the setupmanager through the mount manager to resolve the cyclic dependency
1132
+            return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
1133
+        });
1134
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
1135
+        /** @deprecated 19.0.0 */
1136
+        $this->registerDeprecatedAlias('MountManager', IMountManager::class);
1137
+
1138
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
1139
+            return new \OC\Files\Type\Detection(
1140
+                $c->get(IURLGenerator::class),
1141
+                $c->get(LoggerInterface::class),
1142
+                \OC::$configDir,
1143
+                \OC::$SERVERROOT . '/resources/config/'
1144
+            );
1145
+        });
1146
+        /** @deprecated 19.0.0 */
1147
+        $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1148
+
1149
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
1150
+        /** @deprecated 19.0.0 */
1151
+        $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1152
+        $this->registerService(BundleFetcher::class, function () {
1153
+            return new BundleFetcher($this->getL10N('lib'));
1154
+        });
1155
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
1156
+        /** @deprecated 19.0.0 */
1157
+        $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1158
+
1159
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
1160
+            $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
1161
+            $manager->registerCapability(function () use ($c) {
1162
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
1163
+            });
1164
+            $manager->registerCapability(function () use ($c) {
1165
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1166
+            });
1167
+            $manager->registerCapability(function () use ($c) {
1168
+                return $c->get(MetadataCapabilities::class);
1169
+            });
1170
+            return $manager;
1171
+        });
1172
+        /** @deprecated 19.0.0 */
1173
+        $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1174
+
1175
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1176
+            $config = $c->get(\OCP\IConfig::class);
1177
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1178
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1179
+            $factory = new $factoryClass($this);
1180
+            $manager = $factory->getManager();
1181
+
1182
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1183
+                $manager = $c->get(IUserManager::class);
1184
+                $userDisplayName = $manager->getDisplayName($id);
1185
+                if ($userDisplayName === null) {
1186
+                    $l = $c->get(IFactory::class)->get('core');
1187
+                    return $l->t('Unknown user');
1188
+                }
1189
+                return $userDisplayName;
1190
+            });
1191
+
1192
+            return $manager;
1193
+        });
1194
+        /** @deprecated 19.0.0 */
1195
+        $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1196
+
1197
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1198
+        $this->registerService('ThemingDefaults', function (Server $c) {
1199
+            /*
1200 1200
 			 * Dark magic for autoloader.
1201 1201
 			 * If we do a class_exists it will try to load the class which will
1202 1202
 			 * make composer cache the result. Resulting in errors when enabling
1203 1203
 			 * the theming app.
1204 1204
 			 */
1205
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1206
-			if (isset($prefixes['OCA\\Theming\\'])) {
1207
-				$classExists = true;
1208
-			} else {
1209
-				$classExists = false;
1210
-			}
1211
-
1212
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1213
-				$imageManager = new ImageManager(
1214
-					$c->get(\OCP\IConfig::class),
1215
-					$c->getAppDataDir('theming'),
1216
-					$c->get(IURLGenerator::class),
1217
-					$this->get(ICacheFactory::class),
1218
-					$this->get(ILogger::class),
1219
-					$this->get(ITempManager::class)
1220
-				);
1221
-				return new ThemingDefaults(
1222
-					$c->get(\OCP\IConfig::class),
1223
-					$c->getL10N('theming'),
1224
-					$c->get(IUserSession::class),
1225
-					$c->get(IURLGenerator::class),
1226
-					$c->get(ICacheFactory::class),
1227
-					new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1228
-					$imageManager,
1229
-					$c->get(IAppManager::class),
1230
-					$c->get(INavigationManager::class)
1231
-				);
1232
-			}
1233
-			return new \OC_Defaults();
1234
-		});
1235
-		$this->registerService(JSCombiner::class, function (Server $c) {
1236
-			return new JSCombiner(
1237
-				$c->getAppDataDir('js'),
1238
-				$c->get(IURLGenerator::class),
1239
-				$this->get(ICacheFactory::class),
1240
-				$c->get(SystemConfig::class),
1241
-				$c->get(LoggerInterface::class)
1242
-			);
1243
-		});
1244
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1245
-		/** @deprecated 19.0.0 */
1246
-		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1247
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1248
-
1249
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1250
-			// FIXME: Instantiated here due to cyclic dependency
1251
-			$request = new Request(
1252
-				[
1253
-					'get' => $_GET,
1254
-					'post' => $_POST,
1255
-					'files' => $_FILES,
1256
-					'server' => $_SERVER,
1257
-					'env' => $_ENV,
1258
-					'cookies' => $_COOKIE,
1259
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1260
-						? $_SERVER['REQUEST_METHOD']
1261
-						: null,
1262
-				],
1263
-				$c->get(IRequestId::class),
1264
-				$c->get(\OCP\IConfig::class)
1265
-			);
1266
-
1267
-			return new CryptoWrapper(
1268
-				$c->get(\OCP\IConfig::class),
1269
-				$c->get(ICrypto::class),
1270
-				$c->get(ISecureRandom::class),
1271
-				$request
1272
-			);
1273
-		});
1274
-		/** @deprecated 19.0.0 */
1275
-		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1276
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1277
-			return new SessionStorage($c->get(ISession::class));
1278
-		});
1279
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1280
-		/** @deprecated 19.0.0 */
1281
-		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1282
-
1283
-		$this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1284
-			$config = $c->get(\OCP\IConfig::class);
1285
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1286
-			/** @var \OCP\Share\IProviderFactory $factory */
1287
-			$factory = new $factoryClass($this);
1288
-
1289
-			$manager = new \OC\Share20\Manager(
1290
-				$c->get(LoggerInterface::class),
1291
-				$c->get(\OCP\IConfig::class),
1292
-				$c->get(ISecureRandom::class),
1293
-				$c->get(IHasher::class),
1294
-				$c->get(IMountManager::class),
1295
-				$c->get(IGroupManager::class),
1296
-				$c->getL10N('lib'),
1297
-				$c->get(IFactory::class),
1298
-				$factory,
1299
-				$c->get(IUserManager::class),
1300
-				$c->get(IRootFolder::class),
1301
-				$c->get(SymfonyAdapter::class),
1302
-				$c->get(IMailer::class),
1303
-				$c->get(IURLGenerator::class),
1304
-				$c->get('ThemingDefaults'),
1305
-				$c->get(IEventDispatcher::class),
1306
-				$c->get(IUserSession::class),
1307
-				$c->get(KnownUserService::class)
1308
-			);
1309
-
1310
-			return $manager;
1311
-		});
1312
-		/** @deprecated 19.0.0 */
1313
-		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1314
-
1315
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1316
-			$instance = new Collaboration\Collaborators\Search($c);
1317
-
1318
-			// register default plugins
1319
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1320
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1321
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1322
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1323
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1324
-
1325
-			return $instance;
1326
-		});
1327
-		/** @deprecated 19.0.0 */
1328
-		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1329
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1330
-
1331
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1332
-
1333
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1334
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1335
-
1336
-		$this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1337
-
1338
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1339
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1340
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1341
-			return new \OC\Files\AppData\Factory(
1342
-				$c->get(IRootFolder::class),
1343
-				$c->get(SystemConfig::class)
1344
-			);
1345
-		});
1346
-
1347
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1348
-			return new LockdownManager(function () use ($c) {
1349
-				return $c->get(ISession::class);
1350
-			});
1351
-		});
1352
-
1353
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1354
-			return new DiscoveryService(
1355
-				$c->get(ICacheFactory::class),
1356
-				$c->get(IClientService::class)
1357
-			);
1358
-		});
1359
-
1360
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1361
-			return new CloudIdManager(
1362
-				$c->get(\OCP\Contacts\IManager::class),
1363
-				$c->get(IURLGenerator::class),
1364
-				$c->get(IUserManager::class),
1365
-				$c->get(ICacheFactory::class),
1366
-				$c->get(IEventDispatcher::class),
1367
-			);
1368
-		});
1369
-
1370
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1371
-
1372
-		$this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1373
-			return new CloudFederationProviderManager(
1374
-				$c->get(IAppManager::class),
1375
-				$c->get(IClientService::class),
1376
-				$c->get(ICloudIdManager::class),
1377
-				$c->get(LoggerInterface::class)
1378
-			);
1379
-		});
1380
-
1381
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1382
-			return new CloudFederationFactory();
1383
-		});
1384
-
1385
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1386
-		/** @deprecated 19.0.0 */
1387
-		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1388
-
1389
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1390
-		/** @deprecated 19.0.0 */
1391
-		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1392
-
1393
-		$this->registerService(Defaults::class, function (Server $c) {
1394
-			return new Defaults(
1395
-				$c->getThemingDefaults()
1396
-			);
1397
-		});
1398
-		/** @deprecated 19.0.0 */
1399
-		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1400
-
1401
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1402
-			return $c->get(\OCP\IUserSession::class)->getSession();
1403
-		}, false);
1404
-
1405
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1406
-			return new ShareHelper(
1407
-				$c->get(\OCP\Share\IManager::class)
1408
-			);
1409
-		});
1410
-
1411
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1412
-			return new Installer(
1413
-				$c->get(AppFetcher::class),
1414
-				$c->get(IClientService::class),
1415
-				$c->get(ITempManager::class),
1416
-				$c->get(LoggerInterface::class),
1417
-				$c->get(\OCP\IConfig::class),
1418
-				\OC::$CLI
1419
-			);
1420
-		});
1421
-
1422
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1423
-			return new ApiFactory($c->get(IClientService::class));
1424
-		});
1425
-
1426
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1427
-			$memcacheFactory = $c->get(ICacheFactory::class);
1428
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1429
-		});
1430
-
1431
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1432
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1433
-
1434
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1435
-
1436
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1437
-
1438
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1439
-
1440
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1441
-
1442
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1443
-
1444
-		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1445
-
1446
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1447
-
1448
-		$this->registerAlias(IBroker::class, Broker::class);
1449
-
1450
-		$this->registerAlias(IMetadataManager::class, MetadataManager::class);
1451
-
1452
-		$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1453
-
1454
-		$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1455
-
1456
-		$this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1457
-
1458
-		$this->registerAlias(ITranslationManager::class, TranslationManager::class);
1459
-
1460
-		$this->connectDispatcher();
1461
-	}
1462
-
1463
-	public function boot() {
1464
-		/** @var HookConnector $hookConnector */
1465
-		$hookConnector = $this->get(HookConnector::class);
1466
-		$hookConnector->viewToNode();
1467
-	}
1468
-
1469
-	/**
1470
-	 * @return \OCP\Calendar\IManager
1471
-	 * @deprecated 20.0.0
1472
-	 */
1473
-	public function getCalendarManager() {
1474
-		return $this->get(\OC\Calendar\Manager::class);
1475
-	}
1476
-
1477
-	/**
1478
-	 * @return \OCP\Calendar\Resource\IManager
1479
-	 * @deprecated 20.0.0
1480
-	 */
1481
-	public function getCalendarResourceBackendManager() {
1482
-		return $this->get(\OC\Calendar\Resource\Manager::class);
1483
-	}
1484
-
1485
-	/**
1486
-	 * @return \OCP\Calendar\Room\IManager
1487
-	 * @deprecated 20.0.0
1488
-	 */
1489
-	public function getCalendarRoomBackendManager() {
1490
-		return $this->get(\OC\Calendar\Room\Manager::class);
1491
-	}
1492
-
1493
-	private function connectDispatcher(): void {
1494
-		/** @var IEventDispatcher $eventDispatcher */
1495
-		$eventDispatcher = $this->get(IEventDispatcher::class);
1496
-		$eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1497
-		$eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1498
-		$eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1499
-		$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1500
-	}
1501
-
1502
-	/**
1503
-	 * @return \OCP\Contacts\IManager
1504
-	 * @deprecated 20.0.0
1505
-	 */
1506
-	public function getContactsManager() {
1507
-		return $this->get(\OCP\Contacts\IManager::class);
1508
-	}
1509
-
1510
-	/**
1511
-	 * @return \OC\Encryption\Manager
1512
-	 * @deprecated 20.0.0
1513
-	 */
1514
-	public function getEncryptionManager() {
1515
-		return $this->get(\OCP\Encryption\IManager::class);
1516
-	}
1517
-
1518
-	/**
1519
-	 * @return \OC\Encryption\File
1520
-	 * @deprecated 20.0.0
1521
-	 */
1522
-	public function getEncryptionFilesHelper() {
1523
-		return $this->get(IFile::class);
1524
-	}
1525
-
1526
-	/**
1527
-	 * @return \OCP\Encryption\Keys\IStorage
1528
-	 * @deprecated 20.0.0
1529
-	 */
1530
-	public function getEncryptionKeyStorage() {
1531
-		return $this->get(IStorage::class);
1532
-	}
1533
-
1534
-	/**
1535
-	 * The current request object holding all information about the request
1536
-	 * currently being processed is returned from this method.
1537
-	 * In case the current execution was not initiated by a web request null is returned
1538
-	 *
1539
-	 * @return \OCP\IRequest
1540
-	 * @deprecated 20.0.0
1541
-	 */
1542
-	public function getRequest() {
1543
-		return $this->get(IRequest::class);
1544
-	}
1545
-
1546
-	/**
1547
-	 * Returns the preview manager which can create preview images for a given file
1548
-	 *
1549
-	 * @return IPreview
1550
-	 * @deprecated 20.0.0
1551
-	 */
1552
-	public function getPreviewManager() {
1553
-		return $this->get(IPreview::class);
1554
-	}
1555
-
1556
-	/**
1557
-	 * Returns the tag manager which can get and set tags for different object types
1558
-	 *
1559
-	 * @see \OCP\ITagManager::load()
1560
-	 * @return ITagManager
1561
-	 * @deprecated 20.0.0
1562
-	 */
1563
-	public function getTagManager() {
1564
-		return $this->get(ITagManager::class);
1565
-	}
1566
-
1567
-	/**
1568
-	 * Returns the system-tag manager
1569
-	 *
1570
-	 * @return ISystemTagManager
1571
-	 *
1572
-	 * @since 9.0.0
1573
-	 * @deprecated 20.0.0
1574
-	 */
1575
-	public function getSystemTagManager() {
1576
-		return $this->get(ISystemTagManager::class);
1577
-	}
1578
-
1579
-	/**
1580
-	 * Returns the system-tag object mapper
1581
-	 *
1582
-	 * @return ISystemTagObjectMapper
1583
-	 *
1584
-	 * @since 9.0.0
1585
-	 * @deprecated 20.0.0
1586
-	 */
1587
-	public function getSystemTagObjectMapper() {
1588
-		return $this->get(ISystemTagObjectMapper::class);
1589
-	}
1590
-
1591
-	/**
1592
-	 * Returns the avatar manager, used for avatar functionality
1593
-	 *
1594
-	 * @return IAvatarManager
1595
-	 * @deprecated 20.0.0
1596
-	 */
1597
-	public function getAvatarManager() {
1598
-		return $this->get(IAvatarManager::class);
1599
-	}
1600
-
1601
-	/**
1602
-	 * Returns the root folder of ownCloud's data directory
1603
-	 *
1604
-	 * @return IRootFolder
1605
-	 * @deprecated 20.0.0
1606
-	 */
1607
-	public function getRootFolder() {
1608
-		return $this->get(IRootFolder::class);
1609
-	}
1610
-
1611
-	/**
1612
-	 * Returns the root folder of ownCloud's data directory
1613
-	 * This is the lazy variant so this gets only initialized once it
1614
-	 * is actually used.
1615
-	 *
1616
-	 * @return IRootFolder
1617
-	 * @deprecated 20.0.0
1618
-	 */
1619
-	public function getLazyRootFolder() {
1620
-		return $this->get(IRootFolder::class);
1621
-	}
1622
-
1623
-	/**
1624
-	 * Returns a view to ownCloud's files folder
1625
-	 *
1626
-	 * @param string $userId user ID
1627
-	 * @return \OCP\Files\Folder|null
1628
-	 * @deprecated 20.0.0
1629
-	 */
1630
-	public function getUserFolder($userId = null) {
1631
-		if ($userId === null) {
1632
-			$user = $this->get(IUserSession::class)->getUser();
1633
-			if (!$user) {
1634
-				return null;
1635
-			}
1636
-			$userId = $user->getUID();
1637
-		}
1638
-		$root = $this->get(IRootFolder::class);
1639
-		return $root->getUserFolder($userId);
1640
-	}
1641
-
1642
-	/**
1643
-	 * @return \OC\User\Manager
1644
-	 * @deprecated 20.0.0
1645
-	 */
1646
-	public function getUserManager() {
1647
-		return $this->get(IUserManager::class);
1648
-	}
1649
-
1650
-	/**
1651
-	 * @return \OC\Group\Manager
1652
-	 * @deprecated 20.0.0
1653
-	 */
1654
-	public function getGroupManager() {
1655
-		return $this->get(IGroupManager::class);
1656
-	}
1657
-
1658
-	/**
1659
-	 * @return \OC\User\Session
1660
-	 * @deprecated 20.0.0
1661
-	 */
1662
-	public function getUserSession() {
1663
-		return $this->get(IUserSession::class);
1664
-	}
1665
-
1666
-	/**
1667
-	 * @return \OCP\ISession
1668
-	 * @deprecated 20.0.0
1669
-	 */
1670
-	public function getSession() {
1671
-		return $this->get(Session::class)->getSession();
1672
-	}
1673
-
1674
-	/**
1675
-	 * @param \OCP\ISession $session
1676
-	 */
1677
-	public function setSession(\OCP\ISession $session) {
1678
-		$this->get(SessionStorage::class)->setSession($session);
1679
-		$this->get(Session::class)->setSession($session);
1680
-		$this->get(Store::class)->setSession($session);
1681
-	}
1682
-
1683
-	/**
1684
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1685
-	 * @deprecated 20.0.0
1686
-	 */
1687
-	public function getTwoFactorAuthManager() {
1688
-		return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1689
-	}
1690
-
1691
-	/**
1692
-	 * @return \OC\NavigationManager
1693
-	 * @deprecated 20.0.0
1694
-	 */
1695
-	public function getNavigationManager() {
1696
-		return $this->get(INavigationManager::class);
1697
-	}
1698
-
1699
-	/**
1700
-	 * @return \OCP\IConfig
1701
-	 * @deprecated 20.0.0
1702
-	 */
1703
-	public function getConfig() {
1704
-		return $this->get(AllConfig::class);
1705
-	}
1706
-
1707
-	/**
1708
-	 * @return \OC\SystemConfig
1709
-	 * @deprecated 20.0.0
1710
-	 */
1711
-	public function getSystemConfig() {
1712
-		return $this->get(SystemConfig::class);
1713
-	}
1714
-
1715
-	/**
1716
-	 * Returns the app config manager
1717
-	 *
1718
-	 * @return IAppConfig
1719
-	 * @deprecated 20.0.0
1720
-	 */
1721
-	public function getAppConfig() {
1722
-		return $this->get(IAppConfig::class);
1723
-	}
1724
-
1725
-	/**
1726
-	 * @return IFactory
1727
-	 * @deprecated 20.0.0
1728
-	 */
1729
-	public function getL10NFactory() {
1730
-		return $this->get(IFactory::class);
1731
-	}
1732
-
1733
-	/**
1734
-	 * get an L10N instance
1735
-	 *
1736
-	 * @param string $app appid
1737
-	 * @param string $lang
1738
-	 * @return IL10N
1739
-	 * @deprecated 20.0.0
1740
-	 */
1741
-	public function getL10N($app, $lang = null) {
1742
-		return $this->get(IFactory::class)->get($app, $lang);
1743
-	}
1744
-
1745
-	/**
1746
-	 * @return IURLGenerator
1747
-	 * @deprecated 20.0.0
1748
-	 */
1749
-	public function getURLGenerator() {
1750
-		return $this->get(IURLGenerator::class);
1751
-	}
1752
-
1753
-	/**
1754
-	 * @return AppFetcher
1755
-	 * @deprecated 20.0.0
1756
-	 */
1757
-	public function getAppFetcher() {
1758
-		return $this->get(AppFetcher::class);
1759
-	}
1760
-
1761
-	/**
1762
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1763
-	 * getMemCacheFactory() instead.
1764
-	 *
1765
-	 * @return ICache
1766
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1767
-	 */
1768
-	public function getCache() {
1769
-		return $this->get(ICache::class);
1770
-	}
1771
-
1772
-	/**
1773
-	 * Returns an \OCP\CacheFactory instance
1774
-	 *
1775
-	 * @return \OCP\ICacheFactory
1776
-	 * @deprecated 20.0.0
1777
-	 */
1778
-	public function getMemCacheFactory() {
1779
-		return $this->get(ICacheFactory::class);
1780
-	}
1781
-
1782
-	/**
1783
-	 * Returns an \OC\RedisFactory instance
1784
-	 *
1785
-	 * @return \OC\RedisFactory
1786
-	 * @deprecated 20.0.0
1787
-	 */
1788
-	public function getGetRedisFactory() {
1789
-		return $this->get('RedisFactory');
1790
-	}
1791
-
1792
-
1793
-	/**
1794
-	 * Returns the current session
1795
-	 *
1796
-	 * @return \OCP\IDBConnection
1797
-	 * @deprecated 20.0.0
1798
-	 */
1799
-	public function getDatabaseConnection() {
1800
-		return $this->get(IDBConnection::class);
1801
-	}
1802
-
1803
-	/**
1804
-	 * Returns the activity manager
1805
-	 *
1806
-	 * @return \OCP\Activity\IManager
1807
-	 * @deprecated 20.0.0
1808
-	 */
1809
-	public function getActivityManager() {
1810
-		return $this->get(\OCP\Activity\IManager::class);
1811
-	}
1812
-
1813
-	/**
1814
-	 * Returns an job list for controlling background jobs
1815
-	 *
1816
-	 * @return IJobList
1817
-	 * @deprecated 20.0.0
1818
-	 */
1819
-	public function getJobList() {
1820
-		return $this->get(IJobList::class);
1821
-	}
1822
-
1823
-	/**
1824
-	 * Returns a logger instance
1825
-	 *
1826
-	 * @return ILogger
1827
-	 * @deprecated 20.0.0
1828
-	 */
1829
-	public function getLogger() {
1830
-		return $this->get(ILogger::class);
1831
-	}
1832
-
1833
-	/**
1834
-	 * @return ILogFactory
1835
-	 * @throws \OCP\AppFramework\QueryException
1836
-	 * @deprecated 20.0.0
1837
-	 */
1838
-	public function getLogFactory() {
1839
-		return $this->get(ILogFactory::class);
1840
-	}
1841
-
1842
-	/**
1843
-	 * Returns a router for generating and matching urls
1844
-	 *
1845
-	 * @return IRouter
1846
-	 * @deprecated 20.0.0
1847
-	 */
1848
-	public function getRouter() {
1849
-		return $this->get(IRouter::class);
1850
-	}
1851
-
1852
-	/**
1853
-	 * Returns a search instance
1854
-	 *
1855
-	 * @return ISearch
1856
-	 * @deprecated 20.0.0
1857
-	 */
1858
-	public function getSearch() {
1859
-		return $this->get(ISearch::class);
1860
-	}
1861
-
1862
-	/**
1863
-	 * Returns a SecureRandom instance
1864
-	 *
1865
-	 * @return \OCP\Security\ISecureRandom
1866
-	 * @deprecated 20.0.0
1867
-	 */
1868
-	public function getSecureRandom() {
1869
-		return $this->get(ISecureRandom::class);
1870
-	}
1871
-
1872
-	/**
1873
-	 * Returns a Crypto instance
1874
-	 *
1875
-	 * @return ICrypto
1876
-	 * @deprecated 20.0.0
1877
-	 */
1878
-	public function getCrypto() {
1879
-		return $this->get(ICrypto::class);
1880
-	}
1881
-
1882
-	/**
1883
-	 * Returns a Hasher instance
1884
-	 *
1885
-	 * @return IHasher
1886
-	 * @deprecated 20.0.0
1887
-	 */
1888
-	public function getHasher() {
1889
-		return $this->get(IHasher::class);
1890
-	}
1891
-
1892
-	/**
1893
-	 * Returns a CredentialsManager instance
1894
-	 *
1895
-	 * @return ICredentialsManager
1896
-	 * @deprecated 20.0.0
1897
-	 */
1898
-	public function getCredentialsManager() {
1899
-		return $this->get(ICredentialsManager::class);
1900
-	}
1901
-
1902
-	/**
1903
-	 * Get the certificate manager
1904
-	 *
1905
-	 * @return \OCP\ICertificateManager
1906
-	 */
1907
-	public function getCertificateManager() {
1908
-		return $this->get(ICertificateManager::class);
1909
-	}
1910
-
1911
-	/**
1912
-	 * Returns an instance of the HTTP client service
1913
-	 *
1914
-	 * @return IClientService
1915
-	 * @deprecated 20.0.0
1916
-	 */
1917
-	public function getHTTPClientService() {
1918
-		return $this->get(IClientService::class);
1919
-	}
1920
-
1921
-	/**
1922
-	 * Create a new event source
1923
-	 *
1924
-	 * @return \OCP\IEventSource
1925
-	 * @deprecated 20.0.0
1926
-	 */
1927
-	public function createEventSource() {
1928
-		return new \OC_EventSource();
1929
-	}
1930
-
1931
-	/**
1932
-	 * Get the active event logger
1933
-	 *
1934
-	 * The returned logger only logs data when debug mode is enabled
1935
-	 *
1936
-	 * @return IEventLogger
1937
-	 * @deprecated 20.0.0
1938
-	 */
1939
-	public function getEventLogger() {
1940
-		return $this->get(IEventLogger::class);
1941
-	}
1942
-
1943
-	/**
1944
-	 * Get the active query logger
1945
-	 *
1946
-	 * The returned logger only logs data when debug mode is enabled
1947
-	 *
1948
-	 * @return IQueryLogger
1949
-	 * @deprecated 20.0.0
1950
-	 */
1951
-	public function getQueryLogger() {
1952
-		return $this->get(IQueryLogger::class);
1953
-	}
1954
-
1955
-	/**
1956
-	 * Get the manager for temporary files and folders
1957
-	 *
1958
-	 * @return \OCP\ITempManager
1959
-	 * @deprecated 20.0.0
1960
-	 */
1961
-	public function getTempManager() {
1962
-		return $this->get(ITempManager::class);
1963
-	}
1964
-
1965
-	/**
1966
-	 * Get the app manager
1967
-	 *
1968
-	 * @return \OCP\App\IAppManager
1969
-	 * @deprecated 20.0.0
1970
-	 */
1971
-	public function getAppManager() {
1972
-		return $this->get(IAppManager::class);
1973
-	}
1974
-
1975
-	/**
1976
-	 * Creates a new mailer
1977
-	 *
1978
-	 * @return IMailer
1979
-	 * @deprecated 20.0.0
1980
-	 */
1981
-	public function getMailer() {
1982
-		return $this->get(IMailer::class);
1983
-	}
1984
-
1985
-	/**
1986
-	 * Get the webroot
1987
-	 *
1988
-	 * @return string
1989
-	 * @deprecated 20.0.0
1990
-	 */
1991
-	public function getWebRoot() {
1992
-		return $this->webRoot;
1993
-	}
1994
-
1995
-	/**
1996
-	 * @return \OC\OCSClient
1997
-	 * @deprecated 20.0.0
1998
-	 */
1999
-	public function getOcsClient() {
2000
-		return $this->get('OcsClient');
2001
-	}
2002
-
2003
-	/**
2004
-	 * @return IDateTimeZone
2005
-	 * @deprecated 20.0.0
2006
-	 */
2007
-	public function getDateTimeZone() {
2008
-		return $this->get(IDateTimeZone::class);
2009
-	}
2010
-
2011
-	/**
2012
-	 * @return IDateTimeFormatter
2013
-	 * @deprecated 20.0.0
2014
-	 */
2015
-	public function getDateTimeFormatter() {
2016
-		return $this->get(IDateTimeFormatter::class);
2017
-	}
2018
-
2019
-	/**
2020
-	 * @return IMountProviderCollection
2021
-	 * @deprecated 20.0.0
2022
-	 */
2023
-	public function getMountProviderCollection() {
2024
-		return $this->get(IMountProviderCollection::class);
2025
-	}
2026
-
2027
-	/**
2028
-	 * Get the IniWrapper
2029
-	 *
2030
-	 * @return IniGetWrapper
2031
-	 * @deprecated 20.0.0
2032
-	 */
2033
-	public function getIniWrapper() {
2034
-		return $this->get(IniGetWrapper::class);
2035
-	}
2036
-
2037
-	/**
2038
-	 * @return \OCP\Command\IBus
2039
-	 * @deprecated 20.0.0
2040
-	 */
2041
-	public function getCommandBus() {
2042
-		return $this->get(IBus::class);
2043
-	}
2044
-
2045
-	/**
2046
-	 * Get the trusted domain helper
2047
-	 *
2048
-	 * @return TrustedDomainHelper
2049
-	 * @deprecated 20.0.0
2050
-	 */
2051
-	public function getTrustedDomainHelper() {
2052
-		return $this->get(TrustedDomainHelper::class);
2053
-	}
2054
-
2055
-	/**
2056
-	 * Get the locking provider
2057
-	 *
2058
-	 * @return ILockingProvider
2059
-	 * @since 8.1.0
2060
-	 * @deprecated 20.0.0
2061
-	 */
2062
-	public function getLockingProvider() {
2063
-		return $this->get(ILockingProvider::class);
2064
-	}
2065
-
2066
-	/**
2067
-	 * @return IMountManager
2068
-	 * @deprecated 20.0.0
2069
-	 **/
2070
-	public function getMountManager() {
2071
-		return $this->get(IMountManager::class);
2072
-	}
2073
-
2074
-	/**
2075
-	 * @return IUserMountCache
2076
-	 * @deprecated 20.0.0
2077
-	 */
2078
-	public function getUserMountCache() {
2079
-		return $this->get(IUserMountCache::class);
2080
-	}
2081
-
2082
-	/**
2083
-	 * Get the MimeTypeDetector
2084
-	 *
2085
-	 * @return IMimeTypeDetector
2086
-	 * @deprecated 20.0.0
2087
-	 */
2088
-	public function getMimeTypeDetector() {
2089
-		return $this->get(IMimeTypeDetector::class);
2090
-	}
2091
-
2092
-	/**
2093
-	 * Get the MimeTypeLoader
2094
-	 *
2095
-	 * @return IMimeTypeLoader
2096
-	 * @deprecated 20.0.0
2097
-	 */
2098
-	public function getMimeTypeLoader() {
2099
-		return $this->get(IMimeTypeLoader::class);
2100
-	}
2101
-
2102
-	/**
2103
-	 * Get the manager of all the capabilities
2104
-	 *
2105
-	 * @return CapabilitiesManager
2106
-	 * @deprecated 20.0.0
2107
-	 */
2108
-	public function getCapabilitiesManager() {
2109
-		return $this->get(CapabilitiesManager::class);
2110
-	}
2111
-
2112
-	/**
2113
-	 * Get the EventDispatcher
2114
-	 *
2115
-	 * @return EventDispatcherInterface
2116
-	 * @since 8.2.0
2117
-	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2118
-	 */
2119
-	public function getEventDispatcher() {
2120
-		return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2121
-	}
2122
-
2123
-	/**
2124
-	 * Get the Notification Manager
2125
-	 *
2126
-	 * @return \OCP\Notification\IManager
2127
-	 * @since 8.2.0
2128
-	 * @deprecated 20.0.0
2129
-	 */
2130
-	public function getNotificationManager() {
2131
-		return $this->get(\OCP\Notification\IManager::class);
2132
-	}
2133
-
2134
-	/**
2135
-	 * @return ICommentsManager
2136
-	 * @deprecated 20.0.0
2137
-	 */
2138
-	public function getCommentsManager() {
2139
-		return $this->get(ICommentsManager::class);
2140
-	}
2141
-
2142
-	/**
2143
-	 * @return \OCA\Theming\ThemingDefaults
2144
-	 * @deprecated 20.0.0
2145
-	 */
2146
-	public function getThemingDefaults() {
2147
-		return $this->get('ThemingDefaults');
2148
-	}
2149
-
2150
-	/**
2151
-	 * @return \OC\IntegrityCheck\Checker
2152
-	 * @deprecated 20.0.0
2153
-	 */
2154
-	public function getIntegrityCodeChecker() {
2155
-		return $this->get('IntegrityCodeChecker');
2156
-	}
2157
-
2158
-	/**
2159
-	 * @return \OC\Session\CryptoWrapper
2160
-	 * @deprecated 20.0.0
2161
-	 */
2162
-	public function getSessionCryptoWrapper() {
2163
-		return $this->get('CryptoWrapper');
2164
-	}
2165
-
2166
-	/**
2167
-	 * @return CsrfTokenManager
2168
-	 * @deprecated 20.0.0
2169
-	 */
2170
-	public function getCsrfTokenManager() {
2171
-		return $this->get(CsrfTokenManager::class);
2172
-	}
2173
-
2174
-	/**
2175
-	 * @return Throttler
2176
-	 * @deprecated 20.0.0
2177
-	 */
2178
-	public function getBruteForceThrottler() {
2179
-		return $this->get(Throttler::class);
2180
-	}
2181
-
2182
-	/**
2183
-	 * @return IContentSecurityPolicyManager
2184
-	 * @deprecated 20.0.0
2185
-	 */
2186
-	public function getContentSecurityPolicyManager() {
2187
-		return $this->get(ContentSecurityPolicyManager::class);
2188
-	}
2189
-
2190
-	/**
2191
-	 * @return ContentSecurityPolicyNonceManager
2192
-	 * @deprecated 20.0.0
2193
-	 */
2194
-	public function getContentSecurityPolicyNonceManager() {
2195
-		return $this->get(ContentSecurityPolicyNonceManager::class);
2196
-	}
2197
-
2198
-	/**
2199
-	 * Not a public API as of 8.2, wait for 9.0
2200
-	 *
2201
-	 * @return \OCA\Files_External\Service\BackendService
2202
-	 * @deprecated 20.0.0
2203
-	 */
2204
-	public function getStoragesBackendService() {
2205
-		return $this->get(BackendService::class);
2206
-	}
2207
-
2208
-	/**
2209
-	 * Not a public API as of 8.2, wait for 9.0
2210
-	 *
2211
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
2212
-	 * @deprecated 20.0.0
2213
-	 */
2214
-	public function getGlobalStoragesService() {
2215
-		return $this->get(GlobalStoragesService::class);
2216
-	}
2217
-
2218
-	/**
2219
-	 * Not a public API as of 8.2, wait for 9.0
2220
-	 *
2221
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2222
-	 * @deprecated 20.0.0
2223
-	 */
2224
-	public function getUserGlobalStoragesService() {
2225
-		return $this->get(UserGlobalStoragesService::class);
2226
-	}
2227
-
2228
-	/**
2229
-	 * Not a public API as of 8.2, wait for 9.0
2230
-	 *
2231
-	 * @return \OCA\Files_External\Service\UserStoragesService
2232
-	 * @deprecated 20.0.0
2233
-	 */
2234
-	public function getUserStoragesService() {
2235
-		return $this->get(UserStoragesService::class);
2236
-	}
2237
-
2238
-	/**
2239
-	 * @return \OCP\Share\IManager
2240
-	 * @deprecated 20.0.0
2241
-	 */
2242
-	public function getShareManager() {
2243
-		return $this->get(\OCP\Share\IManager::class);
2244
-	}
2245
-
2246
-	/**
2247
-	 * @return \OCP\Collaboration\Collaborators\ISearch
2248
-	 * @deprecated 20.0.0
2249
-	 */
2250
-	public function getCollaboratorSearch() {
2251
-		return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2252
-	}
2253
-
2254
-	/**
2255
-	 * @return \OCP\Collaboration\AutoComplete\IManager
2256
-	 * @deprecated 20.0.0
2257
-	 */
2258
-	public function getAutoCompleteManager() {
2259
-		return $this->get(IManager::class);
2260
-	}
2261
-
2262
-	/**
2263
-	 * Returns the LDAP Provider
2264
-	 *
2265
-	 * @return \OCP\LDAP\ILDAPProvider
2266
-	 * @deprecated 20.0.0
2267
-	 */
2268
-	public function getLDAPProvider() {
2269
-		return $this->get('LDAPProvider');
2270
-	}
2271
-
2272
-	/**
2273
-	 * @return \OCP\Settings\IManager
2274
-	 * @deprecated 20.0.0
2275
-	 */
2276
-	public function getSettingsManager() {
2277
-		return $this->get(\OC\Settings\Manager::class);
2278
-	}
2279
-
2280
-	/**
2281
-	 * @return \OCP\Files\IAppData
2282
-	 * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
2283
-	 */
2284
-	public function getAppDataDir($app) {
2285
-		/** @var \OC\Files\AppData\Factory $factory */
2286
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
2287
-		return $factory->get($app);
2288
-	}
2289
-
2290
-	/**
2291
-	 * @return \OCP\Lockdown\ILockdownManager
2292
-	 * @deprecated 20.0.0
2293
-	 */
2294
-	public function getLockdownManager() {
2295
-		return $this->get('LockdownManager');
2296
-	}
2297
-
2298
-	/**
2299
-	 * @return \OCP\Federation\ICloudIdManager
2300
-	 * @deprecated 20.0.0
2301
-	 */
2302
-	public function getCloudIdManager() {
2303
-		return $this->get(ICloudIdManager::class);
2304
-	}
2305
-
2306
-	/**
2307
-	 * @return \OCP\GlobalScale\IConfig
2308
-	 * @deprecated 20.0.0
2309
-	 */
2310
-	public function getGlobalScaleConfig() {
2311
-		return $this->get(IConfig::class);
2312
-	}
2313
-
2314
-	/**
2315
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2316
-	 * @deprecated 20.0.0
2317
-	 */
2318
-	public function getCloudFederationProviderManager() {
2319
-		return $this->get(ICloudFederationProviderManager::class);
2320
-	}
2321
-
2322
-	/**
2323
-	 * @return \OCP\Remote\Api\IApiFactory
2324
-	 * @deprecated 20.0.0
2325
-	 */
2326
-	public function getRemoteApiFactory() {
2327
-		return $this->get(IApiFactory::class);
2328
-	}
2329
-
2330
-	/**
2331
-	 * @return \OCP\Federation\ICloudFederationFactory
2332
-	 * @deprecated 20.0.0
2333
-	 */
2334
-	public function getCloudFederationFactory() {
2335
-		return $this->get(ICloudFederationFactory::class);
2336
-	}
2337
-
2338
-	/**
2339
-	 * @return \OCP\Remote\IInstanceFactory
2340
-	 * @deprecated 20.0.0
2341
-	 */
2342
-	public function getRemoteInstanceFactory() {
2343
-		return $this->get(IInstanceFactory::class);
2344
-	}
2345
-
2346
-	/**
2347
-	 * @return IStorageFactory
2348
-	 * @deprecated 20.0.0
2349
-	 */
2350
-	public function getStorageFactory() {
2351
-		return $this->get(IStorageFactory::class);
2352
-	}
2353
-
2354
-	/**
2355
-	 * Get the Preview GeneratorHelper
2356
-	 *
2357
-	 * @return GeneratorHelper
2358
-	 * @since 17.0.0
2359
-	 * @deprecated 20.0.0
2360
-	 */
2361
-	public function getGeneratorHelper() {
2362
-		return $this->get(\OC\Preview\GeneratorHelper::class);
2363
-	}
2364
-
2365
-	private function registerDeprecatedAlias(string $alias, string $target) {
2366
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2367
-			try {
2368
-				/** @var LoggerInterface $logger */
2369
-				$logger = $container->get(LoggerInterface::class);
2370
-				$logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2371
-			} catch (ContainerExceptionInterface $e) {
2372
-				// Could not get logger. Continue
2373
-			}
2374
-
2375
-			return $container->get($target);
2376
-		}, false);
2377
-	}
1205
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1206
+            if (isset($prefixes['OCA\\Theming\\'])) {
1207
+                $classExists = true;
1208
+            } else {
1209
+                $classExists = false;
1210
+            }
1211
+
1212
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1213
+                $imageManager = new ImageManager(
1214
+                    $c->get(\OCP\IConfig::class),
1215
+                    $c->getAppDataDir('theming'),
1216
+                    $c->get(IURLGenerator::class),
1217
+                    $this->get(ICacheFactory::class),
1218
+                    $this->get(ILogger::class),
1219
+                    $this->get(ITempManager::class)
1220
+                );
1221
+                return new ThemingDefaults(
1222
+                    $c->get(\OCP\IConfig::class),
1223
+                    $c->getL10N('theming'),
1224
+                    $c->get(IUserSession::class),
1225
+                    $c->get(IURLGenerator::class),
1226
+                    $c->get(ICacheFactory::class),
1227
+                    new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1228
+                    $imageManager,
1229
+                    $c->get(IAppManager::class),
1230
+                    $c->get(INavigationManager::class)
1231
+                );
1232
+            }
1233
+            return new \OC_Defaults();
1234
+        });
1235
+        $this->registerService(JSCombiner::class, function (Server $c) {
1236
+            return new JSCombiner(
1237
+                $c->getAppDataDir('js'),
1238
+                $c->get(IURLGenerator::class),
1239
+                $this->get(ICacheFactory::class),
1240
+                $c->get(SystemConfig::class),
1241
+                $c->get(LoggerInterface::class)
1242
+            );
1243
+        });
1244
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1245
+        /** @deprecated 19.0.0 */
1246
+        $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1247
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1248
+
1249
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1250
+            // FIXME: Instantiated here due to cyclic dependency
1251
+            $request = new Request(
1252
+                [
1253
+                    'get' => $_GET,
1254
+                    'post' => $_POST,
1255
+                    'files' => $_FILES,
1256
+                    'server' => $_SERVER,
1257
+                    'env' => $_ENV,
1258
+                    'cookies' => $_COOKIE,
1259
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1260
+                        ? $_SERVER['REQUEST_METHOD']
1261
+                        : null,
1262
+                ],
1263
+                $c->get(IRequestId::class),
1264
+                $c->get(\OCP\IConfig::class)
1265
+            );
1266
+
1267
+            return new CryptoWrapper(
1268
+                $c->get(\OCP\IConfig::class),
1269
+                $c->get(ICrypto::class),
1270
+                $c->get(ISecureRandom::class),
1271
+                $request
1272
+            );
1273
+        });
1274
+        /** @deprecated 19.0.0 */
1275
+        $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1276
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1277
+            return new SessionStorage($c->get(ISession::class));
1278
+        });
1279
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1280
+        /** @deprecated 19.0.0 */
1281
+        $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1282
+
1283
+        $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
1284
+            $config = $c->get(\OCP\IConfig::class);
1285
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1286
+            /** @var \OCP\Share\IProviderFactory $factory */
1287
+            $factory = new $factoryClass($this);
1288
+
1289
+            $manager = new \OC\Share20\Manager(
1290
+                $c->get(LoggerInterface::class),
1291
+                $c->get(\OCP\IConfig::class),
1292
+                $c->get(ISecureRandom::class),
1293
+                $c->get(IHasher::class),
1294
+                $c->get(IMountManager::class),
1295
+                $c->get(IGroupManager::class),
1296
+                $c->getL10N('lib'),
1297
+                $c->get(IFactory::class),
1298
+                $factory,
1299
+                $c->get(IUserManager::class),
1300
+                $c->get(IRootFolder::class),
1301
+                $c->get(SymfonyAdapter::class),
1302
+                $c->get(IMailer::class),
1303
+                $c->get(IURLGenerator::class),
1304
+                $c->get('ThemingDefaults'),
1305
+                $c->get(IEventDispatcher::class),
1306
+                $c->get(IUserSession::class),
1307
+                $c->get(KnownUserService::class)
1308
+            );
1309
+
1310
+            return $manager;
1311
+        });
1312
+        /** @deprecated 19.0.0 */
1313
+        $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1314
+
1315
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1316
+            $instance = new Collaboration\Collaborators\Search($c);
1317
+
1318
+            // register default plugins
1319
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1320
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1321
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1322
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1323
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1324
+
1325
+            return $instance;
1326
+        });
1327
+        /** @deprecated 19.0.0 */
1328
+        $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1329
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1330
+
1331
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1332
+
1333
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1334
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1335
+
1336
+        $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1337
+
1338
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1339
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1340
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1341
+            return new \OC\Files\AppData\Factory(
1342
+                $c->get(IRootFolder::class),
1343
+                $c->get(SystemConfig::class)
1344
+            );
1345
+        });
1346
+
1347
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1348
+            return new LockdownManager(function () use ($c) {
1349
+                return $c->get(ISession::class);
1350
+            });
1351
+        });
1352
+
1353
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1354
+            return new DiscoveryService(
1355
+                $c->get(ICacheFactory::class),
1356
+                $c->get(IClientService::class)
1357
+            );
1358
+        });
1359
+
1360
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1361
+            return new CloudIdManager(
1362
+                $c->get(\OCP\Contacts\IManager::class),
1363
+                $c->get(IURLGenerator::class),
1364
+                $c->get(IUserManager::class),
1365
+                $c->get(ICacheFactory::class),
1366
+                $c->get(IEventDispatcher::class),
1367
+            );
1368
+        });
1369
+
1370
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1371
+
1372
+        $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
1373
+            return new CloudFederationProviderManager(
1374
+                $c->get(IAppManager::class),
1375
+                $c->get(IClientService::class),
1376
+                $c->get(ICloudIdManager::class),
1377
+                $c->get(LoggerInterface::class)
1378
+            );
1379
+        });
1380
+
1381
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1382
+            return new CloudFederationFactory();
1383
+        });
1384
+
1385
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1386
+        /** @deprecated 19.0.0 */
1387
+        $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1388
+
1389
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1390
+        /** @deprecated 19.0.0 */
1391
+        $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1392
+
1393
+        $this->registerService(Defaults::class, function (Server $c) {
1394
+            return new Defaults(
1395
+                $c->getThemingDefaults()
1396
+            );
1397
+        });
1398
+        /** @deprecated 19.0.0 */
1399
+        $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1400
+
1401
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1402
+            return $c->get(\OCP\IUserSession::class)->getSession();
1403
+        }, false);
1404
+
1405
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1406
+            return new ShareHelper(
1407
+                $c->get(\OCP\Share\IManager::class)
1408
+            );
1409
+        });
1410
+
1411
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1412
+            return new Installer(
1413
+                $c->get(AppFetcher::class),
1414
+                $c->get(IClientService::class),
1415
+                $c->get(ITempManager::class),
1416
+                $c->get(LoggerInterface::class),
1417
+                $c->get(\OCP\IConfig::class),
1418
+                \OC::$CLI
1419
+            );
1420
+        });
1421
+
1422
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1423
+            return new ApiFactory($c->get(IClientService::class));
1424
+        });
1425
+
1426
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1427
+            $memcacheFactory = $c->get(ICacheFactory::class);
1428
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1429
+        });
1430
+
1431
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1432
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1433
+
1434
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1435
+
1436
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1437
+
1438
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1439
+
1440
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1441
+
1442
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1443
+
1444
+        $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1445
+
1446
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1447
+
1448
+        $this->registerAlias(IBroker::class, Broker::class);
1449
+
1450
+        $this->registerAlias(IMetadataManager::class, MetadataManager::class);
1451
+
1452
+        $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1453
+
1454
+        $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1455
+
1456
+        $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1457
+
1458
+        $this->registerAlias(ITranslationManager::class, TranslationManager::class);
1459
+
1460
+        $this->connectDispatcher();
1461
+    }
1462
+
1463
+    public function boot() {
1464
+        /** @var HookConnector $hookConnector */
1465
+        $hookConnector = $this->get(HookConnector::class);
1466
+        $hookConnector->viewToNode();
1467
+    }
1468
+
1469
+    /**
1470
+     * @return \OCP\Calendar\IManager
1471
+     * @deprecated 20.0.0
1472
+     */
1473
+    public function getCalendarManager() {
1474
+        return $this->get(\OC\Calendar\Manager::class);
1475
+    }
1476
+
1477
+    /**
1478
+     * @return \OCP\Calendar\Resource\IManager
1479
+     * @deprecated 20.0.0
1480
+     */
1481
+    public function getCalendarResourceBackendManager() {
1482
+        return $this->get(\OC\Calendar\Resource\Manager::class);
1483
+    }
1484
+
1485
+    /**
1486
+     * @return \OCP\Calendar\Room\IManager
1487
+     * @deprecated 20.0.0
1488
+     */
1489
+    public function getCalendarRoomBackendManager() {
1490
+        return $this->get(\OC\Calendar\Room\Manager::class);
1491
+    }
1492
+
1493
+    private function connectDispatcher(): void {
1494
+        /** @var IEventDispatcher $eventDispatcher */
1495
+        $eventDispatcher = $this->get(IEventDispatcher::class);
1496
+        $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1497
+        $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1498
+        $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1499
+        $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1500
+    }
1501
+
1502
+    /**
1503
+     * @return \OCP\Contacts\IManager
1504
+     * @deprecated 20.0.0
1505
+     */
1506
+    public function getContactsManager() {
1507
+        return $this->get(\OCP\Contacts\IManager::class);
1508
+    }
1509
+
1510
+    /**
1511
+     * @return \OC\Encryption\Manager
1512
+     * @deprecated 20.0.0
1513
+     */
1514
+    public function getEncryptionManager() {
1515
+        return $this->get(\OCP\Encryption\IManager::class);
1516
+    }
1517
+
1518
+    /**
1519
+     * @return \OC\Encryption\File
1520
+     * @deprecated 20.0.0
1521
+     */
1522
+    public function getEncryptionFilesHelper() {
1523
+        return $this->get(IFile::class);
1524
+    }
1525
+
1526
+    /**
1527
+     * @return \OCP\Encryption\Keys\IStorage
1528
+     * @deprecated 20.0.0
1529
+     */
1530
+    public function getEncryptionKeyStorage() {
1531
+        return $this->get(IStorage::class);
1532
+    }
1533
+
1534
+    /**
1535
+     * The current request object holding all information about the request
1536
+     * currently being processed is returned from this method.
1537
+     * In case the current execution was not initiated by a web request null is returned
1538
+     *
1539
+     * @return \OCP\IRequest
1540
+     * @deprecated 20.0.0
1541
+     */
1542
+    public function getRequest() {
1543
+        return $this->get(IRequest::class);
1544
+    }
1545
+
1546
+    /**
1547
+     * Returns the preview manager which can create preview images for a given file
1548
+     *
1549
+     * @return IPreview
1550
+     * @deprecated 20.0.0
1551
+     */
1552
+    public function getPreviewManager() {
1553
+        return $this->get(IPreview::class);
1554
+    }
1555
+
1556
+    /**
1557
+     * Returns the tag manager which can get and set tags for different object types
1558
+     *
1559
+     * @see \OCP\ITagManager::load()
1560
+     * @return ITagManager
1561
+     * @deprecated 20.0.0
1562
+     */
1563
+    public function getTagManager() {
1564
+        return $this->get(ITagManager::class);
1565
+    }
1566
+
1567
+    /**
1568
+     * Returns the system-tag manager
1569
+     *
1570
+     * @return ISystemTagManager
1571
+     *
1572
+     * @since 9.0.0
1573
+     * @deprecated 20.0.0
1574
+     */
1575
+    public function getSystemTagManager() {
1576
+        return $this->get(ISystemTagManager::class);
1577
+    }
1578
+
1579
+    /**
1580
+     * Returns the system-tag object mapper
1581
+     *
1582
+     * @return ISystemTagObjectMapper
1583
+     *
1584
+     * @since 9.0.0
1585
+     * @deprecated 20.0.0
1586
+     */
1587
+    public function getSystemTagObjectMapper() {
1588
+        return $this->get(ISystemTagObjectMapper::class);
1589
+    }
1590
+
1591
+    /**
1592
+     * Returns the avatar manager, used for avatar functionality
1593
+     *
1594
+     * @return IAvatarManager
1595
+     * @deprecated 20.0.0
1596
+     */
1597
+    public function getAvatarManager() {
1598
+        return $this->get(IAvatarManager::class);
1599
+    }
1600
+
1601
+    /**
1602
+     * Returns the root folder of ownCloud's data directory
1603
+     *
1604
+     * @return IRootFolder
1605
+     * @deprecated 20.0.0
1606
+     */
1607
+    public function getRootFolder() {
1608
+        return $this->get(IRootFolder::class);
1609
+    }
1610
+
1611
+    /**
1612
+     * Returns the root folder of ownCloud's data directory
1613
+     * This is the lazy variant so this gets only initialized once it
1614
+     * is actually used.
1615
+     *
1616
+     * @return IRootFolder
1617
+     * @deprecated 20.0.0
1618
+     */
1619
+    public function getLazyRootFolder() {
1620
+        return $this->get(IRootFolder::class);
1621
+    }
1622
+
1623
+    /**
1624
+     * Returns a view to ownCloud's files folder
1625
+     *
1626
+     * @param string $userId user ID
1627
+     * @return \OCP\Files\Folder|null
1628
+     * @deprecated 20.0.0
1629
+     */
1630
+    public function getUserFolder($userId = null) {
1631
+        if ($userId === null) {
1632
+            $user = $this->get(IUserSession::class)->getUser();
1633
+            if (!$user) {
1634
+                return null;
1635
+            }
1636
+            $userId = $user->getUID();
1637
+        }
1638
+        $root = $this->get(IRootFolder::class);
1639
+        return $root->getUserFolder($userId);
1640
+    }
1641
+
1642
+    /**
1643
+     * @return \OC\User\Manager
1644
+     * @deprecated 20.0.0
1645
+     */
1646
+    public function getUserManager() {
1647
+        return $this->get(IUserManager::class);
1648
+    }
1649
+
1650
+    /**
1651
+     * @return \OC\Group\Manager
1652
+     * @deprecated 20.0.0
1653
+     */
1654
+    public function getGroupManager() {
1655
+        return $this->get(IGroupManager::class);
1656
+    }
1657
+
1658
+    /**
1659
+     * @return \OC\User\Session
1660
+     * @deprecated 20.0.0
1661
+     */
1662
+    public function getUserSession() {
1663
+        return $this->get(IUserSession::class);
1664
+    }
1665
+
1666
+    /**
1667
+     * @return \OCP\ISession
1668
+     * @deprecated 20.0.0
1669
+     */
1670
+    public function getSession() {
1671
+        return $this->get(Session::class)->getSession();
1672
+    }
1673
+
1674
+    /**
1675
+     * @param \OCP\ISession $session
1676
+     */
1677
+    public function setSession(\OCP\ISession $session) {
1678
+        $this->get(SessionStorage::class)->setSession($session);
1679
+        $this->get(Session::class)->setSession($session);
1680
+        $this->get(Store::class)->setSession($session);
1681
+    }
1682
+
1683
+    /**
1684
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1685
+     * @deprecated 20.0.0
1686
+     */
1687
+    public function getTwoFactorAuthManager() {
1688
+        return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
1689
+    }
1690
+
1691
+    /**
1692
+     * @return \OC\NavigationManager
1693
+     * @deprecated 20.0.0
1694
+     */
1695
+    public function getNavigationManager() {
1696
+        return $this->get(INavigationManager::class);
1697
+    }
1698
+
1699
+    /**
1700
+     * @return \OCP\IConfig
1701
+     * @deprecated 20.0.0
1702
+     */
1703
+    public function getConfig() {
1704
+        return $this->get(AllConfig::class);
1705
+    }
1706
+
1707
+    /**
1708
+     * @return \OC\SystemConfig
1709
+     * @deprecated 20.0.0
1710
+     */
1711
+    public function getSystemConfig() {
1712
+        return $this->get(SystemConfig::class);
1713
+    }
1714
+
1715
+    /**
1716
+     * Returns the app config manager
1717
+     *
1718
+     * @return IAppConfig
1719
+     * @deprecated 20.0.0
1720
+     */
1721
+    public function getAppConfig() {
1722
+        return $this->get(IAppConfig::class);
1723
+    }
1724
+
1725
+    /**
1726
+     * @return IFactory
1727
+     * @deprecated 20.0.0
1728
+     */
1729
+    public function getL10NFactory() {
1730
+        return $this->get(IFactory::class);
1731
+    }
1732
+
1733
+    /**
1734
+     * get an L10N instance
1735
+     *
1736
+     * @param string $app appid
1737
+     * @param string $lang
1738
+     * @return IL10N
1739
+     * @deprecated 20.0.0
1740
+     */
1741
+    public function getL10N($app, $lang = null) {
1742
+        return $this->get(IFactory::class)->get($app, $lang);
1743
+    }
1744
+
1745
+    /**
1746
+     * @return IURLGenerator
1747
+     * @deprecated 20.0.0
1748
+     */
1749
+    public function getURLGenerator() {
1750
+        return $this->get(IURLGenerator::class);
1751
+    }
1752
+
1753
+    /**
1754
+     * @return AppFetcher
1755
+     * @deprecated 20.0.0
1756
+     */
1757
+    public function getAppFetcher() {
1758
+        return $this->get(AppFetcher::class);
1759
+    }
1760
+
1761
+    /**
1762
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1763
+     * getMemCacheFactory() instead.
1764
+     *
1765
+     * @return ICache
1766
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1767
+     */
1768
+    public function getCache() {
1769
+        return $this->get(ICache::class);
1770
+    }
1771
+
1772
+    /**
1773
+     * Returns an \OCP\CacheFactory instance
1774
+     *
1775
+     * @return \OCP\ICacheFactory
1776
+     * @deprecated 20.0.0
1777
+     */
1778
+    public function getMemCacheFactory() {
1779
+        return $this->get(ICacheFactory::class);
1780
+    }
1781
+
1782
+    /**
1783
+     * Returns an \OC\RedisFactory instance
1784
+     *
1785
+     * @return \OC\RedisFactory
1786
+     * @deprecated 20.0.0
1787
+     */
1788
+    public function getGetRedisFactory() {
1789
+        return $this->get('RedisFactory');
1790
+    }
1791
+
1792
+
1793
+    /**
1794
+     * Returns the current session
1795
+     *
1796
+     * @return \OCP\IDBConnection
1797
+     * @deprecated 20.0.0
1798
+     */
1799
+    public function getDatabaseConnection() {
1800
+        return $this->get(IDBConnection::class);
1801
+    }
1802
+
1803
+    /**
1804
+     * Returns the activity manager
1805
+     *
1806
+     * @return \OCP\Activity\IManager
1807
+     * @deprecated 20.0.0
1808
+     */
1809
+    public function getActivityManager() {
1810
+        return $this->get(\OCP\Activity\IManager::class);
1811
+    }
1812
+
1813
+    /**
1814
+     * Returns an job list for controlling background jobs
1815
+     *
1816
+     * @return IJobList
1817
+     * @deprecated 20.0.0
1818
+     */
1819
+    public function getJobList() {
1820
+        return $this->get(IJobList::class);
1821
+    }
1822
+
1823
+    /**
1824
+     * Returns a logger instance
1825
+     *
1826
+     * @return ILogger
1827
+     * @deprecated 20.0.0
1828
+     */
1829
+    public function getLogger() {
1830
+        return $this->get(ILogger::class);
1831
+    }
1832
+
1833
+    /**
1834
+     * @return ILogFactory
1835
+     * @throws \OCP\AppFramework\QueryException
1836
+     * @deprecated 20.0.0
1837
+     */
1838
+    public function getLogFactory() {
1839
+        return $this->get(ILogFactory::class);
1840
+    }
1841
+
1842
+    /**
1843
+     * Returns a router for generating and matching urls
1844
+     *
1845
+     * @return IRouter
1846
+     * @deprecated 20.0.0
1847
+     */
1848
+    public function getRouter() {
1849
+        return $this->get(IRouter::class);
1850
+    }
1851
+
1852
+    /**
1853
+     * Returns a search instance
1854
+     *
1855
+     * @return ISearch
1856
+     * @deprecated 20.0.0
1857
+     */
1858
+    public function getSearch() {
1859
+        return $this->get(ISearch::class);
1860
+    }
1861
+
1862
+    /**
1863
+     * Returns a SecureRandom instance
1864
+     *
1865
+     * @return \OCP\Security\ISecureRandom
1866
+     * @deprecated 20.0.0
1867
+     */
1868
+    public function getSecureRandom() {
1869
+        return $this->get(ISecureRandom::class);
1870
+    }
1871
+
1872
+    /**
1873
+     * Returns a Crypto instance
1874
+     *
1875
+     * @return ICrypto
1876
+     * @deprecated 20.0.0
1877
+     */
1878
+    public function getCrypto() {
1879
+        return $this->get(ICrypto::class);
1880
+    }
1881
+
1882
+    /**
1883
+     * Returns a Hasher instance
1884
+     *
1885
+     * @return IHasher
1886
+     * @deprecated 20.0.0
1887
+     */
1888
+    public function getHasher() {
1889
+        return $this->get(IHasher::class);
1890
+    }
1891
+
1892
+    /**
1893
+     * Returns a CredentialsManager instance
1894
+     *
1895
+     * @return ICredentialsManager
1896
+     * @deprecated 20.0.0
1897
+     */
1898
+    public function getCredentialsManager() {
1899
+        return $this->get(ICredentialsManager::class);
1900
+    }
1901
+
1902
+    /**
1903
+     * Get the certificate manager
1904
+     *
1905
+     * @return \OCP\ICertificateManager
1906
+     */
1907
+    public function getCertificateManager() {
1908
+        return $this->get(ICertificateManager::class);
1909
+    }
1910
+
1911
+    /**
1912
+     * Returns an instance of the HTTP client service
1913
+     *
1914
+     * @return IClientService
1915
+     * @deprecated 20.0.0
1916
+     */
1917
+    public function getHTTPClientService() {
1918
+        return $this->get(IClientService::class);
1919
+    }
1920
+
1921
+    /**
1922
+     * Create a new event source
1923
+     *
1924
+     * @return \OCP\IEventSource
1925
+     * @deprecated 20.0.0
1926
+     */
1927
+    public function createEventSource() {
1928
+        return new \OC_EventSource();
1929
+    }
1930
+
1931
+    /**
1932
+     * Get the active event logger
1933
+     *
1934
+     * The returned logger only logs data when debug mode is enabled
1935
+     *
1936
+     * @return IEventLogger
1937
+     * @deprecated 20.0.0
1938
+     */
1939
+    public function getEventLogger() {
1940
+        return $this->get(IEventLogger::class);
1941
+    }
1942
+
1943
+    /**
1944
+     * Get the active query logger
1945
+     *
1946
+     * The returned logger only logs data when debug mode is enabled
1947
+     *
1948
+     * @return IQueryLogger
1949
+     * @deprecated 20.0.0
1950
+     */
1951
+    public function getQueryLogger() {
1952
+        return $this->get(IQueryLogger::class);
1953
+    }
1954
+
1955
+    /**
1956
+     * Get the manager for temporary files and folders
1957
+     *
1958
+     * @return \OCP\ITempManager
1959
+     * @deprecated 20.0.0
1960
+     */
1961
+    public function getTempManager() {
1962
+        return $this->get(ITempManager::class);
1963
+    }
1964
+
1965
+    /**
1966
+     * Get the app manager
1967
+     *
1968
+     * @return \OCP\App\IAppManager
1969
+     * @deprecated 20.0.0
1970
+     */
1971
+    public function getAppManager() {
1972
+        return $this->get(IAppManager::class);
1973
+    }
1974
+
1975
+    /**
1976
+     * Creates a new mailer
1977
+     *
1978
+     * @return IMailer
1979
+     * @deprecated 20.0.0
1980
+     */
1981
+    public function getMailer() {
1982
+        return $this->get(IMailer::class);
1983
+    }
1984
+
1985
+    /**
1986
+     * Get the webroot
1987
+     *
1988
+     * @return string
1989
+     * @deprecated 20.0.0
1990
+     */
1991
+    public function getWebRoot() {
1992
+        return $this->webRoot;
1993
+    }
1994
+
1995
+    /**
1996
+     * @return \OC\OCSClient
1997
+     * @deprecated 20.0.0
1998
+     */
1999
+    public function getOcsClient() {
2000
+        return $this->get('OcsClient');
2001
+    }
2002
+
2003
+    /**
2004
+     * @return IDateTimeZone
2005
+     * @deprecated 20.0.0
2006
+     */
2007
+    public function getDateTimeZone() {
2008
+        return $this->get(IDateTimeZone::class);
2009
+    }
2010
+
2011
+    /**
2012
+     * @return IDateTimeFormatter
2013
+     * @deprecated 20.0.0
2014
+     */
2015
+    public function getDateTimeFormatter() {
2016
+        return $this->get(IDateTimeFormatter::class);
2017
+    }
2018
+
2019
+    /**
2020
+     * @return IMountProviderCollection
2021
+     * @deprecated 20.0.0
2022
+     */
2023
+    public function getMountProviderCollection() {
2024
+        return $this->get(IMountProviderCollection::class);
2025
+    }
2026
+
2027
+    /**
2028
+     * Get the IniWrapper
2029
+     *
2030
+     * @return IniGetWrapper
2031
+     * @deprecated 20.0.0
2032
+     */
2033
+    public function getIniWrapper() {
2034
+        return $this->get(IniGetWrapper::class);
2035
+    }
2036
+
2037
+    /**
2038
+     * @return \OCP\Command\IBus
2039
+     * @deprecated 20.0.0
2040
+     */
2041
+    public function getCommandBus() {
2042
+        return $this->get(IBus::class);
2043
+    }
2044
+
2045
+    /**
2046
+     * Get the trusted domain helper
2047
+     *
2048
+     * @return TrustedDomainHelper
2049
+     * @deprecated 20.0.0
2050
+     */
2051
+    public function getTrustedDomainHelper() {
2052
+        return $this->get(TrustedDomainHelper::class);
2053
+    }
2054
+
2055
+    /**
2056
+     * Get the locking provider
2057
+     *
2058
+     * @return ILockingProvider
2059
+     * @since 8.1.0
2060
+     * @deprecated 20.0.0
2061
+     */
2062
+    public function getLockingProvider() {
2063
+        return $this->get(ILockingProvider::class);
2064
+    }
2065
+
2066
+    /**
2067
+     * @return IMountManager
2068
+     * @deprecated 20.0.0
2069
+     **/
2070
+    public function getMountManager() {
2071
+        return $this->get(IMountManager::class);
2072
+    }
2073
+
2074
+    /**
2075
+     * @return IUserMountCache
2076
+     * @deprecated 20.0.0
2077
+     */
2078
+    public function getUserMountCache() {
2079
+        return $this->get(IUserMountCache::class);
2080
+    }
2081
+
2082
+    /**
2083
+     * Get the MimeTypeDetector
2084
+     *
2085
+     * @return IMimeTypeDetector
2086
+     * @deprecated 20.0.0
2087
+     */
2088
+    public function getMimeTypeDetector() {
2089
+        return $this->get(IMimeTypeDetector::class);
2090
+    }
2091
+
2092
+    /**
2093
+     * Get the MimeTypeLoader
2094
+     *
2095
+     * @return IMimeTypeLoader
2096
+     * @deprecated 20.0.0
2097
+     */
2098
+    public function getMimeTypeLoader() {
2099
+        return $this->get(IMimeTypeLoader::class);
2100
+    }
2101
+
2102
+    /**
2103
+     * Get the manager of all the capabilities
2104
+     *
2105
+     * @return CapabilitiesManager
2106
+     * @deprecated 20.0.0
2107
+     */
2108
+    public function getCapabilitiesManager() {
2109
+        return $this->get(CapabilitiesManager::class);
2110
+    }
2111
+
2112
+    /**
2113
+     * Get the EventDispatcher
2114
+     *
2115
+     * @return EventDispatcherInterface
2116
+     * @since 8.2.0
2117
+     * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2118
+     */
2119
+    public function getEventDispatcher() {
2120
+        return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
2121
+    }
2122
+
2123
+    /**
2124
+     * Get the Notification Manager
2125
+     *
2126
+     * @return \OCP\Notification\IManager
2127
+     * @since 8.2.0
2128
+     * @deprecated 20.0.0
2129
+     */
2130
+    public function getNotificationManager() {
2131
+        return $this->get(\OCP\Notification\IManager::class);
2132
+    }
2133
+
2134
+    /**
2135
+     * @return ICommentsManager
2136
+     * @deprecated 20.0.0
2137
+     */
2138
+    public function getCommentsManager() {
2139
+        return $this->get(ICommentsManager::class);
2140
+    }
2141
+
2142
+    /**
2143
+     * @return \OCA\Theming\ThemingDefaults
2144
+     * @deprecated 20.0.0
2145
+     */
2146
+    public function getThemingDefaults() {
2147
+        return $this->get('ThemingDefaults');
2148
+    }
2149
+
2150
+    /**
2151
+     * @return \OC\IntegrityCheck\Checker
2152
+     * @deprecated 20.0.0
2153
+     */
2154
+    public function getIntegrityCodeChecker() {
2155
+        return $this->get('IntegrityCodeChecker');
2156
+    }
2157
+
2158
+    /**
2159
+     * @return \OC\Session\CryptoWrapper
2160
+     * @deprecated 20.0.0
2161
+     */
2162
+    public function getSessionCryptoWrapper() {
2163
+        return $this->get('CryptoWrapper');
2164
+    }
2165
+
2166
+    /**
2167
+     * @return CsrfTokenManager
2168
+     * @deprecated 20.0.0
2169
+     */
2170
+    public function getCsrfTokenManager() {
2171
+        return $this->get(CsrfTokenManager::class);
2172
+    }
2173
+
2174
+    /**
2175
+     * @return Throttler
2176
+     * @deprecated 20.0.0
2177
+     */
2178
+    public function getBruteForceThrottler() {
2179
+        return $this->get(Throttler::class);
2180
+    }
2181
+
2182
+    /**
2183
+     * @return IContentSecurityPolicyManager
2184
+     * @deprecated 20.0.0
2185
+     */
2186
+    public function getContentSecurityPolicyManager() {
2187
+        return $this->get(ContentSecurityPolicyManager::class);
2188
+    }
2189
+
2190
+    /**
2191
+     * @return ContentSecurityPolicyNonceManager
2192
+     * @deprecated 20.0.0
2193
+     */
2194
+    public function getContentSecurityPolicyNonceManager() {
2195
+        return $this->get(ContentSecurityPolicyNonceManager::class);
2196
+    }
2197
+
2198
+    /**
2199
+     * Not a public API as of 8.2, wait for 9.0
2200
+     *
2201
+     * @return \OCA\Files_External\Service\BackendService
2202
+     * @deprecated 20.0.0
2203
+     */
2204
+    public function getStoragesBackendService() {
2205
+        return $this->get(BackendService::class);
2206
+    }
2207
+
2208
+    /**
2209
+     * Not a public API as of 8.2, wait for 9.0
2210
+     *
2211
+     * @return \OCA\Files_External\Service\GlobalStoragesService
2212
+     * @deprecated 20.0.0
2213
+     */
2214
+    public function getGlobalStoragesService() {
2215
+        return $this->get(GlobalStoragesService::class);
2216
+    }
2217
+
2218
+    /**
2219
+     * Not a public API as of 8.2, wait for 9.0
2220
+     *
2221
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
2222
+     * @deprecated 20.0.0
2223
+     */
2224
+    public function getUserGlobalStoragesService() {
2225
+        return $this->get(UserGlobalStoragesService::class);
2226
+    }
2227
+
2228
+    /**
2229
+     * Not a public API as of 8.2, wait for 9.0
2230
+     *
2231
+     * @return \OCA\Files_External\Service\UserStoragesService
2232
+     * @deprecated 20.0.0
2233
+     */
2234
+    public function getUserStoragesService() {
2235
+        return $this->get(UserStoragesService::class);
2236
+    }
2237
+
2238
+    /**
2239
+     * @return \OCP\Share\IManager
2240
+     * @deprecated 20.0.0
2241
+     */
2242
+    public function getShareManager() {
2243
+        return $this->get(\OCP\Share\IManager::class);
2244
+    }
2245
+
2246
+    /**
2247
+     * @return \OCP\Collaboration\Collaborators\ISearch
2248
+     * @deprecated 20.0.0
2249
+     */
2250
+    public function getCollaboratorSearch() {
2251
+        return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
2252
+    }
2253
+
2254
+    /**
2255
+     * @return \OCP\Collaboration\AutoComplete\IManager
2256
+     * @deprecated 20.0.0
2257
+     */
2258
+    public function getAutoCompleteManager() {
2259
+        return $this->get(IManager::class);
2260
+    }
2261
+
2262
+    /**
2263
+     * Returns the LDAP Provider
2264
+     *
2265
+     * @return \OCP\LDAP\ILDAPProvider
2266
+     * @deprecated 20.0.0
2267
+     */
2268
+    public function getLDAPProvider() {
2269
+        return $this->get('LDAPProvider');
2270
+    }
2271
+
2272
+    /**
2273
+     * @return \OCP\Settings\IManager
2274
+     * @deprecated 20.0.0
2275
+     */
2276
+    public function getSettingsManager() {
2277
+        return $this->get(\OC\Settings\Manager::class);
2278
+    }
2279
+
2280
+    /**
2281
+     * @return \OCP\Files\IAppData
2282
+     * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
2283
+     */
2284
+    public function getAppDataDir($app) {
2285
+        /** @var \OC\Files\AppData\Factory $factory */
2286
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
2287
+        return $factory->get($app);
2288
+    }
2289
+
2290
+    /**
2291
+     * @return \OCP\Lockdown\ILockdownManager
2292
+     * @deprecated 20.0.0
2293
+     */
2294
+    public function getLockdownManager() {
2295
+        return $this->get('LockdownManager');
2296
+    }
2297
+
2298
+    /**
2299
+     * @return \OCP\Federation\ICloudIdManager
2300
+     * @deprecated 20.0.0
2301
+     */
2302
+    public function getCloudIdManager() {
2303
+        return $this->get(ICloudIdManager::class);
2304
+    }
2305
+
2306
+    /**
2307
+     * @return \OCP\GlobalScale\IConfig
2308
+     * @deprecated 20.0.0
2309
+     */
2310
+    public function getGlobalScaleConfig() {
2311
+        return $this->get(IConfig::class);
2312
+    }
2313
+
2314
+    /**
2315
+     * @return \OCP\Federation\ICloudFederationProviderManager
2316
+     * @deprecated 20.0.0
2317
+     */
2318
+    public function getCloudFederationProviderManager() {
2319
+        return $this->get(ICloudFederationProviderManager::class);
2320
+    }
2321
+
2322
+    /**
2323
+     * @return \OCP\Remote\Api\IApiFactory
2324
+     * @deprecated 20.0.0
2325
+     */
2326
+    public function getRemoteApiFactory() {
2327
+        return $this->get(IApiFactory::class);
2328
+    }
2329
+
2330
+    /**
2331
+     * @return \OCP\Federation\ICloudFederationFactory
2332
+     * @deprecated 20.0.0
2333
+     */
2334
+    public function getCloudFederationFactory() {
2335
+        return $this->get(ICloudFederationFactory::class);
2336
+    }
2337
+
2338
+    /**
2339
+     * @return \OCP\Remote\IInstanceFactory
2340
+     * @deprecated 20.0.0
2341
+     */
2342
+    public function getRemoteInstanceFactory() {
2343
+        return $this->get(IInstanceFactory::class);
2344
+    }
2345
+
2346
+    /**
2347
+     * @return IStorageFactory
2348
+     * @deprecated 20.0.0
2349
+     */
2350
+    public function getStorageFactory() {
2351
+        return $this->get(IStorageFactory::class);
2352
+    }
2353
+
2354
+    /**
2355
+     * Get the Preview GeneratorHelper
2356
+     *
2357
+     * @return GeneratorHelper
2358
+     * @since 17.0.0
2359
+     * @deprecated 20.0.0
2360
+     */
2361
+    public function getGeneratorHelper() {
2362
+        return $this->get(\OC\Preview\GeneratorHelper::class);
2363
+    }
2364
+
2365
+    private function registerDeprecatedAlias(string $alias, string $target) {
2366
+        $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2367
+            try {
2368
+                /** @var LoggerInterface $logger */
2369
+                $logger = $container->get(LoggerInterface::class);
2370
+                $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2371
+            } catch (ContainerExceptionInterface $e) {
2372
+                // Could not get logger. Continue
2373
+            }
2374
+
2375
+            return $container->get($target);
2376
+        }, false);
2377
+    }
2378 2378
 }
Please login to merge, or discard this patch.
lib/private/Translation/TranslationManager.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -40,81 +40,81 @@
 block discarded – undo
40 40
 use Throwable;
41 41
 
42 42
 class TranslationManager implements ITranslationManager {
43
-	/** @var ?ITranslationProvider[] */
44
-	private ?array $providers = null;
45
-
46
-	public function __construct(
47
-		private IServerContainer $serverContainer,
48
-		private Coordinator $coordinator,
49
-		private LoggerInterface $logger,
50
-	) {
51
-	}
52
-
53
-	public function getLanguages(): array {
54
-		$languages = [];
55
-		foreach ($this->getProviders() as $provider) {
56
-			$languages = array_merge($languages, $provider->getAvailableLanguages());
57
-		}
58
-		return $languages;
59
-	}
60
-
61
-	public function translate(string $text, ?string $fromLanguage, string $toLanguage): string {
62
-		if (!$this->hasProviders()) {
63
-			throw new PreConditionNotMetException('No translation providers available');
64
-		}
65
-
66
-		foreach ($this->getProviders() as $provider) {
67
-			if ($fromLanguage === null && $provider instanceof IDetectLanguageProvider) {
68
-				$fromLanguage = $provider->detectLanguage($text);
69
-			}
70
-
71
-			if ($fromLanguage === null) {
72
-				throw new InvalidArgumentException('Could not detect language');
73
-			}
74
-
75
-			try {
76
-				return $provider->translate($fromLanguage, $toLanguage, $text);
77
-			} catch (RuntimeException $e) {
78
-				$this->logger->warning("Failed to translate from {$fromLanguage} to {$toLanguage}", ['exception' => $e]);
79
-			}
80
-		}
81
-
82
-		throw new RuntimeException('Could not translate text');
83
-	}
84
-
85
-	public function getProviders(): array {
86
-		$context = $this->coordinator->getRegistrationContext();
87
-
88
-		if ($this->providers !== null) {
89
-			return $this->providers;
90
-		}
91
-
92
-		$this->providers = [];
93
-		foreach ($context->getTranslationProviders() as $providerRegistration) {
94
-			$class = $providerRegistration->getService();
95
-			try {
96
-				$this->providers[$class] = $this->serverContainer->get($class);
97
-			} catch (NotFoundExceptionInterface|ContainerExceptionInterface|Throwable $e) {
98
-				$this->logger->error('Failed to load translation provider ' . $class, [
99
-					'exception' => $e
100
-				]);
101
-			}
102
-		}
103
-
104
-		return $this->providers;
105
-	}
106
-
107
-	public function hasProviders(): bool {
108
-		$context = $this->coordinator->getRegistrationContext();
109
-		return !empty($context->getTranslationProviders());
110
-	}
111
-
112
-	public function canDetectLanguage(): bool {
113
-		foreach ($this->getProviders() as $provider) {
114
-			if ($provider instanceof IDetectLanguageProvider) {
115
-				return true;
116
-			}
117
-		}
118
-		return false;
119
-	}
43
+    /** @var ?ITranslationProvider[] */
44
+    private ?array $providers = null;
45
+
46
+    public function __construct(
47
+        private IServerContainer $serverContainer,
48
+        private Coordinator $coordinator,
49
+        private LoggerInterface $logger,
50
+    ) {
51
+    }
52
+
53
+    public function getLanguages(): array {
54
+        $languages = [];
55
+        foreach ($this->getProviders() as $provider) {
56
+            $languages = array_merge($languages, $provider->getAvailableLanguages());
57
+        }
58
+        return $languages;
59
+    }
60
+
61
+    public function translate(string $text, ?string $fromLanguage, string $toLanguage): string {
62
+        if (!$this->hasProviders()) {
63
+            throw new PreConditionNotMetException('No translation providers available');
64
+        }
65
+
66
+        foreach ($this->getProviders() as $provider) {
67
+            if ($fromLanguage === null && $provider instanceof IDetectLanguageProvider) {
68
+                $fromLanguage = $provider->detectLanguage($text);
69
+            }
70
+
71
+            if ($fromLanguage === null) {
72
+                throw new InvalidArgumentException('Could not detect language');
73
+            }
74
+
75
+            try {
76
+                return $provider->translate($fromLanguage, $toLanguage, $text);
77
+            } catch (RuntimeException $e) {
78
+                $this->logger->warning("Failed to translate from {$fromLanguage} to {$toLanguage}", ['exception' => $e]);
79
+            }
80
+        }
81
+
82
+        throw new RuntimeException('Could not translate text');
83
+    }
84
+
85
+    public function getProviders(): array {
86
+        $context = $this->coordinator->getRegistrationContext();
87
+
88
+        if ($this->providers !== null) {
89
+            return $this->providers;
90
+        }
91
+
92
+        $this->providers = [];
93
+        foreach ($context->getTranslationProviders() as $providerRegistration) {
94
+            $class = $providerRegistration->getService();
95
+            try {
96
+                $this->providers[$class] = $this->serverContainer->get($class);
97
+            } catch (NotFoundExceptionInterface|ContainerExceptionInterface|Throwable $e) {
98
+                $this->logger->error('Failed to load translation provider ' . $class, [
99
+                    'exception' => $e
100
+                ]);
101
+            }
102
+        }
103
+
104
+        return $this->providers;
105
+    }
106
+
107
+    public function hasProviders(): bool {
108
+        $context = $this->coordinator->getRegistrationContext();
109
+        return !empty($context->getTranslationProviders());
110
+    }
111
+
112
+    public function canDetectLanguage(): bool {
113
+        foreach ($this->getProviders() as $provider) {
114
+            if ($provider instanceof IDetectLanguageProvider) {
115
+                return true;
116
+            }
117
+        }
118
+        return false;
119
+    }
120 120
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,8 +94,8 @@
 block discarded – undo
94 94
 			$class = $providerRegistration->getService();
95 95
 			try {
96 96
 				$this->providers[$class] = $this->serverContainer->get($class);
97
-			} catch (NotFoundExceptionInterface|ContainerExceptionInterface|Throwable $e) {
98
-				$this->logger->error('Failed to load translation provider ' . $class, [
97
+			} catch (NotFoundExceptionInterface | ContainerExceptionInterface | Throwable $e) {
98
+				$this->logger->error('Failed to load translation provider '.$class, [
99 99
 					'exception' => $e
100 100
 				]);
101 101
 			}
Please login to merge, or discard this patch.