Completed
Push — master ( 9af26d...fabaf0 )
by Jan-Christoph
12:07
created
apps/theming/lib/Controller/ThemingController.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,6 @@  discard block
 block discarded – undo
27 27
 
28 28
 namespace OCA\Theming\Controller;
29 29
 
30
-use OC\Files\AppData\Factory;
31 30
 use OC\Template\SCSSCacher;
32 31
 use OCA\Theming\ThemingDefaults;
33 32
 use OCP\AppFramework\Controller;
@@ -42,11 +41,9 @@  discard block
 block discarded – undo
42 41
 use OCP\Files\NotFoundException;
43 42
 use OCP\IConfig;
44 43
 use OCP\IL10N;
45
-use OCP\ILogger;
46 44
 use OCP\IRequest;
47 45
 use OCA\Theming\Util;
48 46
 use OCP\ITempManager;
49
-use OCP\IURLGenerator;
50 47
 
51 48
 /**
52 49
  * Class ThemingController
Please login to merge, or discard this patch.
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -56,318 +56,318 @@  discard block
 block discarded – undo
56 56
  * @package OCA\Theming\Controller
57 57
  */
58 58
 class ThemingController extends Controller {
59
-	/** @var ThemingDefaults */
60
-	private $themingDefaults;
61
-	/** @var Util */
62
-	private $util;
63
-	/** @var ITimeFactory */
64
-	private $timeFactory;
65
-	/** @var IL10N */
66
-	private $l10n;
67
-	/** @var IConfig */
68
-	private $config;
69
-	/** @var ITempManager */
70
-	private $tempManager;
71
-	/** @var IAppData */
72
-	private $appData;
73
-	/** @var SCSSCacher */
74
-	private $scssCacher;
59
+    /** @var ThemingDefaults */
60
+    private $themingDefaults;
61
+    /** @var Util */
62
+    private $util;
63
+    /** @var ITimeFactory */
64
+    private $timeFactory;
65
+    /** @var IL10N */
66
+    private $l10n;
67
+    /** @var IConfig */
68
+    private $config;
69
+    /** @var ITempManager */
70
+    private $tempManager;
71
+    /** @var IAppData */
72
+    private $appData;
73
+    /** @var SCSSCacher */
74
+    private $scssCacher;
75 75
 
76
-	/**
77
-	 * ThemingController constructor.
78
-	 *
79
-	 * @param string $appName
80
-	 * @param IRequest $request
81
-	 * @param IConfig $config
82
-	 * @param ThemingDefaults $themingDefaults
83
-	 * @param Util $util
84
-	 * @param ITimeFactory $timeFactory
85
-	 * @param IL10N $l
86
-	 * @param ITempManager $tempManager
87
-	 * @param IAppData $appData
88
-	 * @param SCSSCacher $scssCacher
89
-	 */
90
-	public function __construct(
91
-		$appName,
92
-		IRequest $request,
93
-		IConfig $config,
94
-		ThemingDefaults $themingDefaults,
95
-		Util $util,
96
-		ITimeFactory $timeFactory,
97
-		IL10N $l,
98
-		ITempManager $tempManager,
99
-		IAppData $appData,
100
-		SCSSCacher $scssCacher
101
-	) {
102
-		parent::__construct($appName, $request);
76
+    /**
77
+     * ThemingController constructor.
78
+     *
79
+     * @param string $appName
80
+     * @param IRequest $request
81
+     * @param IConfig $config
82
+     * @param ThemingDefaults $themingDefaults
83
+     * @param Util $util
84
+     * @param ITimeFactory $timeFactory
85
+     * @param IL10N $l
86
+     * @param ITempManager $tempManager
87
+     * @param IAppData $appData
88
+     * @param SCSSCacher $scssCacher
89
+     */
90
+    public function __construct(
91
+        $appName,
92
+        IRequest $request,
93
+        IConfig $config,
94
+        ThemingDefaults $themingDefaults,
95
+        Util $util,
96
+        ITimeFactory $timeFactory,
97
+        IL10N $l,
98
+        ITempManager $tempManager,
99
+        IAppData $appData,
100
+        SCSSCacher $scssCacher
101
+    ) {
102
+        parent::__construct($appName, $request);
103 103
 
104
-		$this->themingDefaults = $themingDefaults;
105
-		$this->util = $util;
106
-		$this->timeFactory = $timeFactory;
107
-		$this->l10n = $l;
108
-		$this->config = $config;
109
-		$this->tempManager = $tempManager;
110
-		$this->appData = $appData;
111
-		$this->scssCacher = $scssCacher;
112
-	}
104
+        $this->themingDefaults = $themingDefaults;
105
+        $this->util = $util;
106
+        $this->timeFactory = $timeFactory;
107
+        $this->l10n = $l;
108
+        $this->config = $config;
109
+        $this->tempManager = $tempManager;
110
+        $this->appData = $appData;
111
+        $this->scssCacher = $scssCacher;
112
+    }
113 113
 
114
-	/**
115
-	 * @param string $setting
116
-	 * @param string $value
117
-	 * @return DataResponse
118
-	 * @internal param string $color
119
-	 */
120
-	public function updateStylesheet($setting, $value) {
121
-		$value = trim($value);
122
-		switch ($setting) {
123
-			case 'name':
124
-				if (strlen($value) > 250) {
125
-					return new DataResponse([
126
-						'data' => [
127
-							'message' => $this->l10n->t('The given name is too long'),
128
-						],
129
-						'status' => 'error'
130
-					]);
131
-				}
132
-				break;
133
-			case 'url':
134
-				if (strlen($value) > 500) {
135
-					return new DataResponse([
136
-						'data' => [
137
-							'message' => $this->l10n->t('The given web address is too long'),
138
-						],
139
-						'status' => 'error'
140
-					]);
141
-				}
142
-				break;
143
-			case 'slogan':
144
-				if (strlen($value) > 500) {
145
-					return new DataResponse([
146
-						'data' => [
147
-							'message' => $this->l10n->t('The given slogan is too long'),
148
-						],
149
-						'status' => 'error'
150
-					]);
151
-				}
152
-				break;
153
-			case 'color':
154
-				if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
155
-					return new DataResponse([
156
-						'data' => [
157
-							'message' => $this->l10n->t('The given color is invalid'),
158
-						],
159
-						'status' => 'error'
160
-					]);
161
-				}
162
-				break;
163
-		}
114
+    /**
115
+     * @param string $setting
116
+     * @param string $value
117
+     * @return DataResponse
118
+     * @internal param string $color
119
+     */
120
+    public function updateStylesheet($setting, $value) {
121
+        $value = trim($value);
122
+        switch ($setting) {
123
+            case 'name':
124
+                if (strlen($value) > 250) {
125
+                    return new DataResponse([
126
+                        'data' => [
127
+                            'message' => $this->l10n->t('The given name is too long'),
128
+                        ],
129
+                        'status' => 'error'
130
+                    ]);
131
+                }
132
+                break;
133
+            case 'url':
134
+                if (strlen($value) > 500) {
135
+                    return new DataResponse([
136
+                        'data' => [
137
+                            'message' => $this->l10n->t('The given web address is too long'),
138
+                        ],
139
+                        'status' => 'error'
140
+                    ]);
141
+                }
142
+                break;
143
+            case 'slogan':
144
+                if (strlen($value) > 500) {
145
+                    return new DataResponse([
146
+                        'data' => [
147
+                            'message' => $this->l10n->t('The given slogan is too long'),
148
+                        ],
149
+                        'status' => 'error'
150
+                    ]);
151
+                }
152
+                break;
153
+            case 'color':
154
+                if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
155
+                    return new DataResponse([
156
+                        'data' => [
157
+                            'message' => $this->l10n->t('The given color is invalid'),
158
+                        ],
159
+                        'status' => 'error'
160
+                    ]);
161
+                }
162
+                break;
163
+        }
164 164
 
165
-		$this->themingDefaults->set($setting, $value);
165
+        $this->themingDefaults->set($setting, $value);
166 166
 
167
-		// reprocess server scss for preview
168
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
167
+        // reprocess server scss for preview
168
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
169 169
 
170
-		return new DataResponse(
171
-			[
172
-				'data' =>
173
-					[
174
-						'message' => $this->l10n->t('Saved')
175
-					],
176
-				'status' => 'success'
177
-			]
178
-		);
179
-	}
170
+        return new DataResponse(
171
+            [
172
+                'data' =>
173
+                    [
174
+                        'message' => $this->l10n->t('Saved')
175
+                    ],
176
+                'status' => 'success'
177
+            ]
178
+        );
179
+    }
180 180
 
181
-	/**
182
-	 * Update the logos and background image
183
-	 *
184
-	 * @return DataResponse
185
-	 */
186
-	public function updateLogo() {
187
-		$newLogo = $this->request->getUploadedFile('uploadlogo');
188
-		$newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
189
-		if (empty($newLogo) && empty($newBackgroundLogo)) {
190
-			return new DataResponse(
191
-				[
192
-					'data' => [
193
-						'message' => $this->l10n->t('No file uploaded')
194
-					]
195
-				],
196
-				Http::STATUS_UNPROCESSABLE_ENTITY
197
-			);
198
-		}
181
+    /**
182
+     * Update the logos and background image
183
+     *
184
+     * @return DataResponse
185
+     */
186
+    public function updateLogo() {
187
+        $newLogo = $this->request->getUploadedFile('uploadlogo');
188
+        $newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
189
+        if (empty($newLogo) && empty($newBackgroundLogo)) {
190
+            return new DataResponse(
191
+                [
192
+                    'data' => [
193
+                        'message' => $this->l10n->t('No file uploaded')
194
+                    ]
195
+                ],
196
+                Http::STATUS_UNPROCESSABLE_ENTITY
197
+            );
198
+        }
199 199
 
200
-		$name = '';
201
-		try {
202
-			$folder = $this->appData->getFolder('images');
203
-		} catch (NotFoundException $e) {
204
-			$folder = $this->appData->newFolder('images');
205
-		}
200
+        $name = '';
201
+        try {
202
+            $folder = $this->appData->getFolder('images');
203
+        } catch (NotFoundException $e) {
204
+            $folder = $this->appData->newFolder('images');
205
+        }
206 206
 
207
-		if (!empty($newLogo)) {
208
-			$target = $folder->newFile('logo');
209
-			$target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
210
-			$this->themingDefaults->set('logoMime', $newLogo['type']);
211
-			$name = $newLogo['name'];
212
-		}
213
-		if (!empty($newBackgroundLogo)) {
214
-			$target = $folder->newFile('background');
215
-			$image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
216
-			if ($image === false) {
217
-				return new DataResponse(
218
-					[
219
-						'data' => [
220
-							'message' => $this->l10n->t('Unsupported image type'),
221
-						],
222
-						'status' => 'failure',
223
-					],
224
-					Http::STATUS_UNPROCESSABLE_ENTITY
225
-				);
226
-			}
207
+        if (!empty($newLogo)) {
208
+            $target = $folder->newFile('logo');
209
+            $target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
210
+            $this->themingDefaults->set('logoMime', $newLogo['type']);
211
+            $name = $newLogo['name'];
212
+        }
213
+        if (!empty($newBackgroundLogo)) {
214
+            $target = $folder->newFile('background');
215
+            $image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
216
+            if ($image === false) {
217
+                return new DataResponse(
218
+                    [
219
+                        'data' => [
220
+                            'message' => $this->l10n->t('Unsupported image type'),
221
+                        ],
222
+                        'status' => 'failure',
223
+                    ],
224
+                    Http::STATUS_UNPROCESSABLE_ENTITY
225
+                );
226
+            }
227 227
 
228
-			// Optimize the image since some people may upload images that will be
229
-			// either to big or are not progressive rendering.
230
-			$tmpFile = $this->tempManager->getTemporaryFile();
231
-			if (function_exists('imagescale')) {
232
-				// FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
233
-				// Workaround for https://bugs.php.net/bug.php?id=65171
234
-				$newHeight = imagesy($image) / (imagesx($image) / 1920);
235
-				$image = imagescale($image, 1920, $newHeight);
236
-			}
237
-			imageinterlace($image, 1);
238
-			imagejpeg($image, $tmpFile, 75);
239
-			imagedestroy($image);
228
+            // Optimize the image since some people may upload images that will be
229
+            // either to big or are not progressive rendering.
230
+            $tmpFile = $this->tempManager->getTemporaryFile();
231
+            if (function_exists('imagescale')) {
232
+                // FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
233
+                // Workaround for https://bugs.php.net/bug.php?id=65171
234
+                $newHeight = imagesy($image) / (imagesx($image) / 1920);
235
+                $image = imagescale($image, 1920, $newHeight);
236
+            }
237
+            imageinterlace($image, 1);
238
+            imagejpeg($image, $tmpFile, 75);
239
+            imagedestroy($image);
240 240
 
241
-			$target->putContent(file_get_contents($tmpFile, 'r'));
242
-			$this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
243
-			$name = $newBackgroundLogo['name'];
244
-		}
241
+            $target->putContent(file_get_contents($tmpFile, 'r'));
242
+            $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
243
+            $name = $newBackgroundLogo['name'];
244
+        }
245 245
 
246
-		return new DataResponse(
247
-			[
248
-				'data' =>
249
-					[
250
-						'name' => $name,
251
-						'message' => $this->l10n->t('Saved')
252
-					],
253
-				'status' => 'success'
254
-			]
255
-		);
256
-	}
246
+        return new DataResponse(
247
+            [
248
+                'data' =>
249
+                    [
250
+                        'name' => $name,
251
+                        'message' => $this->l10n->t('Saved')
252
+                    ],
253
+                'status' => 'success'
254
+            ]
255
+        );
256
+    }
257 257
 
258
-	/**
259
-	 * Revert setting to default value
260
-	 *
261
-	 * @param string $setting setting which should be reverted
262
-	 * @return DataResponse
263
-	 */
264
-	public function undo($setting) {
265
-		$value = $this->themingDefaults->undo($setting);
266
-		// reprocess server scss for preview
267
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
268
-		return new DataResponse(
269
-			[
270
-				'data' =>
271
-					[
272
-						'value' => $value,
273
-						'message' => $this->l10n->t('Saved')
274
-					],
275
-				'status' => 'success'
276
-			]
277
-		);
278
-	}
258
+    /**
259
+     * Revert setting to default value
260
+     *
261
+     * @param string $setting setting which should be reverted
262
+     * @return DataResponse
263
+     */
264
+    public function undo($setting) {
265
+        $value = $this->themingDefaults->undo($setting);
266
+        // reprocess server scss for preview
267
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
268
+        return new DataResponse(
269
+            [
270
+                'data' =>
271
+                    [
272
+                        'value' => $value,
273
+                        'message' => $this->l10n->t('Saved')
274
+                    ],
275
+                'status' => 'success'
276
+            ]
277
+        );
278
+    }
279 279
 
280
-	/**
281
-	 * @PublicPage
282
-	 * @NoCSRFRequired
283
-	 *
284
-	 * @return FileDisplayResponse|NotFoundResponse
285
-	 */
286
-	public function getLogo() {
287
-		try {
288
-			/** @var File $file */
289
-			$file = $this->appData->getFolder('images')->getFile('logo');
290
-		} catch (NotFoundException $e) {
291
-			return new NotFoundResponse();
292
-		}
280
+    /**
281
+     * @PublicPage
282
+     * @NoCSRFRequired
283
+     *
284
+     * @return FileDisplayResponse|NotFoundResponse
285
+     */
286
+    public function getLogo() {
287
+        try {
288
+            /** @var File $file */
289
+            $file = $this->appData->getFolder('images')->getFile('logo');
290
+        } catch (NotFoundException $e) {
291
+            return new NotFoundResponse();
292
+        }
293 293
 
294
-		$response = new FileDisplayResponse($file);
295
-		$response->cacheFor(3600);
296
-		$expires = new \DateTime();
297
-		$expires->setTimestamp($this->timeFactory->getTime());
298
-		$expires->add(new \DateInterval('PT24H'));
299
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
300
-		$response->addHeader('Pragma', 'cache');
301
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
302
-		return $response;
303
-	}
294
+        $response = new FileDisplayResponse($file);
295
+        $response->cacheFor(3600);
296
+        $expires = new \DateTime();
297
+        $expires->setTimestamp($this->timeFactory->getTime());
298
+        $expires->add(new \DateInterval('PT24H'));
299
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
300
+        $response->addHeader('Pragma', 'cache');
301
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
302
+        return $response;
303
+    }
304 304
 
