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