305
-	/**
306
-	 * @PublicPage
307
-	 * @NoCSRFRequired
308
-	 *
309
-	 * @return FileDisplayResponse|NotFoundResponse
310
-	 */
311
-	public function getLoginBackground() {
312
-		try {
313
-			/** @var File $file */
314
-			$file = $this->appData->getFolder('images')->getFile('background');
315
-		} catch (NotFoundException $e) {
316
-			return new NotFoundResponse();
317
-		}
305
+    /**
306
+     * @PublicPage
307
+     * @NoCSRFRequired
308
+     *
309
+     * @return FileDisplayResponse|NotFoundResponse
310
+     */
311
+    public function getLoginBackground() {
312
+        try {
313
+            /** @var File $file */
314
+            $file = $this->appData->getFolder('images')->getFile('background');
315
+        } catch (NotFoundException $e) {
316
+            return new NotFoundResponse();
317
+        }
318 318
 
319
-		$response = new FileDisplayResponse($file);
320
-		$response->cacheFor(3600);
321
-		$expires = new \DateTime();
322
-		$expires->setTimestamp($this->timeFactory->getTime());
323
-		$expires->add(new \DateInterval('PT24H'));
324
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
325
-		$response->addHeader('Pragma', 'cache');
326
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
327
-		return $response;
328
-	}
319
+        $response = new FileDisplayResponse($file);
320
+        $response->cacheFor(3600);
321
+        $expires = new \DateTime();
322
+        $expires->setTimestamp($this->timeFactory->getTime());
323
+        $expires->add(new \DateInterval('PT24H'));
324
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
325
+        $response->addHeader('Pragma', 'cache');
326
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
327
+        return $response;
328
+    }
329 329
 
330
-	/**
331
-	 * @NoCSRFRequired
332
-	 * @PublicPage
333
-	 *
334
-	 * @return FileDisplayResponse|NotFoundResponse
335
-	 */
336
-	public function getStylesheet() {
337
-		$appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
338
-		/* SCSSCacher is required here
330
+    /**
331
+     * @NoCSRFRequired
332
+     * @PublicPage
333
+     *
334
+     * @return FileDisplayResponse|NotFoundResponse
335
+     */
336
+    public function getStylesheet() {
337
+        $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
338
+        /* SCSSCacher is required here
339 339
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
340 340
 		 * since we need to add the cacheBuster value to the url
341 341
 		 */
342
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
343
-		if(!$cssCached) {
344
-			return new NotFoundResponse();
345
-		}
342
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
343
+        if(!$cssCached) {
344
+            return new NotFoundResponse();
345
+        }
346 346
 
347
-		try {
348
-			$cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
349
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
350
-			$response->cacheFor(86400);
351
-			$expires = new \DateTime();
352
-			$expires->setTimestamp($this->timeFactory->getTime());
353
-			$expires->add(new \DateInterval('PT24H'));
354
-			$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
355
-			$response->addHeader('Pragma', 'cache');
356
-			return $response;
357
-		} catch (NotFoundException $e) {
358
-			return new NotFoundResponse();
359
-		}
360
-	}
347
+        try {
348
+            $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
349
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
350
+            $response->cacheFor(86400);
351
+            $expires = new \DateTime();
352
+            $expires->setTimestamp($this->timeFactory->getTime());
353
+            $expires->add(new \DateInterval('PT24H'));
354
+            $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
355
+            $response->addHeader('Pragma', 'cache');
356
+            return $response;
357
+        } catch (NotFoundException $e) {
358
+            return new NotFoundResponse();
359
+        }
360
+    }
361 361
 
362
-	/**
363
-	 * @NoCSRFRequired
364
-	 * @PublicPage
365
-	 *
366
-	 * @return DataDownloadResponse
367
-	 */
368
-	public function getJavascript() {
369
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
370
-		$responseJS = '(function() {
362
+    /**
363
+     * @NoCSRFRequired
364
+     * @PublicPage
365
+     *
366
+     * @return DataDownloadResponse
367
+     */
368
+    public function getJavascript() {
369
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
370
+        $responseJS = '(function() {
371 371
 	OCA.Theming = {
372 372
 		name: ' . json_encode($this->themingDefaults->getName()) . ',
373 373
 		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
 		cacheBuster: ' . json_encode($cacheBusterValue) . '
378 378
 	};
379 379
 })();';
380
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
381
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
382
-		$response->addHeader('Pragma', 'cache');
383
-		$response->cacheFor(3600);
384
-		return $response;
385
-	}
380
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
381
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
382
+        $response->addHeader('Pragma', 'cache');
383
+        $response->cacheFor(3600);
384
+        return $response;
385
+    }
386 386
 }
Please login to merge, or discard this patch.
apps/theming/lib/ThemingDefaults.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,6 @@
 block discarded – undo
58 58
 	 * @param IConfig $config
59 59
 	 * @param IL10N $l
60 60
 	 * @param IURLGenerator $urlGenerator
61
-	 * @param \OC_Defaults $defaults
62 61
 	 * @param IAppData $appData
63 62
 	 * @param ICacheFactory $cacheFactory
64 63
 	 * @param Util $util
Please login to merge, or discard this patch.
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -31,249 +31,249 @@
 block discarded – undo
31 31
 
32 32
 class ThemingDefaults extends \OC_Defaults {
33 33
 
34
-	/** @var IConfig */
35
-	private $config;
36
-	/** @var IL10N */
37
-	private $l;
38
-	/** @var IURLGenerator */
39
-	private $urlGenerator;
40
-	/** @var IAppData */
41
-	private $appData;
42
-	/** @var ICacheFactory */
43
-	private $cacheFactory;
44
-	/** @var string */
45
-	private $name;
46
-	/** @var string */
47
-	private $url;
48
-	/** @var string */
49
-	private $slogan;
50
-	/** @var string */
51
-	private $color;
52
-	/** @var Util */
53
-	private $util;
54
-
55
-	/**
56
-	 * ThemingDefaults constructor.
57
-	 *
58
-	 * @param IConfig $config
59
-	 * @param IL10N $l
60
-	 * @param IURLGenerator $urlGenerator
61
-	 * @param \OC_Defaults $defaults
62
-	 * @param IAppData $appData
63
-	 * @param ICacheFactory $cacheFactory
64
-	 * @param Util $util
65
-	 */
66
-	public function __construct(IConfig $config,
67
-								IL10N $l,
68
-								IURLGenerator $urlGenerator,
69
-								IAppData $appData,
70
-								ICacheFactory $cacheFactory,
71
-								Util $util
72
-	) {
73
-		parent::__construct();
74
-		$this->config = $config;
75
-		$this->l = $l;
76
-		$this->urlGenerator = $urlGenerator;
77
-		$this->appData = $appData;
78
-		$this->cacheFactory = $cacheFactory;
79
-		$this->util = $util;
80
-
81
-		$this->name = parent::getName();
82
-		$this->url = parent::getBaseUrl();
83
-		$this->slogan = parent::getSlogan();
84
-		$this->color = parent::getColorPrimary();
85
-	}
86
-
87
-	public function getName() {
88
-		return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
89
-	}
90
-
91
-	public function getHTMLName() {
92
-		return $this->config->getAppValue('theming', 'name', $this->name);
93
-	}
94
-
95
-	public function getTitle() {
96
-		return $this->getName();
97
-	}
98
-
99
-	public function getEntity() {
100
-		return $this->getName();
101
-	}
102
-
103
-	public function getBaseUrl() {
104
-		return $this->config->getAppValue('theming', 'url', $this->url);
105
-	}
106
-
107
-	public function getSlogan() {
108
-		return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
109
-	}
110
-
111
-	public function getShortFooter() {
112
-		$slogan = $this->getSlogan();
113
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
114
-			' rel="noreferrer">' .$this->getEntity() . '</a>'.
115
-			($slogan !== '' ? ' – ' . $slogan : '');
116
-
117
-		return $footer;
118
-	}
119
-
120
-	/**
121
-	 * Color that is used for the header as well as for mail headers
122
-	 *
123
-	 * @return string
124
-	 */
125
-	public function getColorPrimary() {
126
-		return $this->config->getAppValue('theming', 'color', $this->color);
127
-	}
128
-
129
-	/**
130
-	 * Themed logo url
131
-	 *
132
-	 * @return string
133
-	 */
134
-	public function getLogo() {
135
-		$logo = $this->config->getAppValue('theming', 'logoMime', false);
136
-
137
-		$logoExists = true;
138
-		try {
139
-			$this->appData->getFolder('images')->getFile('logo');
140
-		} catch (\Exception $e) {
141
-			$logoExists = false;
142
-		}
143
-
144
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
145
-
146
-		if(!$logo || !$logoExists) {
147
-			return $this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter;
148
-		}
149
-
150
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
151
-	}
152
-
153
-	/**
154
-	 * Themed background image url
155
-	 *
156
-	 * @return string
157
-	 */
158
-	public function getBackground() {
159
-		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
160
-
161
-		$backgroundExists = true;
162
-		try {
163
-			$this->appData->getFolder('images')->getFile('background');
164
-		} catch (\Exception $e) {
165
-			$backgroundExists = false;
166
-		}
167
-
168
-		if(!$backgroundLogo || !$backgroundExists) {
169
-			return $this->urlGenerator->imagePath('core','background.jpg');
170
-		}
171
-
172
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
173
-	}
174
-
175
-
176
-	/**
177
-	 * @return array scss variables to overwrite
178
-	 */
179
-	public function getScssVariables() {
180
-		$cache = $this->cacheFactory->create('theming');
181
-		if ($value = $cache->get('getScssVariables')) {
182
-			return $value;
183
-		}
184
-
185
-		$variables = [
186
-			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
187
-		];
188
-
189
-		$variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
190
-		$variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'";
191
-
192
-		if ($this->config->getAppValue('theming', 'color', null) !== null) {
193
-			if ($this->util->invertTextColor($this->getColorPrimary())) {
194
-				$colorPrimaryText = '#000000';
195
-			} else {
196
-				$colorPrimaryText = '#ffffff';
197
-			}
198
-			$variables['color-primary'] = $this->getColorPrimary();
199
-			$variables['color-primary-text'] = $colorPrimaryText;
200
-		}
201
-		$cache->set('getScssVariables', $variables);
202
-		return $variables;
203
-	}
204
-
205
-	/**
206
-	 * Check if Imagemagick is enabled and if SVG is supported
207
-	 * otherwise we can't render custom icons
208
-	 *
209
-	 * @return bool
210
-	 */
211
-	public function shouldReplaceIcons() {
212
-		$cache = $this->cacheFactory->create('theming');
213
-		if($value = $cache->get('shouldReplaceIcons')) {
214
-			return (bool)$value;
215
-		}
216
-		$value = false;
217
-		if(extension_loaded('imagick')) {
218
-			$checkImagick = new \Imagick();
219
-			if (count($checkImagick->queryFormats('SVG')) >= 1) {
220
-				$value = true;
221
-			}
222
-			$checkImagick->clear();
223
-		}
224
-		$cache->set('shouldReplaceIcons', $value);
225
-		return $value;
226
-	}
227
-
228
-	/**
229
-	 * Increases the cache buster key
230
-	 */
231
-	private function increaseCacheBuster() {
232
-		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
233
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
234
-		$this->cacheFactory->create('theming')->clear('getScssVariables');
235
-	}
236
-
237
-	/**
238
-	 * Update setting in the database
239
-	 *
240
-	 * @param string $setting
241
-	 * @param string $value
242
-	 */
243
-	public function set($setting, $value) {
244
-		$this->config->setAppValue('theming', $setting, $value);
245
-		$this->increaseCacheBuster();
246
-	}
247
-
248
-	/**
249
-	 * Revert settings to the default value
250
-	 *
251
-	 * @param string $setting setting which should be reverted
252
-	 * @return string default value
253
-	 */
254
-	public function undo($setting) {
255
-		$this->config->deleteAppValue('theming', $setting);
256
-		$this->increaseCacheBuster();
257
-
258
-		switch ($setting) {
259
-			case 'name':
260
-				$returnValue = $this->getEntity();
261
-				break;
262
-			case 'url':
263
-				$returnValue = $this->getBaseUrl();
264
-				break;
265
-			case 'slogan':
266
-				$returnValue = $this->getSlogan();
267
-				break;
268
-			case 'color':
269
-				$returnValue = $this->getColorPrimary();
270
-				break;
271
-			default:
272
-				$returnValue = '';
273
-				break;
274
-		}
275
-
276
-		return $returnValue;
277
-	}
34
+    /** @var IConfig */
35
+    private $config;
36
+    /** @var IL10N */
37
+    private $l;
38
+    /** @var IURLGenerator */
39
+    private $urlGenerator;
40
+    /** @var IAppData */
41
+    private $appData;
42
+    /** @var ICacheFactory */
43
+    private $cacheFactory;
44
+    /** @var string */
45
+    private $name;
46
+    /** @var string */
47
+    private $url;
48
+    /** @var string */
49
+    private $slogan;
50
+    /** @var string */
51
+    private $color;
52
+    /** @var Util */
53
+    private $util;
54
+
55
+    /**
56
+     * ThemingDefaults constructor.
57
+     *
58
+     * @param IConfig $config
59
+     * @param IL10N $l
60
+     * @param IURLGenerator $urlGenerator
61
+     * @param \OC_Defaults $defaults
62
+     * @param IAppData $appData
63
+     * @param ICacheFactory $cacheFactory
64
+     * @param Util $util
65
+     */
66
+    public function __construct(IConfig $config,
67
+                                IL10N $l,
68
+                                IURLGenerator $urlGenerator,
69
+                                IAppData $appData,
70
+                                ICacheFactory $cacheFactory,
71
+                                Util $util
72
+    ) {
73
+        parent::__construct();
74
+        $this->config = $config;
75
+        $this->l = $l;
76
+        $this->urlGenerator = $urlGenerator;
77
+        $this->appData = $appData;
78
+        $this->cacheFactory = $cacheFactory;
79
+        $this->util = $util;
80
+
81
+        $this->name = parent::getName();
82
+        $this->url = parent::getBaseUrl();
83
+        $this->slogan = parent::getSlogan();
84
+        $this->color = parent::getColorPrimary();
85
+    }
86
+
87
+    public function getName() {
88
+        return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
89
+    }
90
+
91
+    public function getHTMLName() {
92
+        return $this->config->getAppValue('theming', 'name', $this->name);
93
+    }
94
+
95
+    public function getTitle() {
96
+        return $this->getName();
97
+    }
98
+
99
+    public function getEntity() {
100
+        return $this->getName();
101
+    }
102
+
103
+    public function getBaseUrl() {
104
+        return $this->config->getAppValue('theming', 'url', $this->url);
105
+    }
106
+
107
+    public function getSlogan() {
108
+        return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
109
+    }
110
+
111
+    public function getShortFooter() {
112
+        $slogan = $this->getSlogan();
113
+        $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
114
+            ' rel="noreferrer">' .$this->getEntity() . '</a>'.
115
+            ($slogan !== '' ? ' – ' . $slogan : '');
116
+
117
+        return $footer;
118
+    }
119
+
120
+    /**
121
+     * Color that is used for the header as well as for mail headers
122
+     *
123
+     * @return string
124
+     */
125
+    public function getColorPrimary() {
126
+        return $this->config->getAppValue('theming', 'color', $this->color);
127
+    }
128
+
129
+    /**
130
+     * Themed logo url
131
+     *
132
+     * @return string
133
+     */
134
+    public function getLogo() {
135
+        $logo = $this->config->getAppValue('theming', 'logoMime', false);
136
+
137
+        $logoExists = true;
138
+        try {
139
+            $this->appData->getFolder('images')->getFile('logo');
140
+        } catch (\Exception $e) {
141
+            $logoExists = false;
142
+        }
143
+
144
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
145
+
146
+        if(!$logo || !$logoExists) {
147
+            return $this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter;
148
+        }
149
+
150
+        return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
151
+    }
152
+
153
+    /**
154
+     * Themed background image url
155
+     *
156
+     * @return string
157
+     */
158
+    public function getBackground() {
159
+        $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
160
+
161
+        $backgroundExists = true;
162
+        try {
163
+            $this->appData->getFolder('images')->getFile('background');
164
+        } catch (\Exception $e) {
165
+            $backgroundExists = false;
166
+        }
167
+
168
+        if(!$backgroundLogo || !$backgroundExists) {
169
+            return $this->urlGenerator->imagePath('core','background.jpg');
170
+        }
171
+
172
+        return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
173
+    }
174
+
175
+
176
+    /**
177
+     * @return array scss variables to overwrite
178
+     */
179
+    public function getScssVariables() {
180
+        $cache = $this->cacheFactory->create('theming');
181
+        if ($value = $cache->get('getScssVariables')) {
182
+            return $value;
183
+        }
184
+
185
+        $variables = [
186
+            'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
187
+        ];
188
+
189
+        $variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
190
+        $variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'";
191
+
192
+        if ($this->config->getAppValue('theming', 'color', null) !== null) {
193
+            if ($this->util->invertTextColor($this->getColorPrimary())) {
194
+                $colorPrimaryText = '#000000';
195
+            } else {
196
+                $colorPrimaryText = '#ffffff';
197
+            }
198
+            $variables['color-primary'] = $this->getColorPrimary();
199
+            $variables['color-primary-text'] = $colorPrimaryText;
200
+        }
201
+        $cache->set('getScssVariables', $variables);
202
+        return $variables;
203
+    }
204
+
205
+    /**
206
+     * Check if Imagemagick is enabled and if SVG is supported
207
+     * otherwise we can't render custom icons
208
+     *
209
+     * @return bool
210
+     */
211
+    public function shouldReplaceIcons() {
212
+        $cache = $this->cacheFactory->create('theming');
213
+        if($value = $cache->get('shouldReplaceIcons')) {
214
+            return (bool)$value;
215
+        }
216
+        $value = false;
217
+        if(extension_loaded('imagick')) {
218
+            $checkImagick = new \Imagick();
219
+            if (count($checkImagick->queryFormats('SVG')) >= 1) {
220
+                $value = true;
221
+            }
222
+            $checkImagick->clear();
223
+        }
224
+        $cache->set('shouldReplaceIcons', $value);
225
+        return $value;
226
+    }
227
+
228
+    /**
229
+     * Increases the cache buster key
230
+     */
231
+    private function increaseCacheBuster() {
232
+        $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
233
+        $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
234
+        $this->cacheFactory->create('theming')->clear('getScssVariables');
235
+    }
236
+
237
+    /**
238
+     * Update setting in the database
239
+     *
240
+     * @param string $setting
241
+     * @param string $value
242
+     */
243
+    public function set($setting, $value) {
244
+        $this->config->setAppValue('theming', $setting, $value);
245
+        $this->increaseCacheBuster();
246
+    }
247
+
248
+    /**
249
+     * Revert settings to the default value
250
+     *
251
+     * @param string $setting setting which should be reverted
252
+     * @return string default value
253
+     */
254
+    public function undo($setting) {
255
+        $this->config->deleteAppValue('theming', $setting);
256
+        $this->increaseCacheBuster();
257
+
258
+        switch ($setting) {
259
+            case 'name':
260
+                $returnValue = $this->getEntity();
261
+                break;
262
+            case 'url':
263
+                $returnValue = $this->getBaseUrl();
264
+                break;
265
+            case 'slogan':
266
+                $returnValue = $this->getSlogan();
267
+                break;
268
+            case 'color':
269
+                $returnValue = $this->getColorPrimary();
270
+                break;
271
+            default:
272
+                $returnValue = '';
273
+                break;
274
+        }
275
+
276
+        return $returnValue;
277
+    }
278 278
 
279 279
 }
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +1646 added lines, -1646 removed lines patch added patch discarded remove patch
@@ -126,1655 +126,1655 @@
 block discarded – undo
126 126
  * TODO: hookup all manager classes
127 127
  */
128 128
 class Server extends ServerContainer implements IServerContainer {
129
-	/** @var string */
130
-	private $webRoot;
131
-
132
-	/**
133
-	 * @param string $webRoot
134
-	 * @param \OC\Config $config
135
-	 */
136
-	public function __construct($webRoot, \OC\Config $config) {
137
-		parent::__construct();
138
-		$this->webRoot = $webRoot;
139
-
140
-		$this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) {
141
-			return $c;
142
-		});
143
-
144
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
145
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
146
-
147
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
148
-
149
-
150
-
151
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
152
-			return new PreviewManager(
153
-				$c->getConfig(),
154
-				$c->getRootFolder(),
155
-				$c->getAppDataDir('preview'),
156
-				$c->getEventDispatcher(),
157
-				$c->getSession()->get('user_id')
158
-			);
159
-		});
160
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
161
-
162
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
163
-			return new \OC\Preview\Watcher(
164
-				$c->getAppDataDir('preview')
165
-			);
166
-		});
167
-
168
-		$this->registerService('EncryptionManager', function (Server $c) {
169
-			$view = new View();
170
-			$util = new Encryption\Util(
171
-				$view,
172
-				$c->getUserManager(),
173
-				$c->getGroupManager(),
174
-				$c->getConfig()
175
-			);
176
-			return new Encryption\Manager(
177
-				$c->getConfig(),
178
-				$c->getLogger(),
179
-				$c->getL10N('core'),
180
-				new View(),
181
-				$util,
182
-				new ArrayCache()
183
-			);
184
-		});
185
-
186
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
187
-			$util = new Encryption\Util(
188
-				new View(),
189
-				$c->getUserManager(),
190
-				$c->getGroupManager(),
191
-				$c->getConfig()
192
-			);
193
-			return new Encryption\File(
194
-				$util,
195
-				$c->getRootFolder(),
196
-				$c->getShareManager()
197
-			);
198
-		});
199
-
200
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
201
-			$view = new View();
202
-			$util = new Encryption\Util(
203
-				$view,
204
-				$c->getUserManager(),
205
-				$c->getGroupManager(),
206
-				$c->getConfig()
207
-			);
208
-
209
-			return new Encryption\Keys\Storage($view, $util);
210
-		});
211
-		$this->registerService('TagMapper', function (Server $c) {
212
-			return new TagMapper($c->getDatabaseConnection());
213
-		});
214
-
215
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
216
-			$tagMapper = $c->query('TagMapper');
217
-			return new TagManager($tagMapper, $c->getUserSession());
218
-		});
219
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
220
-
221
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
222
-			$config = $c->getConfig();
223
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
224
-			/** @var \OC\SystemTag\ManagerFactory $factory */
225
-			$factory = new $factoryClass($this);
226
-			return $factory;
227
-		});
228
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
229
-			return $c->query('SystemTagManagerFactory')->getManager();
230
-		});
231
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
232
-
233
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
234
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
235
-		});
236
-		$this->registerService('RootFolder', function (Server $c) {
237
-			$manager = \OC\Files\Filesystem::getMountManager(null);
238
-			$view = new View();
239
-			$root = new Root(
240
-				$manager,
241
-				$view,
242
-				null,
243
-				$c->getUserMountCache(),
244
-				$this->getLogger(),
245
-				$this->getUserManager()
246
-			);
247
-			$connector = new HookConnector($root, $view);
248
-			$connector->viewToNode();
249
-
250
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
251
-			$previewConnector->connectWatcher();
252
-
253
-			return $root;
254
-		});
255
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
256
-
257
-		$this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
258
-			return new LazyRoot(function() use ($c) {
259
-				return $c->query('RootFolder');
260
-			});
261
-		});
262
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
263
-
264
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
265
-			$config = $c->getConfig();
266
-			return new \OC\User\Manager($config);
267
-		});
268
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
269
-
270
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
271
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
272
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
273
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
274
-			});
275
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
276
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
277
-			});
278
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
279
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
280
-			});
281
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
282
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
283
-			});
284
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
285
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
286
-			});
287
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
288
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
289
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
290
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
291
-			});
292
-			return $groupManager;
293
-		});
294
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
295
-
296
-		$this->registerService(Store::class, function(Server $c) {
297
-			$session = $c->getSession();
298
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
299
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
300
-			} else {
301
-				$tokenProvider = null;
302
-			}
303
-			$logger = $c->getLogger();
304
-			return new Store($session, $logger, $tokenProvider);
305
-		});
306
-		$this->registerAlias(IStore::class, Store::class);
307
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
308
-			$dbConnection = $c->getDatabaseConnection();
309
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
310
-		});
311
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
312
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
313
-			$crypto = $c->getCrypto();
314
-			$config = $c->getConfig();
315
-			$logger = $c->getLogger();
316
-			$timeFactory = new TimeFactory();
317
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
318
-		});
319
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
320
-
321
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
322
-			$manager = $c->getUserManager();
323
-			$session = new \OC\Session\Memory('');
324
-			$timeFactory = new TimeFactory();
325
-			// Token providers might require a working database. This code
326
-			// might however be called when ownCloud is not yet setup.
327
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
328
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
329
-			} else {
330
-				$defaultTokenProvider = null;
331
-			}
332
-
333
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
334
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
335
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
336
-			});
337
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
338
-				/** @var $user \OC\User\User */
339
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
340
-			});
341
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
342
-				/** @var $user \OC\User\User */
343
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
344
-			});
345
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
346
-				/** @var $user \OC\User\User */
347
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
348
-			});
349
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
350
-				/** @var $user \OC\User\User */
351
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
352
-			});
353
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
354
-				/** @var $user \OC\User\User */
355
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
356
-			});
357
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
358
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
359
-			});
360
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
361
-				/** @var $user \OC\User\User */
362
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
363
-			});
364
-			$userSession->listen('\OC\User', 'logout', function () {
365
-				\OC_Hook::emit('OC_User', 'logout', array());
366
-			});
367
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
368
-				/** @var $user \OC\User\User */
369
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
370
-			});
371
-			return $userSession;
372
-		});
373
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
374
-
375
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
376
-			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
377
-		});
378
-
379
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
380
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
381
-
382
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
383
-			return new \OC\AllConfig(
384
-				$c->getSystemConfig()
385
-			);
386
-		});
387
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
388
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
389
-
390
-		$this->registerService('SystemConfig', function ($c) use ($config) {
391
-			return new \OC\SystemConfig($config);
392
-		});
393
-
394
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
395
-			return new \OC\AppConfig($c->getDatabaseConnection());
396
-		});
397
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
398
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
399
-
400
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
401
-			return new \OC\L10N\Factory(
402
-				$c->getConfig(),
403
-				$c->getRequest(),
404
-				$c->getUserSession(),
405
-				\OC::$SERVERROOT
406
-			);
407
-		});
408
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
409
-
410
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
411
-			$config = $c->getConfig();
412
-			$cacheFactory = $c->getMemCacheFactory();
413
-			return new \OC\URLGenerator(
414
-				$config,
415
-				$cacheFactory
416
-			);
417
-		});
418
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
419
-
420
-		$this->registerService('AppHelper', function ($c) {
421
-			return new \OC\AppHelper();
422
-		});
423
-		$this->registerService('AppFetcher', function ($c) {
424
-			return new AppFetcher(
425
-				$this->getAppDataDir('appstore'),
426
-				$this->getHTTPClientService(),
427
-				$this->query(TimeFactory::class),
428
-				$this->getConfig()
429
-			);
430
-		});
431
-		$this->registerService('CategoryFetcher', function ($c) {
432
-			return new CategoryFetcher(
433
-				$this->getAppDataDir('appstore'),
434
-				$this->getHTTPClientService(),
435
-				$this->query(TimeFactory::class),
436
-				$this->getConfig()
437
-			);
438
-		});
439
-
440
-		$this->registerService(\OCP\ICache::class, function ($c) {
441
-			return new Cache\File();
442
-		});
443
-		$this->registerAlias('UserCache', \OCP\ICache::class);
444
-
445
-		$this->registerService(Factory::class, function (Server $c) {
446
-			$config = $c->getConfig();
447
-
448
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
449
-				$v = \OC_App::getAppVersions();
450
-				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
451
-				$version = implode(',', $v);
452
-				$instanceId = \OC_Util::getInstanceId();
453
-				$path = \OC::$SERVERROOT;
454
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
455
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
456
-					$config->getSystemValue('memcache.local', null),
457
-					$config->getSystemValue('memcache.distributed', null),
458
-					$config->getSystemValue('memcache.locking', null)
459
-				);
460
-			}
461
-
462
-			return new \OC\Memcache\Factory('', $c->getLogger(),
463
-				'\\OC\\Memcache\\ArrayCache',
464
-				'\\OC\\Memcache\\ArrayCache',
465
-				'\\OC\\Memcache\\ArrayCache'
466
-			);
467
-		});
468
-		$this->registerAlias('MemCacheFactory', Factory::class);
469
-		$this->registerAlias(ICacheFactory::class, Factory::class);
470
-
471
-		$this->registerService('RedisFactory', function (Server $c) {
472
-			$systemConfig = $c->getSystemConfig();
473
-			return new RedisFactory($systemConfig);
474
-		});
475
-
476
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
477
-			return new \OC\Activity\Manager(
478
-				$c->getRequest(),
479
-				$c->getUserSession(),
480
-				$c->getConfig(),
481
-				$c->query(IValidator::class)
482
-			);
483
-		});
484
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
485
-
486
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
487
-			return new \OC\Activity\EventMerger(
488
-				$c->getL10N('lib')
489
-			);
490
-		});
491
-		$this->registerAlias(IValidator::class, Validator::class);
492
-
493
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
494
-			return new AvatarManager(
495
-				$c->getUserManager(),
496
-				$c->getAppDataDir('avatar'),
497
-				$c->getL10N('lib'),
498
-				$c->getLogger(),
499
-				$c->getConfig()
500
-			);
501
-		});
502
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
503
-
504
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
505
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
506
-			$logger = Log::getLogClass($logType);
507
-			call_user_func(array($logger, 'init'));
508
-
509
-			return new Log($logger);
510
-		});
511
-		$this->registerAlias('Logger', \OCP\ILogger::class);
512
-
513
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
514
-			$config = $c->getConfig();
515
-			return new \OC\BackgroundJob\JobList(
516
-				$c->getDatabaseConnection(),
517
-				$config,
518
-				new TimeFactory()
519
-			);
520
-		});
521
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
522
-
523
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
524
-			$cacheFactory = $c->getMemCacheFactory();
525
-			$logger = $c->getLogger();
526
-			if ($cacheFactory->isAvailable()) {
527
-				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
528
-			} else {
529
-				$router = new \OC\Route\Router($logger);
530
-			}
531
-			return $router;
532
-		});
533
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
534
-
535
-		$this->registerService(\OCP\ISearch::class, function ($c) {
536
-			return new Search();
537
-		});
538
-		$this->registerAlias('Search', \OCP\ISearch::class);
539
-
540
-		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) {
541
-			return new \OC\Security\RateLimiting\Limiter(
542
-				$this->getUserSession(),
543
-				$this->getRequest(),
544
-				new \OC\AppFramework\Utility\TimeFactory(),
545
-				$c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
546
-			);
547
-		});
548
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
549
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
550
-				$this->getMemCacheFactory(),
551
-				new \OC\AppFramework\Utility\TimeFactory()
552
-			);
553
-		});
554
-
555
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
556
-			return new SecureRandom();
557
-		});
558
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
559
-
560
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
561
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
562
-		});
563
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
564
-
565
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
566
-			return new Hasher($c->getConfig());
567
-		});
568
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
569
-
570
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
571
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
572
-		});
573
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
574
-
575
-		$this->registerService(IDBConnection::class, function (Server $c) {
576
-			$systemConfig = $c->getSystemConfig();
577
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
578
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
579
-			if (!$factory->isValidType($type)) {
580
-				throw new \OC\DatabaseException('Invalid database type');
581
-			}
582
-			$connectionParams = $factory->createConnectionParams();
583
-			$connection = $factory->getConnection($type, $connectionParams);
584
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
585
-			return $connection;
586
-		});
587
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
588
-
589
-		$this->registerService('HTTPHelper', function (Server $c) {
590
-			$config = $c->getConfig();
591
-			return new HTTPHelper(
592
-				$config,
593
-				$c->getHTTPClientService()
594
-			);
595
-		});
596
-
597
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
598
-			$user = \OC_User::getUser();
599
-			$uid = $user ? $user : null;
600
-			return new ClientService(
601
-				$c->getConfig(),
602
-				new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
603
-			);
604
-		});
605
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
606
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
607
-			$eventLogger = new EventLogger();
608
-			if ($c->getSystemConfig()->getValue('debug', false)) {
609
-				// In debug mode, module is being activated by default
610
-				$eventLogger->activate();
611
-			}
612
-			return $eventLogger;
613
-		});
614
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
615
-
616
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
617
-			$queryLogger = new QueryLogger();
618
-			if ($c->getSystemConfig()->getValue('debug', false)) {
619
-				// In debug mode, module is being activated by default
620
-				$queryLogger->activate();
621
-			}
622
-			return $queryLogger;
623
-		});
624
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
625
-
626
-		$this->registerService(TempManager::class, function (Server $c) {
627
-			return new TempManager(
628
-				$c->getLogger(),
629
-				$c->getConfig()
630
-			);
631
-		});
632
-		$this->registerAlias('TempManager', TempManager::class);
633
-		$this->registerAlias(ITempManager::class, TempManager::class);
634
-
635
-		$this->registerService(AppManager::class, function (Server $c) {
636
-			return new \OC\App\AppManager(
637
-				$c->getUserSession(),
638
-				$c->getAppConfig(),
639
-				$c->getGroupManager(),
640
-				$c->getMemCacheFactory(),
641
-				$c->getEventDispatcher()
642
-			);
643
-		});
644
-		$this->registerAlias('AppManager', AppManager::class);
645
-		$this->registerAlias(IAppManager::class, AppManager::class);
646
-
647
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
648
-			return new DateTimeZone(
649
-				$c->getConfig(),
650
-				$c->getSession()
651
-			);
652
-		});
653
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
654
-
655
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
656
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
657
-
658
-			return new DateTimeFormatter(
659
-				$c->getDateTimeZone()->getTimeZone(),
660
-				$c->getL10N('lib', $language)
661
-			);
662
-		});
663
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
664
-
665
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
666
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
667
-			$listener = new UserMountCacheListener($mountCache);
668
-			$listener->listen($c->getUserManager());
669
-			return $mountCache;
670
-		});
671
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
672
-
673
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
674
-			$loader = \OC\Files\Filesystem::getLoader();
675
-			$mountCache = $c->query('UserMountCache');
676
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
677
-
678
-			// builtin providers
679
-
680
-			$config = $c->getConfig();
681
-			$manager->registerProvider(new CacheMountProvider($config));
682
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
683
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
684
-
685
-			return $manager;
686
-		});
687
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
688
-
689
-		$this->registerService('IniWrapper', function ($c) {
690
-			return new IniGetWrapper();
691
-		});
692
-		$this->registerService('AsyncCommandBus', function (Server $c) {
693
-			$jobList = $c->getJobList();
694
-			return new AsyncBus($jobList);
695
-		});
696
-		$this->registerService('TrustedDomainHelper', function ($c) {
697
-			return new TrustedDomainHelper($this->getConfig());
698
-		});
699
-		$this->registerService('Throttler', function(Server $c) {
700
-			return new Throttler(
701
-				$c->getDatabaseConnection(),
702
-				new TimeFactory(),
703
-				$c->getLogger(),
704
-				$c->getConfig()
705
-			);
706
-		});
707
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
708
-			// IConfig and IAppManager requires a working database. This code
709
-			// might however be called when ownCloud is not yet setup.
710
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
711
-				$config = $c->getConfig();
712
-				$appManager = $c->getAppManager();
713
-			} else {
714
-				$config = null;
715
-				$appManager = null;
716
-			}
717
-
718
-			return new Checker(
719
-					new EnvironmentHelper(),
720
-					new FileAccessHelper(),
721
-					new AppLocator(),
722
-					$config,
723
-					$c->getMemCacheFactory(),
724
-					$appManager,
725
-					$c->getTempManager()
726
-			);
727
-		});
728
-		$this->registerService(\OCP\IRequest::class, function ($c) {
729
-			if (isset($this['urlParams'])) {
730
-				$urlParams = $this['urlParams'];
731
-			} else {
732
-				$urlParams = [];
733
-			}
734
-
735
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
736
-				&& in_array('fakeinput', stream_get_wrappers())
737
-			) {
738
-				$stream = 'fakeinput://data';
739
-			} else {
740
-				$stream = 'php://input';
741
-			}
742
-
743
-			return new Request(
744
-				[
745
-					'get' => $_GET,
746
-					'post' => $_POST,
747
-					'files' => $_FILES,
748
-					'server' => $_SERVER,
749
-					'env' => $_ENV,
750
-					'cookies' => $_COOKIE,
751
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
752
-						? $_SERVER['REQUEST_METHOD']
753
-						: null,
754
-					'urlParams' => $urlParams,
755
-				],
756
-				$this->getSecureRandom(),
757
-				$this->getConfig(),
758
-				$this->getCsrfTokenManager(),
759
-				$stream
760
-			);
761
-		});
762
-		$this->registerAlias('Request', \OCP\IRequest::class);
763
-
764
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
765
-			return new Mailer(
766
-				$c->getConfig(),
767
-				$c->getLogger(),
768
-				$c->query(Defaults::class),
769
-				$c->getURLGenerator(),
770
-				$c->getL10N('lib')
771
-			);
772
-		});
773
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
774
-
775
-		$this->registerService('LDAPProvider', function(Server $c) {
776
-			$config = $c->getConfig();
777
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
778
-			if(is_null($factoryClass)) {
779
-				throw new \Exception('ldapProviderFactory not set');
780
-			}
781
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
782
-			$factory = new $factoryClass($this);
783
-			return $factory->getLDAPProvider();
784
-		});
785
-		$this->registerService('LockingProvider', function (Server $c) {
786
-			$ini = $c->getIniWrapper();
787
-			$config = $c->getConfig();
788
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
789
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
790
-				/** @var \OC\Memcache\Factory $memcacheFactory */
791
-				$memcacheFactory = $c->getMemCacheFactory();
792
-				$memcache = $memcacheFactory->createLocking('lock');
793
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
794
-					return new MemcacheLockingProvider($memcache, $ttl);
795
-				}
796
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
797
-			}
798
-			return new NoopLockingProvider();
799
-		});
800
-
801
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
802
-			return new \OC\Files\Mount\Manager();
803
-		});
804
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
805
-
806
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
807
-			return new \OC\Files\Type\Detection(
808
-				$c->getURLGenerator(),
809
-				\OC::$configDir,
810
-				\OC::$SERVERROOT . '/resources/config/'
811
-			);
812
-		});
813
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
814
-
815
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
816
-			return new \OC\Files\Type\Loader(
817
-				$c->getDatabaseConnection()
818
-			);
819
-		});
820
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
821
-		$this->registerService(BundleFetcher::class, function () {
822
-			return new BundleFetcher($this->getL10N('lib'));
823
-		});
824
-		$this->registerService(AppFetcher::class, function() {
825
-			return $this->getAppFetcher();
826
-		});
827
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
828
-			return new Manager(
829
-				$c->query(IValidator::class)
830
-			);
831
-		});
832
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
833
-
834
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
835
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
836
-			$manager->registerCapability(function () use ($c) {
837
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
838
-			});
839
-			return $manager;
840
-		});
841
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
842
-
843
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
844
-			$config = $c->getConfig();
845
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
846
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
847
-			$factory = new $factoryClass($this);
848
-			return $factory->getManager();
849
-		});
850
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
851
-
852
-		$this->registerService('ThemingDefaults', function(Server $c) {
853
-			/*
129
+    /** @var string */
130
+    private $webRoot;
131
+
132
+    /**
133
+     * @param string $webRoot
134
+     * @param \OC\Config $config
135
+     */
136
+    public function __construct($webRoot, \OC\Config $config) {
137
+        parent::__construct();
138
+        $this->webRoot = $webRoot;
139
+
140
+        $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) {
141
+            return $c;
142
+        });
143
+
144
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
145
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
146
+
147
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
148
+
149
+
150
+
151
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
152
+            return new PreviewManager(
153
+                $c->getConfig(),
154
+                $c->getRootFolder(),
155
+                $c->getAppDataDir('preview'),
156
+                $c->getEventDispatcher(),
157
+                $c->getSession()->get('user_id')
158
+            );
159
+        });
160
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
161
+
162
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
163
+            return new \OC\Preview\Watcher(
164
+                $c->getAppDataDir('preview')
165
+            );
166
+        });
167
+
168
+        $this->registerService('EncryptionManager', function (Server $c) {
169
+            $view = new View();
170
+            $util = new Encryption\Util(
171
+                $view,
172
+                $c->getUserManager(),
173
+                $c->getGroupManager(),
174
+                $c->getConfig()
175
+            );
176
+            return new Encryption\Manager(
177
+                $c->getConfig(),
178
+                $c->getLogger(),
179
+                $c->getL10N('core'),
180
+                new View(),
181
+                $util,
182
+                new ArrayCache()
183
+            );
184
+        });
185
+
186
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
187
+            $util = new Encryption\Util(
188
+                new View(),
189
+                $c->getUserManager(),
190
+                $c->getGroupManager(),
191
+                $c->getConfig()
192
+            );
193
+            return new Encryption\File(
194
+                $util,
195
+                $c->getRootFolder(),
196
+                $c->getShareManager()
197
+            );
198
+        });
199
+
200
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
201
+            $view = new View();
202
+            $util = new Encryption\Util(
203
+                $view,
204
+                $c->getUserManager(),
205
+                $c->getGroupManager(),
206
+                $c->getConfig()
207
+            );
208
+
209
+            return new Encryption\Keys\Storage($view, $util);
210
+        });
211
+        $this->registerService('TagMapper', function (Server $c) {
212
+            return new TagMapper($c->getDatabaseConnection());
213
+        });
214
+
215
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
216
+            $tagMapper = $c->query('TagMapper');
217
+            return new TagManager($tagMapper, $c->getUserSession());
218
+        });
219
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
220
+
221
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
222
+            $config = $c->getConfig();
223
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
224
+            /** @var \OC\SystemTag\ManagerFactory $factory */
225
+            $factory = new $factoryClass($this);
226
+            return $factory;
227
+        });
228
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
229
+            return $c->query('SystemTagManagerFactory')->getManager();
230
+        });
231
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
232
+
233
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
234
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
235
+        });
236
+        $this->registerService('RootFolder', function (Server $c) {
237
+            $manager = \OC\Files\Filesystem::getMountManager(null);
238
+            $view = new View();
239
+            $root = new Root(
240
+                $manager,
241
+                $view,
242
+                null,
243
+                $c->getUserMountCache(),
244
+                $this->getLogger(),
245
+                $this->getUserManager()
246
+            );
247
+            $connector = new HookConnector($root, $view);
248
+            $connector->viewToNode();
249
+
250
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
251
+            $previewConnector->connectWatcher();
252
+
253
+            return $root;
254
+        });
255
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
256
+
257
+        $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
258
+            return new LazyRoot(function() use ($c) {
259
+                return $c->query('RootFolder');
260
+            });
261
+        });
262
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
263
+
264
+        $this->registerService(\OCP\IUserManager::class, function (Server $c) {
265
+            $config = $c->getConfig();
266
+            return new \OC\User\Manager($config);
267
+        });
268
+        $this->registerAlias('UserManager', \OCP\IUserManager::class);
269
+
270
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
271
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
272
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
273
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
274
+            });
275
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
276
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
277
+            });
278
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
279
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
280
+            });
281
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
282
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
283
+            });
284
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
285
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
286
+            });
287
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
288
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
289
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
290
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
291
+            });
292
+            return $groupManager;
293
+        });
294
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
295
+
296
+        $this->registerService(Store::class, function(Server $c) {
297
+            $session = $c->getSession();
298
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
299
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
300
+            } else {
301
+                $tokenProvider = null;
302
+            }
303
+            $logger = $c->getLogger();
304
+            return new Store($session, $logger, $tokenProvider);
305
+        });
306
+        $this->registerAlias(IStore::class, Store::class);
307
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
308
+            $dbConnection = $c->getDatabaseConnection();
309
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
310
+        });
311
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
312
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
313
+            $crypto = $c->getCrypto();
314
+            $config = $c->getConfig();
315
+            $logger = $c->getLogger();
316
+            $timeFactory = new TimeFactory();
317
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
318
+        });
319
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
320
+
321
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
322
+            $manager = $c->getUserManager();
323
+            $session = new \OC\Session\Memory('');
324
+            $timeFactory = new TimeFactory();
325
+            // Token providers might require a working database. This code
326
+            // might however be called when ownCloud is not yet setup.
327
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
328
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
329
+            } else {
330
+                $defaultTokenProvider = null;
331
+            }
332
+
333
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
334
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
335
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
336
+            });
337
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
338
+                /** @var $user \OC\User\User */
339
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
340
+            });
341
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
342
+                /** @var $user \OC\User\User */
343
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
344
+            });
345
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
346
+                /** @var $user \OC\User\User */
347
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
348
+            });
349
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
350
+                /** @var $user \OC\User\User */
351
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
352
+            });
353
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
354
+                /** @var $user \OC\User\User */
355
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
356
+            });
357
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
358
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
359
+            });
360
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
361
+                /** @var $user \OC\User\User */
362
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
363
+            });
364
+            $userSession->listen('\OC\User', 'logout', function () {
365
+                \OC_Hook::emit('OC_User', 'logout', array());
366
+            });
367
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
368
+                /** @var $user \OC\User\User */
369
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
370
+            });
371
+            return $userSession;
372
+        });
373
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
374
+
375
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
376
+            return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
377
+        });
378
+
379
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
380
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
381
+
382
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
383
+            return new \OC\AllConfig(
384
+                $c->getSystemConfig()
385
+            );
386
+        });
387
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
388
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
389
+
390
+        $this->registerService('SystemConfig', function ($c) use ($config) {
391
+            return new \OC\SystemConfig($config);
392
+        });
393
+
394
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
395
+            return new \OC\AppConfig($c->getDatabaseConnection());
396
+        });
397
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
398
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
399
+
400
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
401
+            return new \OC\L10N\Factory(
402
+                $c->getConfig(),
403
+                $c->getRequest(),
404
+                $c->getUserSession(),
405
+                \OC::$SERVERROOT
406
+            );
407
+        });
408
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
409
+
410
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
411
+            $config = $c->getConfig();
412
+            $cacheFactory = $c->getMemCacheFactory();
413
+            return new \OC\URLGenerator(
414
+                $config,
415
+                $cacheFactory
416
+            );
417
+        });
418
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
419
+
420
+        $this->registerService('AppHelper', function ($c) {
421
+            return new \OC\AppHelper();
422
+        });
423
+        $this->registerService('AppFetcher', function ($c) {
424
+            return new AppFetcher(
425
+                $this->getAppDataDir('appstore'),
426
+                $this->getHTTPClientService(),
427
+                $this->query(TimeFactory::class),
428
+                $this->getConfig()
429
+            );
430
+        });
431
+        $this->registerService('CategoryFetcher', function ($c) {
432
+            return new CategoryFetcher(
433
+                $this->getAppDataDir('appstore'),
434
+                $this->getHTTPClientService(),
435
+                $this->query(TimeFactory::class),
436
+                $this->getConfig()
437
+            );
438
+        });
439
+
440
+        $this->registerService(\OCP\ICache::class, function ($c) {
441
+            return new Cache\File();
442
+        });
443
+        $this->registerAlias('UserCache', \OCP\ICache::class);
444
+
445
+        $this->registerService(Factory::class, function (Server $c) {
446
+            $config = $c->getConfig();
447
+
448
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
449
+                $v = \OC_App::getAppVersions();
450
+                $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
451
+                $version = implode(',', $v);
452
+                $instanceId = \OC_Util::getInstanceId();
453
+                $path = \OC::$SERVERROOT;
454
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
455
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
456
+                    $config->getSystemValue('memcache.local', null),
457
+                    $config->getSystemValue('memcache.distributed', null),
458
+                    $config->getSystemValue('memcache.locking', null)
459
+                );
460
+            }
461
+
462
+            return new \OC\Memcache\Factory('', $c->getLogger(),
463
+                '\\OC\\Memcache\\ArrayCache',
464
+                '\\OC\\Memcache\\ArrayCache',
465
+                '\\OC\\Memcache\\ArrayCache'
466
+            );
467
+        });
468
+        $this->registerAlias('MemCacheFactory', Factory::class);
469
+        $this->registerAlias(ICacheFactory::class, Factory::class);
470
+
471
+        $this->registerService('RedisFactory', function (Server $c) {
472
+            $systemConfig = $c->getSystemConfig();
473
+            return new RedisFactory($systemConfig);
474
+        });
475
+
476
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
477
+            return new \OC\Activity\Manager(
478
+                $c->getRequest(),
479
+                $c->getUserSession(),
480
+                $c->getConfig(),
481
+                $c->query(IValidator::class)
482
+            );
483
+        });
484
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
485
+
486
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
487
+            return new \OC\Activity\EventMerger(
488
+                $c->getL10N('lib')
489
+            );
490
+        });
491
+        $this->registerAlias(IValidator::class, Validator::class);
492
+
493
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
494
+            return new AvatarManager(
495
+                $c->getUserManager(),
496
+                $c->getAppDataDir('avatar'),
497
+                $c->getL10N('lib'),
498
+                $c->getLogger(),
499
+                $c->getConfig()
500
+            );
501
+        });
502
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
503
+
504
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
505
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
506
+            $logger = Log::getLogClass($logType);
507
+            call_user_func(array($logger, 'init'));
508
+
509
+            return new Log($logger);
510
+        });
511
+        $this->registerAlias('Logger', \OCP\ILogger::class);
512
+
513
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
514
+            $config = $c->getConfig();
515
+            return new \OC\BackgroundJob\JobList(
516
+                $c->getDatabaseConnection(),
517
+                $config,
518
+                new TimeFactory()
519
+            );
520
+        });
521
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
522
+
523
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
524
+            $cacheFactory = $c->getMemCacheFactory();
525
+            $logger = $c->getLogger();
526
+            if ($cacheFactory->isAvailable()) {
527
+                $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
528
+            } else {
529
+                $router = new \OC\Route\Router($logger);
530
+            }
531
+            return $router;
532
+        });
533
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
534
+
535
+        $this->registerService(\OCP\ISearch::class, function ($c) {
536
+            return new Search();
537
+        });
538
+        $this->registerAlias('Search', \OCP\ISearch::class);
539
+
540
+        $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) {
541
+            return new \OC\Security\RateLimiting\Limiter(
542
+                $this->getUserSession(),
543
+                $this->getRequest(),
544
+                new \OC\AppFramework\Utility\TimeFactory(),
545
+                $c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
546
+            );
547
+        });
548
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
549
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
550
+                $this->getMemCacheFactory(),
551
+                new \OC\AppFramework\Utility\TimeFactory()
552
+            );
553
+        });
554
+
555
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
556
+            return new SecureRandom();
557
+        });
558
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
559
+
560
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
561
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
562
+        });
563
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
564
+
565
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
566
+            return new Hasher($c->getConfig());
567
+        });
568
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
569
+
570
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
571
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
572
+        });
573
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
574
+
575
+        $this->registerService(IDBConnection::class, function (Server $c) {
576
+            $systemConfig = $c->getSystemConfig();
577
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
578
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
579
+            if (!$factory->isValidType($type)) {
580
+                throw new \OC\DatabaseException('Invalid database type');
581
+            }
582
+            $connectionParams = $factory->createConnectionParams();
583
+            $connection = $factory->getConnection($type, $connectionParams);
584
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
585
+            return $connection;
586
+        });
587
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
588
+
589
+        $this->registerService('HTTPHelper', function (Server $c) {
590
+            $config = $c->getConfig();
591
+            return new HTTPHelper(
592
+                $config,
593
+                $c->getHTTPClientService()
594
+            );
595
+        });
596
+
597
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
598
+            $user = \OC_User::getUser();
599
+            $uid = $user ? $user : null;
600
+            return new ClientService(
601
+                $c->getConfig(),
602
+                new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
603
+            );
604
+        });
605
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
606
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
607
+            $eventLogger = new EventLogger();
608
+            if ($c->getSystemConfig()->getValue('debug', false)) {
609
+                // In debug mode, module is being activated by default
610
+                $eventLogger->activate();
611
+            }
612
+            return $eventLogger;
613
+        });
614
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
615
+
616
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
617
+            $queryLogger = new QueryLogger();
618
+            if ($c->getSystemConfig()->getValue('debug', false)) {
619
+                // In debug mode, module is being activated by default
620
+                $queryLogger->activate();
621
+            }
622
+            return $queryLogger;
623
+        });
624
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
625
+
626
+        $this->registerService(TempManager::class, function (Server $c) {
627
+            return new TempManager(
628
+                $c->getLogger(),
629
+                $c->getConfig()
630
+            );
631
+        });
632
+        $this->registerAlias('TempManager', TempManager::class);
633
+        $this->registerAlias(ITempManager::class, TempManager::class);
634
+
635
+        $this->registerService(AppManager::class, function (Server $c) {
636
+            return new \OC\App\AppManager(
637
+                $c->getUserSession(),
638
+                $c->getAppConfig(),
639
+                $c->getGroupManager(),
640
+                $c->getMemCacheFactory(),
641
+                $c->getEventDispatcher()
642
+            );
643
+        });
644
+        $this->registerAlias('AppManager', AppManager::class);
645
+        $this->registerAlias(IAppManager::class, AppManager::class);
646
+
647
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
648
+            return new DateTimeZone(
649
+                $c->getConfig(),
650
+                $c->getSession()
651
+            );
652
+        });
653
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
654
+
655
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
656
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
657
+
658
+            return new DateTimeFormatter(
659
+                $c->getDateTimeZone()->getTimeZone(),
660
+                $c->getL10N('lib', $language)
661
+            );
662
+        });
663
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
664
+
665
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
666
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
667
+            $listener = new UserMountCacheListener($mountCache);
668
+            $listener->listen($c->getUserManager());
669
+            return $mountCache;
670
+        });
671
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
672
+
673
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
674
+            $loader = \OC\Files\Filesystem::getLoader();
675
+            $mountCache = $c->query('UserMountCache');
676
+            $manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
677
+
678
+            // builtin providers
679
+
680
+            $config = $c->getConfig();
681
+            $manager->registerProvider(new CacheMountProvider($config));
682
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
683
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
684
+
685
+            return $manager;
686
+        });
687
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
688
+
689
+        $this->registerService('IniWrapper', function ($c) {
690
+            return new IniGetWrapper();
691
+        });
692
+        $this->registerService('AsyncCommandBus', function (Server $c) {
693
+            $jobList = $c->getJobList();
694
+            return new AsyncBus($jobList);
695
+        });
696
+        $this->registerService('TrustedDomainHelper', function ($c) {
697
+            return new TrustedDomainHelper($this->getConfig());
698
+        });
699
+        $this->registerService('Throttler', function(Server $c) {
700
+            return new Throttler(
701
+                $c->getDatabaseConnection(),
702
+                new TimeFactory(),
703
+                $c->getLogger(),
704
+                $c->getConfig()
705
+            );
706
+        });
707
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
708
+            // IConfig and IAppManager requires a working database. This code
709
+            // might however be called when ownCloud is not yet setup.
710
+            if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
711
+                $config = $c->getConfig();
712
+                $appManager = $c->getAppManager();
713
+            } else {
714
+                $config = null;
715
+                $appManager = null;
716
+            }
717
+
718
+            return new Checker(
719
+                    new EnvironmentHelper(),
720
+                    new FileAccessHelper(),
721
+                    new AppLocator(),
722
+                    $config,
723
+                    $c->getMemCacheFactory(),
724
+                    $appManager,
725
+                    $c->getTempManager()
726
+            );
727
+        });
728
+        $this->registerService(\OCP\IRequest::class, function ($c) {
729
+            if (isset($this['urlParams'])) {
730
+                $urlParams = $this['urlParams'];
731
+            } else {
732
+                $urlParams = [];
733
+            }
734
+
735
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
736
+                && in_array('fakeinput', stream_get_wrappers())
737
+            ) {
738
+                $stream = 'fakeinput://data';
739
+            } else {
740
+                $stream = 'php://input';
741
+            }
742
+
743
+            return new Request(
744
+                [
745
+                    'get' => $_GET,
746
+                    'post' => $_POST,
747
+                    'files' => $_FILES,
748
+                    'server' => $_SERVER,
749
+                    'env' => $_ENV,
750
+                    'cookies' => $_COOKIE,
751
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
752
+                        ? $_SERVER['REQUEST_METHOD']
753
+                        : null,
754
+                    'urlParams' => $urlParams,
755
+                ],
756
+                $this->getSecureRandom(),
757
+                $this->getConfig(),
758
+                $this->getCsrfTokenManager(),
759
+                $stream
760
+            );
761
+        });
762
+        $this->registerAlias('Request', \OCP\IRequest::class);
763
+
764
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
765
+            return new Mailer(
766
+                $c->getConfig(),
767
+                $c->getLogger(),
768
+                $c->query(Defaults::class),
769
+                $c->getURLGenerator(),
770
+                $c->getL10N('lib')
771
+            );
772
+        });
773
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
774
+
775
+        $this->registerService('LDAPProvider', function(Server $c) {
776
+            $config = $c->getConfig();
777
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
778
+            if(is_null($factoryClass)) {
779
+                throw new \Exception('ldapProviderFactory not set');
780
+            }
781
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
782
+            $factory = new $factoryClass($this);
783
+            return $factory->getLDAPProvider();
784
+        });
785
+        $this->registerService('LockingProvider', function (Server $c) {
786
+            $ini = $c->getIniWrapper();
787
+            $config = $c->getConfig();
788
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
789
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
790
+                /** @var \OC\Memcache\Factory $memcacheFactory */
791
+                $memcacheFactory = $c->getMemCacheFactory();
792
+                $memcache = $memcacheFactory->createLocking('lock');
793
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
794
+                    return new MemcacheLockingProvider($memcache, $ttl);
795
+                }
796
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
797
+            }
798
+            return new NoopLockingProvider();
799
+        });
800
+
801
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
802
+            return new \OC\Files\Mount\Manager();
803
+        });
804
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
805
+
806
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
807
+            return new \OC\Files\Type\Detection(
808
+                $c->getURLGenerator(),
809
+                \OC::$configDir,
810
+                \OC::$SERVERROOT . '/resources/config/'
811
+            );
812
+        });
813
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
814
+
815
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
816
+            return new \OC\Files\Type\Loader(
817
+                $c->getDatabaseConnection()
818
+            );
819
+        });
820
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
821
+        $this->registerService(BundleFetcher::class, function () {
822
+            return new BundleFetcher($this->getL10N('lib'));
823
+        });
824
+        $this->registerService(AppFetcher::class, function() {
825
+            return $this->getAppFetcher();
826
+        });
827
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
828
+            return new Manager(
829
+                $c->query(IValidator::class)
830
+            );
831
+        });
832
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
833
+
834
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
835
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
836
+            $manager->registerCapability(function () use ($c) {
837
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
838
+            });
839
+            return $manager;
840
+        });
841
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
842
+
843
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
844
+            $config = $c->getConfig();
845
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
846
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
847
+            $factory = new $factoryClass($this);
848
+            return $factory->getManager();
849
+        });
850
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
851
+
852
+        $this->registerService('ThemingDefaults', function(Server $c) {
853
+            /*
854 854
 			 * Dark magic for autoloader.
855 855
 			 * If we do a class_exists it will try to load the class which will
856 856
 			 * make composer cache the result. Resulting in errors when enabling
857 857
 			 * the theming app.
858 858
 			 */
859
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
860
-			if (isset($prefixes['OCA\\Theming\\'])) {
861
-				$classExists = true;
862
-			} else {
863
-				$classExists = false;
864
-			}
865
-
866
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
867
-				return new ThemingDefaults(
868
-					$c->getConfig(),
869
-					$c->getL10N('theming'),
870
-					$c->getURLGenerator(),
871
-					$c->getAppDataDir('theming'),
872
-					$c->getMemCacheFactory(),
873
-					new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager())
874
-				);
875
-			}
876
-			return new \OC_Defaults();
877
-		});
878
-		$this->registerService(SCSSCacher::class, function(Server $c) {
879
-			/** @var Factory $cacheFactory */
880
-			$cacheFactory = $c->query(Factory::class);
881
-			return new SCSSCacher(
882
-				$c->getLogger(),
883
-				$c->query(\OC\Files\AppData\Factory::class),
884
-				$c->getURLGenerator(),
885
-				$c->getConfig(),
886
-				$c->getThemingDefaults(),
887
-				\OC::$SERVERROOT,
888
-				$cacheFactory->createLocal('SCSS')
889
-			);
890
-		});
891
-		$this->registerService(EventDispatcher::class, function () {
892
-			return new EventDispatcher();
893
-		});
894
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
895
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
896
-
897
-		$this->registerService('CryptoWrapper', function (Server $c) {
898
-			// FIXME: Instantiiated here due to cyclic dependency
899
-			$request = new Request(
900
-				[
901
-					'get' => $_GET,
902
-					'post' => $_POST,
903
-					'files' => $_FILES,
904
-					'server' => $_SERVER,
905
-					'env' => $_ENV,
906
-					'cookies' => $_COOKIE,
907
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
908
-						? $_SERVER['REQUEST_METHOD']
909
-						: null,
910
-				],
911
-				$c->getSecureRandom(),
912
-				$c->getConfig()
913
-			);
914
-
915
-			return new CryptoWrapper(
916
-				$c->getConfig(),
917
-				$c->getCrypto(),
918
-				$c->getSecureRandom(),
919
-				$request
920
-			);
921
-		});
922
-		$this->registerService('CsrfTokenManager', function (Server $c) {
923
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
924
-
925
-			return new CsrfTokenManager(
926
-				$tokenGenerator,
927
-				$c->query(SessionStorage::class)
928
-			);
929
-		});
930
-		$this->registerService(SessionStorage::class, function (Server $c) {
931
-			return new SessionStorage($c->getSession());
932
-		});
933
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
934
-			return new ContentSecurityPolicyManager();
935
-		});
936
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
937
-
938
-		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
939
-			return new ContentSecurityPolicyNonceManager(
940
-				$c->getCsrfTokenManager(),
941
-				$c->getRequest()
942
-			);
943
-		});
944
-
945
-		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
946
-			$config = $c->getConfig();
947
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
948
-			/** @var \OCP\Share\IProviderFactory $factory */
949
-			$factory = new $factoryClass($this);
950
-
951
-			$manager = new \OC\Share20\Manager(
952
-				$c->getLogger(),
953
-				$c->getConfig(),
954
-				$c->getSecureRandom(),
955
-				$c->getHasher(),
956
-				$c->getMountManager(),
957
-				$c->getGroupManager(),
958
-				$c->getL10N('core'),
959
-				$factory,
960
-				$c->getUserManager(),
961
-				$c->getLazyRootFolder(),
962
-				$c->getEventDispatcher()
963
-			);
964
-
965
-			return $manager;
966
-		});
967
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
968
-
969
-		$this->registerService('SettingsManager', function(Server $c) {
970
-			$manager = new \OC\Settings\Manager(
971
-				$c->getLogger(),
972
-				$c->getDatabaseConnection(),
973
-				$c->getL10N('lib'),
974
-				$c->getConfig(),
975
-				$c->getEncryptionManager(),
976
-				$c->getUserManager(),
977
-				$c->getLockingProvider(),
978
-				$c->getRequest(),
979
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
980
-				$c->getURLGenerator()
981
-			);
982
-			return $manager;
983
-		});
984
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
985
-			return new \OC\Files\AppData\Factory(
986
-				$c->getRootFolder(),
987
-				$c->getSystemConfig()
988
-			);
989
-		});
990
-
991
-		$this->registerService('LockdownManager', function (Server $c) {
992
-			return new LockdownManager(function() use ($c) {
993
-				return $c->getSession();
994
-			});
995
-		});
996
-
997
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
998
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
999
-		});
1000
-
1001
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1002
-			return new CloudIdManager();
1003
-		});
1004
-
1005
-		/* To trick DI since we don't extend the DIContainer here */
1006
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1007
-			return new CleanPreviewsBackgroundJob(
1008
-				$c->getRootFolder(),
1009
-				$c->getLogger(),
1010
-				$c->getJobList(),
1011
-				new TimeFactory()
1012
-			);
1013
-		});
1014
-
1015
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1016
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1017
-
1018
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1019
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1020
-
1021
-		$this->registerService(Defaults::class, function (Server $c) {
1022
-			return new Defaults(
1023
-				$c->getThemingDefaults()
1024
-			);
1025
-		});
1026
-		$this->registerAlias('Defaults', \OCP\Defaults::class);
1027
-
1028
-		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
1029
-			return $c->query(\OCP\IUserSession::class)->getSession();
1030
-		});
1031
-
1032
-		$this->registerService(IShareHelper::class, function(Server $c) {
1033
-			return new ShareHelper(
1034
-				$c->query(\OCP\Share\IManager::class)
1035
-			);
1036
-		});
1037
-	}
1038
-
1039
-	/**
1040
-	 * @return \OCP\Contacts\IManager
1041
-	 */
1042
-	public function getContactsManager() {
1043
-		return $this->query('ContactsManager');
1044
-	}
1045
-
1046
-	/**
1047
-	 * @return \OC\Encryption\Manager
1048
-	 */
1049
-	public function getEncryptionManager() {
1050
-		return $this->query('EncryptionManager');
1051
-	}
1052
-
1053
-	/**
1054
-	 * @return \OC\Encryption\File
1055
-	 */
1056
-	public function getEncryptionFilesHelper() {
1057
-		return $this->query('EncryptionFileHelper');
1058
-	}
1059
-
1060
-	/**
1061
-	 * @return \OCP\Encryption\Keys\IStorage
1062
-	 */
1063
-	public function getEncryptionKeyStorage() {
1064
-		return $this->query('EncryptionKeyStorage');
1065
-	}
1066
-
1067
-	/**
1068
-	 * The current request object holding all information about the request
1069
-	 * currently being processed is returned from this method.
1070
-	 * In case the current execution was not initiated by a web request null is returned
1071
-	 *
1072
-	 * @return \OCP\IRequest
1073
-	 */
1074
-	public function getRequest() {
1075
-		return $this->query('Request');
1076
-	}
1077
-
1078
-	/**
1079
-	 * Returns the preview manager which can create preview images for a given file
1080
-	 *
1081
-	 * @return \OCP\IPreview
1082
-	 */
1083
-	public function getPreviewManager() {
1084
-		return $this->query('PreviewManager');
1085
-	}
1086
-
1087
-	/**
1088
-	 * Returns the tag manager which can get and set tags for different object types
1089
-	 *
1090
-	 * @see \OCP\ITagManager::load()
1091
-	 * @return \OCP\ITagManager
1092
-	 */
1093
-	public function getTagManager() {
1094
-		return $this->query('TagManager');
1095
-	}
1096
-
1097
-	/**
1098
-	 * Returns the system-tag manager
1099
-	 *
1100
-	 * @return \OCP\SystemTag\ISystemTagManager
1101
-	 *
1102
-	 * @since 9.0.0
1103
-	 */
1104
-	public function getSystemTagManager() {
1105
-		return $this->query('SystemTagManager');
1106
-	}
1107
-
1108
-	/**
1109
-	 * Returns the system-tag object mapper
1110
-	 *
1111
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1112
-	 *
1113
-	 * @since 9.0.0
1114
-	 */
1115
-	public function getSystemTagObjectMapper() {
1116
-		return $this->query('SystemTagObjectMapper');
1117
-	}
1118
-
1119
-	/**
1120
-	 * Returns the avatar manager, used for avatar functionality
1121
-	 *
1122
-	 * @return \OCP\IAvatarManager
1123
-	 */
1124
-	public function getAvatarManager() {
1125
-		return $this->query('AvatarManager');
1126
-	}
1127
-
1128
-	/**
1129
-	 * Returns the root folder of ownCloud's data directory
1130
-	 *
1131
-	 * @return \OCP\Files\IRootFolder
1132
-	 */
1133
-	public function getRootFolder() {
1134
-		return $this->query('LazyRootFolder');
1135
-	}
1136
-
1137
-	/**
1138
-	 * Returns the root folder of ownCloud's data directory
1139
-	 * This is the lazy variant so this gets only initialized once it
1140
-	 * is actually used.
1141
-	 *
1142
-	 * @return \OCP\Files\IRootFolder
1143
-	 */
1144
-	public function getLazyRootFolder() {
1145
-		return $this->query('LazyRootFolder');
1146
-	}
1147
-
1148
-	/**
1149
-	 * Returns a view to ownCloud's files folder
1150
-	 *
1151
-	 * @param string $userId user ID
1152
-	 * @return \OCP\Files\Folder|null
1153
-	 */
1154
-	public function getUserFolder($userId = null) {
1155
-		if ($userId === null) {
1156
-			$user = $this->getUserSession()->getUser();
1157
-			if (!$user) {
1158
-				return null;
1159
-			}
1160
-			$userId = $user->getUID();
1161
-		}
1162
-		$root = $this->getRootFolder();
1163
-		return $root->getUserFolder($userId);
1164
-	}
1165
-
1166
-	/**
1167
-	 * Returns an app-specific view in ownClouds data directory
1168
-	 *
1169
-	 * @return \OCP\Files\Folder
1170
-	 * @deprecated since 9.2.0 use IAppData
1171
-	 */
1172
-	public function getAppFolder() {
1173
-		$dir = '/' . \OC_App::getCurrentApp();
1174
-		$root = $this->getRootFolder();
1175
-		if (!$root->nodeExists($dir)) {
1176
-			$folder = $root->newFolder($dir);
1177
-		} else {
1178
-			$folder = $root->get($dir);
1179
-		}
1180
-		return $folder;
1181
-	}
1182
-
1183
-	/**
1184
-	 * @return \OC\User\Manager
1185
-	 */
1186
-	public function getUserManager() {
1187
-		return $this->query('UserManager');
1188
-	}
1189
-
1190
-	/**
1191
-	 * @return \OC\Group\Manager
1192
-	 */
1193
-	public function getGroupManager() {
1194
-		return $this->query('GroupManager');
1195
-	}
1196
-
1197
-	/**
1198
-	 * @return \OC\User\Session
1199
-	 */
1200
-	public function getUserSession() {
1201
-		return $this->query('UserSession');
1202
-	}
1203
-
1204
-	/**
1205
-	 * @return \OCP\ISession
1206
-	 */
1207
-	public function getSession() {
1208
-		return $this->query('UserSession')->getSession();
1209
-	}
1210
-
1211
-	/**
1212
-	 * @param \OCP\ISession $session
1213
-	 */
1214
-	public function setSession(\OCP\ISession $session) {
1215
-		$this->query(SessionStorage::class)->setSession($session);
1216
-		$this->query('UserSession')->setSession($session);
1217
-		$this->query(Store::class)->setSession($session);
1218
-	}
1219
-
1220
-	/**
1221
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1222
-	 */
1223
-	public function getTwoFactorAuthManager() {
1224
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1225
-	}
1226
-
1227
-	/**
1228
-	 * @return \OC\NavigationManager
1229
-	 */
1230
-	public function getNavigationManager() {
1231
-		return $this->query('NavigationManager');
1232
-	}
1233
-
1234
-	/**
1235
-	 * @return \OCP\IConfig
1236
-	 */
1237
-	public function getConfig() {
1238
-		return $this->query('AllConfig');
1239
-	}
1240
-
1241
-	/**
1242
-	 * @internal For internal use only
1243
-	 * @return \OC\SystemConfig
1244
-	 */
1245
-	public function getSystemConfig() {
1246
-		return $this->query('SystemConfig');
1247
-	}
1248
-
1249
-	/**
1250
-	 * Returns the app config manager
1251
-	 *
1252
-	 * @return \OCP\IAppConfig
1253
-	 */
1254
-	public function getAppConfig() {
1255
-		return $this->query('AppConfig');
1256
-	}
1257
-
1258
-	/**
1259
-	 * @return \OCP\L10N\IFactory
1260
-	 */
1261
-	public function getL10NFactory() {
1262
-		return $this->query('L10NFactory');
1263
-	}
1264
-
1265
-	/**
1266
-	 * get an L10N instance
1267
-	 *
1268
-	 * @param string $app appid
1269
-	 * @param string $lang
1270
-	 * @return IL10N
1271
-	 */
1272
-	public function getL10N($app, $lang = null) {
1273
-		return $this->getL10NFactory()->get($app, $lang);
1274
-	}
1275
-
1276
-	/**
1277
-	 * @return \OCP\IURLGenerator
1278
-	 */
1279
-	public function getURLGenerator() {
1280
-		return $this->query('URLGenerator');
1281
-	}
1282
-
1283
-	/**
1284
-	 * @return \OCP\IHelper
1285
-	 */
1286
-	public function getHelper() {
1287
-		return $this->query('AppHelper');
1288
-	}
1289
-
1290
-	/**
1291
-	 * @return AppFetcher
1292
-	 */
1293
-	public function getAppFetcher() {
1294
-		return $this->query('AppFetcher');
1295
-	}
1296
-
1297
-	/**
1298
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1299
-	 * getMemCacheFactory() instead.
1300
-	 *
1301
-	 * @return \OCP\ICache
1302
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1303
-	 */
1304
-	public function getCache() {
1305
-		return $this->query('UserCache');
1306
-	}
1307
-
1308
-	/**
1309
-	 * Returns an \OCP\CacheFactory instance
1310
-	 *
1311
-	 * @return \OCP\ICacheFactory
1312
-	 */
1313
-	public function getMemCacheFactory() {
1314
-		return $this->query('MemCacheFactory');
1315
-	}
1316
-
1317
-	/**
1318
-	 * Returns an \OC\RedisFactory instance
1319
-	 *
1320
-	 * @return \OC\RedisFactory
1321
-	 */
1322
-	public function getGetRedisFactory() {
1323
-		return $this->query('RedisFactory');
1324
-	}
1325
-
1326
-
1327
-	/**
1328
-	 * Returns the current session
1329
-	 *
1330
-	 * @return \OCP\IDBConnection
1331
-	 */
1332
-	public function getDatabaseConnection() {
1333
-		return $this->query('DatabaseConnection');
1334
-	}
1335
-
1336
-	/**
1337
-	 * Returns the activity manager
1338
-	 *
1339
-	 * @return \OCP\Activity\IManager
1340
-	 */
1341
-	public function getActivityManager() {
1342
-		return $this->query('ActivityManager');
1343
-	}
1344
-
1345
-	/**
1346
-	 * Returns an job list for controlling background jobs
1347
-	 *
1348
-	 * @return \OCP\BackgroundJob\IJobList
1349
-	 */
1350
-	public function getJobList() {
1351
-		return $this->query('JobList');
1352
-	}
1353
-
1354
-	/**
1355
-	 * Returns a logger instance
1356
-	 *
1357
-	 * @return \OCP\ILogger
1358
-	 */
1359
-	public function getLogger() {
1360
-		return $this->query('Logger');
1361
-	}
1362
-
1363
-	/**
1364
-	 * Returns a router for generating and matching urls
1365
-	 *
1366
-	 * @return \OCP\Route\IRouter
1367
-	 */
1368
-	public function getRouter() {
1369
-		return $this->query('Router');
1370
-	}
1371
-
1372
-	/**
1373
-	 * Returns a search instance
1374
-	 *
1375
-	 * @return \OCP\ISearch
1376
-	 */
1377
-	public function getSearch() {
1378
-		return $this->query('Search');
1379
-	}
1380
-
1381
-	/**
1382
-	 * Returns a SecureRandom instance
1383
-	 *
1384
-	 * @return \OCP\Security\ISecureRandom
1385
-	 */
1386
-	public function getSecureRandom() {
1387
-		return $this->query('SecureRandom');
1388
-	}
1389
-
1390
-	/**
1391
-	 * Returns a Crypto instance
1392
-	 *
1393
-	 * @return \OCP\Security\ICrypto
1394
-	 */
1395
-	public function getCrypto() {
1396
-		return $this->query('Crypto');
1397
-	}
1398
-
1399
-	/**
1400
-	 * Returns a Hasher instance
1401
-	 *
1402
-	 * @return \OCP\Security\IHasher
1403
-	 */
1404
-	public function getHasher() {
1405
-		return $this->query('Hasher');
1406
-	}
1407
-
1408
-	/**
1409
-	 * Returns a CredentialsManager instance
1410
-	 *
1411
-	 * @return \OCP\Security\ICredentialsManager
1412
-	 */
1413
-	public function getCredentialsManager() {
1414
-		return $this->query('CredentialsManager');
1415
-	}
1416
-
1417
-	/**
1418
-	 * Returns an instance of the HTTP helper class
1419
-	 *
1420
-	 * @deprecated Use getHTTPClientService()
1421
-	 * @return \OC\HTTPHelper
1422
-	 */
1423
-	public function getHTTPHelper() {
1424
-		return $this->query('HTTPHelper');
1425
-	}
1426
-
1427
-	/**
1428
-	 * Get the certificate manager for the user
1429
-	 *
1430
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1431
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1432
-	 */
1433
-	public function getCertificateManager($userId = '') {
1434
-		if ($userId === '') {
1435
-			$userSession = $this->getUserSession();
1436
-			$user = $userSession->getUser();
1437
-			if (is_null($user)) {
1438
-				return null;
1439
-			}
1440
-			$userId = $user->getUID();
1441
-		}
1442
-		return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1443
-	}
1444
-
1445
-	/**
1446
-	 * Returns an instance of the HTTP client service
1447
-	 *
1448
-	 * @return \OCP\Http\Client\IClientService
1449
-	 */
1450
-	public function getHTTPClientService() {
1451
-		return $this->query('HttpClientService');
1452
-	}
1453
-
1454
-	/**
1455
-	 * Create a new event source
1456
-	 *
1457
-	 * @return \OCP\IEventSource
1458
-	 */
1459
-	public function createEventSource() {
1460
-		return new \OC_EventSource();
1461
-	}
1462
-
1463
-	/**
1464
-	 * Get the active event logger
1465
-	 *
1466
-	 * The returned logger only logs data when debug mode is enabled
1467
-	 *
1468
-	 * @return \OCP\Diagnostics\IEventLogger
1469
-	 */
1470
-	public function getEventLogger() {
1471
-		return $this->query('EventLogger');
1472
-	}
1473
-
1474
-	/**
1475
-	 * Get the active query logger
1476
-	 *
1477
-	 * The returned logger only logs data when debug mode is enabled
1478
-	 *
1479
-	 * @return \OCP\Diagnostics\IQueryLogger
1480
-	 */
1481
-	public function getQueryLogger() {
1482
-		return $this->query('QueryLogger');
1483
-	}
1484
-
1485
-	/**
1486
-	 * Get the manager for temporary files and folders
1487
-	 *
1488
-	 * @return \OCP\ITempManager
1489
-	 */
1490
-	public function getTempManager() {
1491
-		return $this->query('TempManager');
1492
-	}
1493
-
1494
-	/**
1495
-	 * Get the app manager
1496
-	 *
1497
-	 * @return \OCP\App\IAppManager
1498
-	 */
1499
-	public function getAppManager() {
1500
-		return $this->query('AppManager');
1501
-	}
1502
-
1503
-	/**
1504
-	 * Creates a new mailer
1505
-	 *
1506
-	 * @return \OCP\Mail\IMailer
1507
-	 */
1508
-	public function getMailer() {
1509
-		return $this->query('Mailer');
1510
-	}
1511
-
1512
-	/**
1513
-	 * Get the webroot
1514
-	 *
1515
-	 * @return string
1516
-	 */
1517
-	public function getWebRoot() {
1518
-		return $this->webRoot;
1519
-	}
1520
-
1521
-	/**
1522
-	 * @return \OC\OCSClient
1523
-	 */
1524
-	public function getOcsClient() {
1525
-		return $this->query('OcsClient');
1526
-	}
1527
-
1528
-	/**
1529
-	 * @return \OCP\IDateTimeZone
1530
-	 */
1531
-	public function getDateTimeZone() {
1532
-		return $this->query('DateTimeZone');
1533
-	}
1534
-
1535
-	/**
1536
-	 * @return \OCP\IDateTimeFormatter
1537
-	 */
1538
-	public function getDateTimeFormatter() {
1539
-		return $this->query('DateTimeFormatter');
1540
-	}
1541
-
1542
-	/**
1543
-	 * @return \OCP\Files\Config\IMountProviderCollection
1544
-	 */
1545
-	public function getMountProviderCollection() {
1546
-		return $this->query('MountConfigManager');
1547
-	}
1548
-
1549
-	/**
1550
-	 * Get the IniWrapper
1551
-	 *
1552
-	 * @return IniGetWrapper
1553
-	 */
1554
-	public function getIniWrapper() {
1555
-		return $this->query('IniWrapper');
1556
-	}
1557
-
1558
-	/**
1559
-	 * @return \OCP\Command\IBus
1560
-	 */
1561
-	public function getCommandBus() {
1562
-		return $this->query('AsyncCommandBus');
1563
-	}
1564
-
1565
-	/**
1566
-	 * Get the trusted domain helper
1567
-	 *
1568
-	 * @return TrustedDomainHelper
1569
-	 */
1570
-	public function getTrustedDomainHelper() {
1571
-		return $this->query('TrustedDomainHelper');
1572
-	}
1573
-
1574
-	/**
1575
-	 * Get the locking provider
1576
-	 *
1577
-	 * @return \OCP\Lock\ILockingProvider
1578
-	 * @since 8.1.0
1579
-	 */
1580
-	public function getLockingProvider() {
1581
-		return $this->query('LockingProvider');
1582
-	}
1583
-
1584
-	/**
1585
-	 * @return \OCP\Files\Mount\IMountManager
1586
-	 **/
1587
-	function getMountManager() {
1588
-		return $this->query('MountManager');
1589
-	}
1590
-
1591
-	/** @return \OCP\Files\Config\IUserMountCache */
1592
-	function getUserMountCache() {
1593
-		return $this->query('UserMountCache');
1594
-	}
1595
-
1596
-	/**
1597
-	 * Get the MimeTypeDetector
1598
-	 *
1599
-	 * @return \OCP\Files\IMimeTypeDetector
1600
-	 */
1601
-	public function getMimeTypeDetector() {
1602
-		return $this->query('MimeTypeDetector');
1603
-	}
1604
-
1605
-	/**
1606
-	 * Get the MimeTypeLoader
1607
-	 *
1608
-	 * @return \OCP\Files\IMimeTypeLoader
1609
-	 */
1610
-	public function getMimeTypeLoader() {
1611
-		return $this->query('MimeTypeLoader');
1612
-	}
1613
-
1614
-	/**
1615
-	 * Get the manager of all the capabilities
1616
-	 *
1617
-	 * @return \OC\CapabilitiesManager
1618
-	 */
1619
-	public function getCapabilitiesManager() {
1620
-		return $this->query('CapabilitiesManager');
1621
-	}
1622
-
1623
-	/**
1624
-	 * Get the EventDispatcher
1625
-	 *
1626
-	 * @return EventDispatcherInterface
1627
-	 * @since 8.2.0
1628
-	 */
1629
-	public function getEventDispatcher() {
1630
-		return $this->query('EventDispatcher');
1631
-	}
1632
-
1633
-	/**
1634
-	 * Get the Notification Manager
1635
-	 *
1636
-	 * @return \OCP\Notification\IManager
1637
-	 * @since 8.2.0
1638
-	 */
1639
-	public function getNotificationManager() {
1640
-		return $this->query('NotificationManager');
1641
-	}
1642
-
1643
-	/**
1644
-	 * @return \OCP\Comments\ICommentsManager
1645
-	 */
1646
-	public function getCommentsManager() {
1647
-		return $this->query('CommentsManager');
1648
-	}
1649
-
1650
-	/**
1651
-	 * @return \OCA\Theming\ThemingDefaults
1652
-	 */
1653
-	public function getThemingDefaults() {
1654
-		return $this->query('ThemingDefaults');
1655
-	}
1656
-
1657
-	/**
1658
-	 * @return \OC\IntegrityCheck\Checker
1659
-	 */
1660
-	public function getIntegrityCodeChecker() {
1661
-		return $this->query('IntegrityCodeChecker');
1662
-	}
1663
-
1664
-	/**
1665
-	 * @return \OC\Session\CryptoWrapper
1666
-	 */
1667
-	public function getSessionCryptoWrapper() {
1668
-		return $this->query('CryptoWrapper');
1669
-	}
1670
-
1671
-	/**
1672
-	 * @return CsrfTokenManager
1673
-	 */
1674
-	public function getCsrfTokenManager() {
1675
-		return $this->query('CsrfTokenManager');
1676
-	}
1677
-
1678
-	/**
1679
-	 * @return Throttler
1680
-	 */
1681
-	public function getBruteForceThrottler() {
1682
-		return $this->query('Throttler');
1683
-	}
1684
-
1685
-	/**
1686
-	 * @return IContentSecurityPolicyManager
1687
-	 */
1688
-	public function getContentSecurityPolicyManager() {
1689
-		return $this->query('ContentSecurityPolicyManager');
1690
-	}
1691
-
1692
-	/**
1693
-	 * @return ContentSecurityPolicyNonceManager
1694
-	 */
1695
-	public function getContentSecurityPolicyNonceManager() {
1696
-		return $this->query('ContentSecurityPolicyNonceManager');
1697
-	}
1698
-
1699
-	/**
1700
-	 * Not a public API as of 8.2, wait for 9.0
1701
-	 *
1702
-	 * @return \OCA\Files_External\Service\BackendService
1703
-	 */
1704
-	public function getStoragesBackendService() {
1705
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1706
-	}
1707
-
1708
-	/**
1709
-	 * Not a public API as of 8.2, wait for 9.0
1710
-	 *
1711
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1712
-	 */
1713
-	public function getGlobalStoragesService() {
1714
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1715
-	}
1716
-
1717
-	/**
1718
-	 * Not a public API as of 8.2, wait for 9.0
1719
-	 *
1720
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1721
-	 */
1722
-	public function getUserGlobalStoragesService() {
1723
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1724
-	}
1725
-
1726
-	/**
1727
-	 * Not a public API as of 8.2, wait for 9.0
1728
-	 *
1729
-	 * @return \OCA\Files_External\Service\UserStoragesService
1730
-	 */
1731
-	public function getUserStoragesService() {
1732
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1733
-	}
1734
-
1735
-	/**
1736
-	 * @return \OCP\Share\IManager
1737
-	 */
1738
-	public function getShareManager() {
1739
-		return $this->query('ShareManager');
1740
-	}
1741
-
1742
-	/**
1743
-	 * Returns the LDAP Provider
1744
-	 *
1745
-	 * @return \OCP\LDAP\ILDAPProvider
1746
-	 */
1747
-	public function getLDAPProvider() {
1748
-		return $this->query('LDAPProvider');
1749
-	}
1750
-
1751
-	/**
1752
-	 * @return \OCP\Settings\IManager
1753
-	 */
1754
-	public function getSettingsManager() {
1755
-		return $this->query('SettingsManager');
1756
-	}
1757
-
1758
-	/**
1759
-	 * @return \OCP\Files\IAppData
1760
-	 */
1761
-	public function getAppDataDir($app) {
1762
-		/** @var \OC\Files\AppData\Factory $factory */
1763
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1764
-		return $factory->get($app);
1765
-	}
1766
-
1767
-	/**
1768
-	 * @return \OCP\Lockdown\ILockdownManager
1769
-	 */
1770
-	public function getLockdownManager() {
1771
-		return $this->query('LockdownManager');
1772
-	}
1773
-
1774
-	/**
1775
-	 * @return \OCP\Federation\ICloudIdManager
1776
-	 */
1777
-	public function getCloudIdManager() {
1778
-		return $this->query(ICloudIdManager::class);
1779
-	}
859
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
860
+            if (isset($prefixes['OCA\\Theming\\'])) {
861
+                $classExists = true;
862
+            } else {
863
+                $classExists = false;
864
+            }
865
+
866
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
867
+                return new ThemingDefaults(
868
+                    $c->getConfig(),
869
+                    $c->getL10N('theming'),
870
+                    $c->getURLGenerator(),
871
+                    $c->getAppDataDir('theming'),
872
+                    $c->getMemCacheFactory(),
873
+                    new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager())
874
+                );
875
+            }
876
+            return new \OC_Defaults();
877
+        });
878
+        $this->registerService(SCSSCacher::class, function(Server $c) {
879
+            /** @var Factory $cacheFactory */
880
+            $cacheFactory = $c->query(Factory::class);
881
+            return new SCSSCacher(
882
+                $c->getLogger(),
883
+                $c->query(\OC\Files\AppData\Factory::class),
884
+                $c->getURLGenerator(),
885
+                $c->getConfig(),
886
+                $c->getThemingDefaults(),
887
+                \OC::$SERVERROOT,
888
+                $cacheFactory->createLocal('SCSS')
889
+            );
890
+        });
891
+        $this->registerService(EventDispatcher::class, function () {
892
+            return new EventDispatcher();
893
+        });
894
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
895
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
896
+
897
+        $this->registerService('CryptoWrapper', function (Server $c) {
898
+            // FIXME: Instantiiated here due to cyclic dependency
899
+            $request = new Request(
900
+                [
901
+                    'get' => $_GET,
902
+                    'post' => $_POST,
903
+                    'files' => $_FILES,
904
+                    'server' => $_SERVER,
905
+                    'env' => $_ENV,
906
+                    'cookies' => $_COOKIE,
907
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
908
+                        ? $_SERVER['REQUEST_METHOD']
909
+                        : null,
910
+                ],
911
+                $c->getSecureRandom(),
912
+                $c->getConfig()
913
+            );
914
+
915
+            return new CryptoWrapper(
916
+                $c->getConfig(),
917
+                $c->getCrypto(),
918
+                $c->getSecureRandom(),
919
+                $request
920
+            );
921
+        });
922
+        $this->registerService('CsrfTokenManager', function (Server $c) {
923
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
924
+
925
+            return new CsrfTokenManager(
926
+                $tokenGenerator,
927
+                $c->query(SessionStorage::class)
928
+            );
929
+        });
930
+        $this->registerService(SessionStorage::class, function (Server $c) {
931
+            return new SessionStorage($c->getSession());
932
+        });
933
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
934
+            return new ContentSecurityPolicyManager();
935
+        });
936
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
937
+
938
+        $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
939
+            return new ContentSecurityPolicyNonceManager(
940
+                $c->getCsrfTokenManager(),
941
+                $c->getRequest()
942
+            );
943
+        });
944
+
945
+        $this->registerService(\OCP\Share\IManager::class, function(Server $c) {
946
+            $config = $c->getConfig();
947
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
948
+            /** @var \OCP\Share\IProviderFactory $factory */
949
+            $factory = new $factoryClass($this);
950
+
951
+            $manager = new \OC\Share20\Manager(
952
+                $c->getLogger(),
953
+                $c->getConfig(),
954
+                $c->getSecureRandom(),
955
+                $c->getHasher(),
956
+                $c->getMountManager(),
957
+                $c->getGroupManager(),
958
+                $c->getL10N('core'),
959
+                $factory,
960
+                $c->getUserManager(),
961
+                $c->getLazyRootFolder(),
962
+                $c->getEventDispatcher()
963
+            );
964
+
965
+            return $manager;
966
+        });
967
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
968
+
969
+        $this->registerService('SettingsManager', function(Server $c) {
970
+            $manager = new \OC\Settings\Manager(
971
+                $c->getLogger(),
972
+                $c->getDatabaseConnection(),
973
+                $c->getL10N('lib'),
974
+                $c->getConfig(),
975
+                $c->getEncryptionManager(),
976
+                $c->getUserManager(),
977
+                $c->getLockingProvider(),
978
+                $c->getRequest(),
979
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
980
+                $c->getURLGenerator()
981
+            );
982
+            return $manager;
983
+        });
984
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
985
+            return new \OC\Files\AppData\Factory(
986
+                $c->getRootFolder(),
987
+                $c->getSystemConfig()
988
+            );
989
+        });
990
+
991
+        $this->registerService('LockdownManager', function (Server $c) {
992
+            return new LockdownManager(function() use ($c) {
993
+                return $c->getSession();
994
+            });
995
+        });
996
+
997
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
998
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
999
+        });
1000
+
1001
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
1002
+            return new CloudIdManager();
1003
+        });
1004
+
1005
+        /* To trick DI since we don't extend the DIContainer here */
1006
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1007
+            return new CleanPreviewsBackgroundJob(
1008
+                $c->getRootFolder(),
1009
+                $c->getLogger(),
1010
+                $c->getJobList(),
1011
+                new TimeFactory()
1012
+            );
1013
+        });
1014
+
1015
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1016
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1017
+
1018
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1019
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1020
+
1021
+        $this->registerService(Defaults::class, function (Server $c) {
1022
+            return new Defaults(
1023
+                $c->getThemingDefaults()
1024
+            );
1025
+        });
1026
+        $this->registerAlias('Defaults', \OCP\Defaults::class);
1027
+
1028
+        $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
1029
+            return $c->query(\OCP\IUserSession::class)->getSession();
1030
+        });
1031
+
1032
+        $this->registerService(IShareHelper::class, function(Server $c) {
1033
+            return new ShareHelper(
1034
+                $c->query(\OCP\Share\IManager::class)
1035
+            );
1036
+        });
1037
+    }
1038
+
1039
+    /**
1040
+     * @return \OCP\Contacts\IManager
1041
+     */
1042
+    public function getContactsManager() {
1043
+        return $this->query('ContactsManager');
1044
+    }
1045
+
1046
+    /**
1047
+     * @return \OC\Encryption\Manager
1048
+     */
1049
+    public function getEncryptionManager() {
1050
+        return $this->query('EncryptionManager');
1051
+    }
1052
+
1053
+    /**
1054
+     * @return \OC\Encryption\File
1055
+     */
1056
+    public function getEncryptionFilesHelper() {
1057
+        return $this->query('EncryptionFileHelper');
1058
+    }
1059
+
1060
+    /**
1061
+     * @return \OCP\Encryption\Keys\IStorage
1062
+     */
1063
+    public function getEncryptionKeyStorage() {
1064
+        return $this->query('EncryptionKeyStorage');
1065
+    }
1066
+
1067
+    /**
1068
+     * The current request object holding all information about the request
1069
+     * currently being processed is returned from this method.
1070
+     * In case the current execution was not initiated by a web request null is returned
1071
+     *
1072
+     * @return \OCP\IRequest
1073
+     */
1074
+    public function getRequest() {
1075
+        return $this->query('Request');
1076
+    }
1077
+
1078
+    /**
1079
+     * Returns the preview manager which can create preview images for a given file
1080
+     *
1081
+     * @return \OCP\IPreview
1082
+     */
1083
+    public function getPreviewManager() {
1084
+        return $this->query('PreviewManager');
1085
+    }
1086
+
1087
+    /**
1088
+     * Returns the tag manager which can get and set tags for different object types
1089
+     *
1090
+     * @see \OCP\ITagManager::load()
1091
+     * @return \OCP\ITagManager
1092
+     */
1093
+    public function getTagManager() {
1094
+        return $this->query('TagManager');
1095
+    }
1096
+
1097
+    /**
1098
+     * Returns the system-tag manager
1099
+     *
1100
+     * @return \OCP\SystemTag\ISystemTagManager
1101
+     *
1102
+     * @since 9.0.0
1103
+     */
1104
+    public function getSystemTagManager() {
1105
+        return $this->query('SystemTagManager');
1106
+    }
1107
+
1108
+    /**
1109
+     * Returns the system-tag object mapper
1110
+     *
1111
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1112
+     *
1113
+     * @since 9.0.0
1114
+     */
1115
+    public function getSystemTagObjectMapper() {
1116
+        return $this->query('SystemTagObjectMapper');
1117
+    }
1118
+
1119
+    /**
1120
+     * Returns the avatar manager, used for avatar functionality
1121
+     *
1122
+     * @return \OCP\IAvatarManager
1123
+     */
1124
+    public function getAvatarManager() {
1125
+        return $this->query('AvatarManager');
1126
+    }
1127
+
1128
+    /**
1129
+     * Returns the root folder of ownCloud's data directory
1130
+     *
1131
+     * @return \OCP\Files\IRootFolder
1132
+     */
1133
+    public function getRootFolder() {
1134
+        return $this->query('LazyRootFolder');
1135
+    }
1136
+
1137
+    /**
1138
+     * Returns the root folder of ownCloud's data directory
1139
+     * This is the lazy variant so this gets only initialized once it
1140
+     * is actually used.
1141
+     *
1142
+     * @return \OCP\Files\IRootFolder
1143
+     */
1144
+    public function getLazyRootFolder() {
1145
+        return $this->query('LazyRootFolder');
1146
+    }
1147
+
1148
+    /**
1149
+     * Returns a view to ownCloud's files folder
1150
+     *
1151
+     * @param string $userId user ID
1152
+     * @return \OCP\Files\Folder|null
1153
+     */
1154
+    public function getUserFolder($userId = null) {
1155
+        if ($userId === null) {
1156
+            $user = $this->getUserSession()->getUser();
1157
+            if (!$user) {
1158
+                return null;
1159
+            }
1160
+            $userId = $user->getUID();
1161
+        }
1162
+        $root = $this->getRootFolder();
1163
+        return $root->getUserFolder($userId);
1164
+    }
1165
+
1166
+    /**
1167
+     * Returns an app-specific view in ownClouds data directory
1168
+     *
1169
+     * @return \OCP\Files\Folder
1170
+     * @deprecated since 9.2.0 use IAppData
1171
+     */
1172
+    public function getAppFolder() {
1173
+        $dir = '/' . \OC_App::getCurrentApp();
1174
+        $root = $this->getRootFolder();
1175
+        if (!$root->nodeExists($dir)) {
1176
+            $folder = $root->newFolder($dir);
1177
+        } else {
1178
+            $folder = $root->get($dir);
1179
+        }
1180
+        return $folder;
1181
+    }
1182
+
1183
+    /**
1184
+     * @return \OC\User\Manager
1185
+     */
1186
+    public function getUserManager() {
1187
+        return $this->query('UserManager');
1188
+    }
1189
+
1190
+    /**
1191
+     * @return \OC\Group\Manager
1192
+     */
1193
+    public function getGroupManager() {
1194
+        return $this->query('GroupManager');
1195
+    }
1196
+
1197
+    /**
1198
+     * @return \OC\User\Session
1199
+     */
1200
+    public function getUserSession() {
1201
+        return $this->query('UserSession');
1202
+    }
1203
+
1204
+    /**
1205
+     * @return \OCP\ISession
1206
+     */
1207
+    public function getSession() {
1208
+        return $this->query('UserSession')->getSession();
1209
+    }
1210
+
1211
+    /**
1212
+     * @param \OCP\ISession $session
1213
+     */
1214
+    public function setSession(\OCP\ISession $session) {
1215
+        $this->query(SessionStorage::class)->setSession($session);
1216
+        $this->query('UserSession')->setSession($session);
1217
+        $this->query(Store::class)->setSession($session);
1218
+    }
1219
+
1220
+    /**
1221
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1222
+     */
1223
+    public function getTwoFactorAuthManager() {
1224
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1225
+    }
1226
+
1227
+    /**
1228
+     * @return \OC\NavigationManager
1229
+     */
1230
+    public function getNavigationManager() {
1231
+        return $this->query('NavigationManager');
1232
+    }
1233
+
1234
+    /**
1235
+     * @return \OCP\IConfig
1236
+     */
1237
+    public function getConfig() {
1238
+        return $this->query('AllConfig');
1239
+    }
1240
+
1241
+    /**
1242
+     * @internal For internal use only
1243
+     * @return \OC\SystemConfig
1244
+     */
1245
+    public function getSystemConfig() {
1246
+        return $this->query('SystemConfig');
1247
+    }
1248
+
1249
+    /**
1250
+     * Returns the app config manager
1251
+     *
1252
+     * @return \OCP\IAppConfig
1253
+     */
1254
+    public function getAppConfig() {
1255
+        return $this->query('AppConfig');
1256
+    }
1257
+
1258
+    /**
1259
+     * @return \OCP\L10N\IFactory
1260
+     */
1261
+    public function getL10NFactory() {
1262
+        return $this->query('L10NFactory');
1263
+    }
1264
+
1265
+    /**
1266
+     * get an L10N instance
1267
+     *
1268
+     * @param string $app appid
1269
+     * @param string $lang
1270
+     * @return IL10N
1271
+     */
1272
+    public function getL10N($app, $lang = null) {
1273
+        return $this->getL10NFactory()->get($app, $lang);
1274
+    }
1275
+
1276
+    /**
1277
+     * @return \OCP\IURLGenerator
1278
+     */
1279
+    public function getURLGenerator() {
1280
+        return $this->query('URLGenerator');
1281
+    }
1282
+
1283
+    /**
1284
+     * @return \OCP\IHelper
1285
+     */
1286
+    public function getHelper() {
1287
+        return $this->query('AppHelper');
1288
+    }
1289
+
1290
+    /**
1291
+     * @return AppFetcher
1292
+     */
1293
+    public function getAppFetcher() {
1294
+        return $this->query('AppFetcher');
1295
+    }
1296
+
1297
+    /**
1298
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1299
+     * getMemCacheFactory() instead.
1300
+     *
1301
+     * @return \OCP\ICache
1302
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1303
+     */
1304
+    public function getCache() {
1305
+        return $this->query('UserCache');
1306
+    }
1307
+
1308
+    /**
1309
+     * Returns an \OCP\CacheFactory instance
1310
+     *
1311
+     * @return \OCP\ICacheFactory
1312
+     */
1313
+    public function getMemCacheFactory() {
1314
+        return $this->query('MemCacheFactory');
1315
+    }
1316
+
1317
+    /**
1318
+     * Returns an \OC\RedisFactory instance
1319
+     *
1320
+     * @return \OC\RedisFactory
1321
+     */
1322
+    public function getGetRedisFactory() {
1323
+        return $this->query('RedisFactory');
1324
+    }
1325
+
1326
+
1327
+    /**
1328
+     * Returns the current session
1329
+     *
1330
+     * @return \OCP\IDBConnection
1331
+     */
1332
+    public function getDatabaseConnection() {
1333
+        return $this->query('DatabaseConnection');
1334
+    }
1335
+
1336
+    /**
1337
+     * Returns the activity manager
1338
+     *
1339
+     * @return \OCP\Activity\IManager
1340
+     */
1341
+    public function getActivityManager() {
1342
+        return $this->query('ActivityManager');
1343
+    }
1344
+
1345
+    /**
1346
+     * Returns an job list for controlling background jobs
1347
+     *
1348
+     * @return \OCP\BackgroundJob\IJobList
1349
+     */
1350
+    public function getJobList() {
1351
+        return $this->query('JobList');
1352
+    }
1353
+
1354
+    /**
1355
+     * Returns a logger instance
1356
+     *
1357
+     * @return \OCP\ILogger
1358
+     */
1359
+    public function getLogger() {
1360
+        return $this->query('Logger');
1361
+    }
1362
+
1363
+    /**
1364
+     * Returns a router for generating and matching urls
1365
+     *
1366
+     * @return \OCP\Route\IRouter
1367
+     */
1368
+    public function getRouter() {
1369
+        return $this->query('Router');
1370
+    }
1371
+
1372
+    /**
1373
+     * Returns a search instance
1374
+     *
1375
+     * @return \OCP\ISearch
1376
+     */
1377
+    public function getSearch() {
1378
+        return $this->query('Search');
1379
+    }
1380
+
1381
+    /**
1382
+     * Returns a SecureRandom instance
1383
+     *
1384
+     * @return \OCP\Security\ISecureRandom
1385
+     */
1386
+    public function getSecureRandom() {
1387
+        return $this->query('SecureRandom');
1388
+    }
1389
+
1390
+    /**
1391
+     * Returns a Crypto instance
1392
+     *
1393
+     * @return \OCP\Security\ICrypto
1394
+     */
1395
+    public function getCrypto() {
1396
+        return $this->query('Crypto');
1397
+    }
1398
+
1399
+    /**
1400
+     * Returns a Hasher instance
1401
+     *
1402
+     * @return \OCP\Security\IHasher
1403
+     */
1404
+    public function getHasher() {
1405
+        return $this->query('Hasher');
1406
+    }
1407
+
1408
+    /**
1409
+     * Returns a CredentialsManager instance
1410
+     *
1411
+     * @return \OCP\Security\ICredentialsManager
1412
+     */
1413
+    public function getCredentialsManager() {
1414
+        return $this->query('CredentialsManager');
1415
+    }
1416
+
1417
+    /**
1418
+     * Returns an instance of the HTTP helper class
1419
+     *
1420
+     * @deprecated Use getHTTPClientService()
1421
+     * @return \OC\HTTPHelper
1422
+     */
1423
+    public function getHTTPHelper() {
1424
+        return $this->query('HTTPHelper');
1425
+    }
1426
+
1427
+    /**
1428
+     * Get the certificate manager for the user
1429
+     *
1430
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1431
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1432
+     */
1433
+    public function getCertificateManager($userId = '') {
1434
+        if ($userId === '') {
1435
+            $userSession = $this->getUserSession();
1436
+            $user = $userSession->getUser();
1437
+            if (is_null($user)) {
1438
+                return null;
1439
+            }
1440
+            $userId = $user->getUID();
1441
+        }
1442
+        return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1443
+    }
1444
+
1445
+    /**
1446
+     * Returns an instance of the HTTP client service
1447
+     *
1448
+     * @return \OCP\Http\Client\IClientService
1449
+     */
1450
+    public function getHTTPClientService() {
1451
+        return $this->query('HttpClientService');
1452
+    }
1453
+
1454
+    /**
1455
+     * Create a new event source
1456
+     *
1457
+     * @return \OCP\IEventSource
1458
+     */
1459
+    public function createEventSource() {
1460
+        return new \OC_EventSource();
1461
+    }
1462
+
1463
+    /**
1464
+     * Get the active event logger
1465
+     *
1466
+     * The returned logger only logs data when debug mode is enabled
1467
+     *
1468
+     * @return \OCP\Diagnostics\IEventLogger
1469
+     */
1470
+    public function getEventLogger() {
1471
+        return $this->query('EventLogger');
1472
+    }
1473
+
1474
+    /**
1475
+     * Get the active query logger
1476
+     *
1477
+     * The returned logger only logs data when debug mode is enabled
1478
+     *
1479
+     * @return \OCP\Diagnostics\IQueryLogger
1480
+     */
1481
+    public function getQueryLogger() {
1482
+        return $this->query('QueryLogger');
1483
+    }
1484
+
1485
+    /**
1486
+     * Get the manager for temporary files and folders
1487
+     *
1488
+     * @return \OCP\ITempManager
1489
+     */
1490
+    public function getTempManager() {
1491
+        return $this->query('TempManager');
1492
+    }
1493
+
1494
+    /**
1495
+     * Get the app manager
1496
+     *
1497
+     * @return \OCP\App\IAppManager
1498
+     */
1499
+    public function getAppManager() {
1500
+        return $this->query('AppManager');
1501
+    }
1502
+
1503
+    /**
1504
+     * Creates a new mailer
1505
+     *
1506
+     * @return \OCP\Mail\IMailer
1507
+     */
1508
+    public function getMailer() {
1509
+        return $this->query('Mailer');
1510
+    }
1511
+
1512
+    /**
1513
+     * Get the webroot
1514
+     *
1515
+     * @return string
1516
+     */
1517
+    public function getWebRoot() {
1518
+        return $this->webRoot;
1519
+    }
1520
+
1521
+    /**
1522
+     * @return \OC\OCSClient
1523
+     */
1524
+    public function getOcsClient() {
1525
+        return $this->query('OcsClient');
1526
+    }
1527
+
1528
+    /**
1529
+     * @return \OCP\IDateTimeZone
1530
+     */
1531
+    public function getDateTimeZone() {
1532
+        return $this->query('DateTimeZone');
1533
+    }
1534
+
1535
+    /**
1536
+     * @return \OCP\IDateTimeFormatter
1537
+     */
1538
+    public function getDateTimeFormatter() {
1539
+        return $this->query('DateTimeFormatter');
1540
+    }
1541
+
1542
+    /**
1543
+     * @return \OCP\Files\Config\IMountProviderCollection
1544
+     */
1545
+    public function getMountProviderCollection() {
1546
+        return $this->query('MountConfigManager');
1547
+    }
1548
+
1549
+    /**
1550
+     * Get the IniWrapper
1551
+     *
1552
+     * @return IniGetWrapper
1553
+     */
1554
+    public function getIniWrapper() {
1555
+        return $this->query('IniWrapper');
1556
+    }
1557
+
1558
+    /**
1559
+     * @return \OCP\Command\IBus
1560
+     */
1561
+    public function getCommandBus() {
1562
+        return $this->query('AsyncCommandBus');
1563
+    }
1564
+
1565
+    /**
1566
+     * Get the trusted domain helper
1567
+     *
1568
+     * @return TrustedDomainHelper
1569
+     */
1570
+    public function getTrustedDomainHelper() {
1571
+        return $this->query('TrustedDomainHelper');
1572
+    }
1573
+
1574
+    /**
1575
+     * Get the locking provider
1576
+     *
1577
+     * @return \OCP\Lock\ILockingProvider
1578
+     * @since 8.1.0
1579
+     */
1580
+    public function getLockingProvider() {
1581
+        return $this->query('LockingProvider');
1582
+    }
1583
+
1584
+    /**
1585
+     * @return \OCP\Files\Mount\IMountManager
1586
+     **/
1587
+    function getMountManager() {
1588
+        return $this->query('MountManager');
1589
+    }
1590
+
1591
+    /** @return \OCP\Files\Config\IUserMountCache */
1592
+    function getUserMountCache() {
1593
+        return $this->query('UserMountCache');
1594
+    }
1595
+
1596
+    /**
1597
+     * Get the MimeTypeDetector
1598
+     *
1599
+     * @return \OCP\Files\IMimeTypeDetector
1600
+     */
1601
+    public function getMimeTypeDetector() {
1602
+        return $this->query('MimeTypeDetector');
1603
+    }
1604
+
1605
+    /**
1606
+     * Get the MimeTypeLoader
1607
+     *
1608
+     * @return \OCP\Files\IMimeTypeLoader
1609
+     */
1610
+    public function getMimeTypeLoader() {
1611
+        return $this->query('MimeTypeLoader');
1612
+    }
1613
+
1614
+    /**
1615
+     * Get the manager of all the capabilities
1616
+     *
1617
+     * @return \OC\CapabilitiesManager
1618
+     */
1619
+    public function getCapabilitiesManager() {
1620
+        return $this->query('CapabilitiesManager');
1621
+    }
1622
+
1623
+    /**
1624
+     * Get the EventDispatcher
1625
+     *
1626
+     * @return EventDispatcherInterface
1627
+     * @since 8.2.0
1628
+     */
1629
+    public function getEventDispatcher() {
1630
+        return $this->query('EventDispatcher');
1631
+    }
1632
+
1633
+    /**
1634
+     * Get the Notification Manager
1635
+     *
1636
+     * @return \OCP\Notification\IManager
1637
+     * @since 8.2.0
1638
+     */
1639
+    public function getNotificationManager() {
1640
+        return $this->query('NotificationManager');
1641
+    }
1642
+
1643
+    /**
1644
+     * @return \OCP\Comments\ICommentsManager
1645
+     */
1646
+    public function getCommentsManager() {
1647
+        return $this->query('CommentsManager');
1648
+    }
1649
+
1650
+    /**
1651
+     * @return \OCA\Theming\ThemingDefaults
1652
+     */
1653
+    public function getThemingDefaults() {
1654
+        return $this->query('ThemingDefaults');
1655
+    }
1656
+
1657
+    /**
1658
+     * @return \OC\IntegrityCheck\Checker
1659
+     */
1660
+    public function getIntegrityCodeChecker() {
1661
+        return $this->query('IntegrityCodeChecker');
1662
+    }
1663
+
1664
+    /**
1665
+     * @return \OC\Session\CryptoWrapper
1666
+     */
1667
+    public function getSessionCryptoWrapper() {
1668
+        return $this->query('CryptoWrapper');
1669
+    }
1670
+
1671
+    /**
1672
+     * @return CsrfTokenManager
1673
+     */
1674
+    public function getCsrfTokenManager() {
1675
+        return $this->query('CsrfTokenManager');
1676
+    }
1677
+
1678
+    /**
1679
+     * @return Throttler
1680
+     */
1681
+    public function getBruteForceThrottler() {
1682
+        return $this->query('Throttler');
1683
+    }
1684
+
1685
+    /**
1686
+     * @return IContentSecurityPolicyManager
1687
+     */
1688
+    public function getContentSecurityPolicyManager() {
1689
+        return $this->query('ContentSecurityPolicyManager');
1690
+    }
1691
+
1692
+    /**
1693
+     * @return ContentSecurityPolicyNonceManager
1694
+     */
1695
+    public function getContentSecurityPolicyNonceManager() {
1696
+        return $this->query('ContentSecurityPolicyNonceManager');
1697
+    }
1698
+
1699
+    /**
1700
+     * Not a public API as of 8.2, wait for 9.0
1701
+     *
1702
+     * @return \OCA\Files_External\Service\BackendService
1703
+     */
1704
+    public function getStoragesBackendService() {
1705
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1706
+    }
1707
+
1708
+    /**
1709
+     * Not a public API as of 8.2, wait for 9.0
1710
+     *
1711
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1712
+     */
1713
+    public function getGlobalStoragesService() {
1714
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1715
+    }
1716
+
1717
+    /**
1718
+     * Not a public API as of 8.2, wait for 9.0
1719
+     *
1720
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1721
+     */
1722
+    public function getUserGlobalStoragesService() {
1723
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1724
+    }
1725
+
1726
+    /**
1727
+     * Not a public API as of 8.2, wait for 9.0
1728
+     *
1729
+     * @return \OCA\Files_External\Service\UserStoragesService
1730
+     */
1731
+    public function getUserStoragesService() {
1732
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1733
+    }
1734
+
1735
+    /**
1736
+     * @return \OCP\Share\IManager
1737
+     */
1738
+    public function getShareManager() {
1739
+        return $this->query('ShareManager');
1740
+    }
1741
+
1742
+    /**
1743
+     * Returns the LDAP Provider
1744
+     *
1745
+     * @return \OCP\LDAP\ILDAPProvider
1746
+     */
1747
+    public function getLDAPProvider() {
1748
+        return $this->query('LDAPProvider');
1749
+    }
1750
+
1751
+    /**
1752
+     * @return \OCP\Settings\IManager
1753
+     */
1754
+    public function getSettingsManager() {
1755
+        return $this->query('SettingsManager');
1756
+    }
1757
+
1758
+    /**
1759
+     * @return \OCP\Files\IAppData
1760
+     */
1761
+    public function getAppDataDir($app) {
1762
+        /** @var \OC\Files\AppData\Factory $factory */
1763
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1764
+        return $factory->get($app);
1765
+    }
1766
+
1767
+    /**
1768
+     * @return \OCP\Lockdown\ILockdownManager
1769
+     */
1770
+    public function getLockdownManager() {
1771
+        return $this->query('LockdownManager');
1772
+    }
1773
+
1774
+    /**
1775
+     * @return \OCP\Federation\ICloudIdManager
1776
+     */
1777
+    public function getCloudIdManager() {
1778
+        return $this->query(ICloudIdManager::class);
1779
+    }
1780 1780
 }
Please login to merge, or discard this patch.