Completed
Pull Request — master (#3898)
by Joas
73:48 queued 58:08
created
lib/private/Settings/Manager.php 1 patch
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -38,323 +38,323 @@
 block discarded – undo
38 38
 use OCP\Settings\ISection;
39 39
 
40 40
 class Manager implements IManager {
41
-	const TABLE_ADMIN_SETTINGS = 'admin_settings';
42
-	const TABLE_ADMIN_SECTIONS = 'admin_sections';
41
+    const TABLE_ADMIN_SETTINGS = 'admin_settings';
42
+    const TABLE_ADMIN_SECTIONS = 'admin_sections';
43 43
 
44
-	/** @var ILogger */
45
-	private $log;
46
-	/** @var IDBConnection */
47
-	private $dbc;
48
-	/** @var Mapper */
49
-	private $mapper;
50
-	/** @var IL10N */
51
-	private $l;
52
-	/** @var IConfig */
53
-	private $config;
54
-	/** @var EncryptionManager */
55
-	private $encryptionManager;
56
-	/** @var IUserManager */
57
-	private $userManager;
58
-	/** @var ILockingProvider */
59
-	private $lockingProvider;
60
-	/** @var IRequest */
61
-	private $request;
62
-	/** @var IURLGenerator */
63
-	private $url;
44
+    /** @var ILogger */
45
+    private $log;
46
+    /** @var IDBConnection */
47
+    private $dbc;
48
+    /** @var Mapper */
49
+    private $mapper;
50
+    /** @var IL10N */
51
+    private $l;
52
+    /** @var IConfig */
53
+    private $config;
54
+    /** @var EncryptionManager */
55
+    private $encryptionManager;
56
+    /** @var IUserManager */
57
+    private $userManager;
58
+    /** @var ILockingProvider */
59
+    private $lockingProvider;
60
+    /** @var IRequest */
61
+    private $request;
62
+    /** @var IURLGenerator */
63
+    private $url;
64 64
 
65
-	/**
66
-	 * @param ILogger $log
67
-	 * @param IDBConnection $dbc
68
-	 * @param IL10N $l
69
-	 * @param IConfig $config
70
-	 * @param EncryptionManager $encryptionManager
71
-	 * @param IUserManager $userManager
72
-	 * @param ILockingProvider $lockingProvider
73
-	 * @param IRequest $request
74
-	 * @param Mapper $mapper
75
-	 * @param IURLGenerator $url
76
-	 */
77
-	public function __construct(
78
-		ILogger $log,
79
-		IDBConnection $dbc,
80
-		IL10N $l,
81
-		IConfig $config,
82
-		EncryptionManager $encryptionManager,
83
-		IUserManager $userManager,
84
-		ILockingProvider $lockingProvider,
85
-		IRequest $request,
86
-		Mapper $mapper,
87
-		IURLGenerator $url
88
-	) {
89
-		$this->log = $log;
90
-		$this->dbc = $dbc;
91
-		$this->mapper = $mapper;
92
-		$this->l = $l;
93
-		$this->config = $config;
94
-		$this->encryptionManager = $encryptionManager;
95
-		$this->userManager = $userManager;
96
-		$this->lockingProvider = $lockingProvider;
97
-		$this->request = $request;
98
-		$this->url = $url;
99
-	}
65
+    /**
66
+     * @param ILogger $log
67
+     * @param IDBConnection $dbc
68
+     * @param IL10N $l
69
+     * @param IConfig $config
70
+     * @param EncryptionManager $encryptionManager
71
+     * @param IUserManager $userManager
72
+     * @param ILockingProvider $lockingProvider
73
+     * @param IRequest $request
74
+     * @param Mapper $mapper
75
+     * @param IURLGenerator $url
76
+     */
77
+    public function __construct(
78
+        ILogger $log,
79
+        IDBConnection $dbc,
80
+        IL10N $l,
81
+        IConfig $config,
82
+        EncryptionManager $encryptionManager,
83
+        IUserManager $userManager,
84
+        ILockingProvider $lockingProvider,
85
+        IRequest $request,
86
+        Mapper $mapper,
87
+        IURLGenerator $url
88
+    ) {
89
+        $this->log = $log;
90
+        $this->dbc = $dbc;
91
+        $this->mapper = $mapper;
92
+        $this->l = $l;
93
+        $this->config = $config;
94
+        $this->encryptionManager = $encryptionManager;
95
+        $this->userManager = $userManager;
96
+        $this->lockingProvider = $lockingProvider;
97
+        $this->request = $request;
98
+        $this->url = $url;
99
+    }
100 100
 
101
-	/**
102
-	 * @inheritdoc
103
-	 */
104
-	public function setupSettings(array $settings) {
105
-		if (isset($settings[IManager::KEY_ADMIN_SECTION])) {
106
-			$this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]);
107
-		}
108
-		if (isset($settings[IManager::KEY_ADMIN_SETTINGS])) {
109
-			$this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]);
110
-		}
111
-	}
101
+    /**
102
+     * @inheritdoc
103
+     */
104
+    public function setupSettings(array $settings) {
105
+        if (isset($settings[IManager::KEY_ADMIN_SECTION])) {
106
+            $this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]);
107
+        }
108
+        if (isset($settings[IManager::KEY_ADMIN_SETTINGS])) {
109
+            $this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]);
110
+        }
111
+    }
112 112
 
113
-	/**
114
-	 * attempts to remove an apps section and/or settings entry. A listener is
115
-	 * added centrally making sure that this method is called ones an app was
116
-	 * disabled.
117
-	 *
118
-	 * @param string $appId
119
-	 * @since 9.1.0
120
-	 */
121
-	public function onAppDisabled($appId) {
122
-		$appInfo = \OC_App::getAppInfo($appId); // hello static legacy
113
+    /**
114
+     * attempts to remove an apps section and/or settings entry. A listener is
115
+     * added centrally making sure that this method is called ones an app was
116
+     * disabled.
117
+     *
118
+     * @param string $appId
119
+     * @since 9.1.0
120
+     */
121
+    public function onAppDisabled($appId) {
122
+        $appInfo = \OC_App::getAppInfo($appId); // hello static legacy
123 123
 
124
-		if (isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) {
125
-			$this->mapper->remove(self::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\'));
126
-		}
127
-		if (isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) {
128
-			$this->mapper->remove(self::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\'));
129
-		}
130
-	}
124
+        if (isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) {
125
+            $this->mapper->remove(self::TABLE_ADMIN_SECTIONS, trim($appInfo['settings'][IManager::KEY_ADMIN_SECTION], '\\'));
126
+        }
127
+        if (isset($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS])) {
128
+            $this->mapper->remove(self::TABLE_ADMIN_SETTINGS, trim($appInfo['settings'][IManager::KEY_ADMIN_SETTINGS], '\\'));
129
+        }
130
+    }
131 131
 
132
-	public function checkForOrphanedClassNames() {
133
-		$tables = [self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS];
134
-		foreach ($tables as $table) {
135
-			$classes = $this->mapper->getClasses($table);
136
-			foreach ($classes as $className) {
137
-				try {
138
-					\OC::$server->query($className);
139
-				} catch (QueryException $e) {
140
-					$this->mapper->remove($table, $className);
141
-				}
142
-			}
143
-		}
144
-	}
132
+    public function checkForOrphanedClassNames() {
133
+        $tables = [self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS];
134
+        foreach ($tables as $table) {
135
+            $classes = $this->mapper->getClasses($table);
136
+            foreach ($classes as $className) {
137
+                try {
138
+                    \OC::$server->query($className);
139
+                } catch (QueryException $e) {
140
+                    $this->mapper->remove($table, $className);
141
+                }
142
+            }
143
+        }
144
+    }
145 145
 
146
-	/**
147
-	 * @param string $sectionClassName
148
-	 */
149
-	private function setupAdminSection($sectionClassName) {
150
-		if (!class_exists($sectionClassName)) {
151
-			$this->log->debug('Could not find admin section class ' . $sectionClassName);
152
-			return;
153
-		}
154
-		try {
155
-			$section = $this->query($sectionClassName);
156
-		} catch (QueryException $e) {
157
-			// cancel
158
-			return;
159
-		}
146
+    /**
147
+     * @param string $sectionClassName
148
+     */
149
+    private function setupAdminSection($sectionClassName) {
150
+        if (!class_exists($sectionClassName)) {
151
+            $this->log->debug('Could not find admin section class ' . $sectionClassName);
152
+            return;
153
+        }
154
+        try {
155
+            $section = $this->query($sectionClassName);
156
+        } catch (QueryException $e) {
157
+            // cancel
158
+            return;
159
+        }
160 160
 
161
-		if (!$section instanceof ISection) {
162
-			$this->log->error(
163
-				'Admin section instance must implement \OCP\ISection. Invalid class: {class}',
164
-				['class' => $sectionClassName]
165
-			);
166
-			return;
167
-		}
168
-		if (!$this->hasAdminSection(get_class($section))) {
169
-			$this->addAdminSection($section);
170
-		} else {
171
-			$this->updateAdminSection($section);
172
-		}
173
-	}
161
+        if (!$section instanceof ISection) {
162
+            $this->log->error(
163
+                'Admin section instance must implement \OCP\ISection. Invalid class: {class}',
164
+                ['class' => $sectionClassName]
165
+            );
166
+            return;
167
+        }
168
+        if (!$this->hasAdminSection(get_class($section))) {
169
+            $this->addAdminSection($section);
170
+        } else {
171
+            $this->updateAdminSection($section);
172
+        }
173
+    }
174 174
 
175
-	private function addAdminSection(ISection $section) {
176
-		$this->mapper->add(self::TABLE_ADMIN_SECTIONS, [
177
-			'id' => $section->getID(),
178
-			'class' => get_class($section),
179
-			'priority' => $section->getPriority(),
180
-		]);
181
-	}
175
+    private function addAdminSection(ISection $section) {
176
+        $this->mapper->add(self::TABLE_ADMIN_SECTIONS, [
177
+            'id' => $section->getID(),
178
+            'class' => get_class($section),
179
+            'priority' => $section->getPriority(),
180
+        ]);
181
+    }
182 182
 
183
-	private function addAdminSettings(ISettings $settings) {
184
-		$this->mapper->add(self::TABLE_ADMIN_SETTINGS, [
185
-			'class' => get_class($settings),
186
-			'section' => $settings->getSection(),
187
-			'priority' => $settings->getPriority(),
188
-		]);
189
-	}
183
+    private function addAdminSettings(ISettings $settings) {
184
+        $this->mapper->add(self::TABLE_ADMIN_SETTINGS, [
185
+            'class' => get_class($settings),
186
+            'section' => $settings->getSection(),
187
+            'priority' => $settings->getPriority(),
188
+        ]);
189
+    }
190 190
 
191
-	private function updateAdminSettings(ISettings $settings) {
192
-		$this->mapper->update(
193
-			self::TABLE_ADMIN_SETTINGS,
194
-			'class',
195
-			get_class($settings),
196
-			[
197
-				'section' => $settings->getSection(),
198
-				'priority' => $settings->getPriority(),
199
-			]
200
-		);
201
-	}
191
+    private function updateAdminSettings(ISettings $settings) {
192
+        $this->mapper->update(
193
+            self::TABLE_ADMIN_SETTINGS,
194
+            'class',
195
+            get_class($settings),
196
+            [
197
+                'section' => $settings->getSection(),
198
+                'priority' => $settings->getPriority(),
199
+            ]
200
+        );
201
+    }
202 202
 
203
-	private function updateAdminSection(ISection $section) {
204
-		$this->mapper->update(
205
-			self::TABLE_ADMIN_SECTIONS,
206
-			'class',
207
-			get_class($section),
208
-			[
209
-				'id' => $section->getID(),
210
-				'priority' => $section->getPriority(),
211
-			]
212
-		);
213
-	}
203
+    private function updateAdminSection(ISection $section) {
204
+        $this->mapper->update(
205
+            self::TABLE_ADMIN_SECTIONS,
206
+            'class',
207
+            get_class($section),
208
+            [
209
+                'id' => $section->getID(),
210
+                'priority' => $section->getPriority(),
211
+            ]
212
+        );
213
+    }
214 214
 
215
-	/**
216
-	 * @param string $className
217
-	 * @return bool
218
-	 */
219
-	private function hasAdminSection($className) {
220
-		return $this->mapper->has(self::TABLE_ADMIN_SECTIONS, $className);
221
-	}
215
+    /**
216
+     * @param string $className
217
+     * @return bool
218
+     */
219
+    private function hasAdminSection($className) {
220
+        return $this->mapper->has(self::TABLE_ADMIN_SECTIONS, $className);
221
+    }
222 222
 
223
-	/**
224
-	 * @param string $className
225
-	 * @return bool
226
-	 */
227
-	private function hasAdminSettings($className) {
228
-		return $this->mapper->has(self::TABLE_ADMIN_SETTINGS, $className);
229
-	}
223
+    /**
224
+     * @param string $className
225
+     * @return bool
226
+     */
227
+    private function hasAdminSettings($className) {
228
+        return $this->mapper->has(self::TABLE_ADMIN_SETTINGS, $className);
229
+    }
230 230
 
231
-	private function setupAdminSettings($settingsClassName) {
232
-		if (!class_exists($settingsClassName)) {
233
-			$this->log->debug('Could not find admin section class ' . $settingsClassName);
234
-			return;
235
-		}
231
+    private function setupAdminSettings($settingsClassName) {
232
+        if (!class_exists($settingsClassName)) {
233
+            $this->log->debug('Could not find admin section class ' . $settingsClassName);
234
+            return;
235
+        }
236 236
 
237
-		try {
238
-			/** @var ISettings $settings */
239
-			$settings = $this->query($settingsClassName);
240
-		} catch (QueryException $e) {
241
-			// cancel
242
-			return;
243
-		}
237
+        try {
238
+            /** @var ISettings $settings */
239
+            $settings = $this->query($settingsClassName);
240
+        } catch (QueryException $e) {
241
+            // cancel
242
+            return;
243
+        }
244 244
 
245
-		if (!$settings instanceof ISettings) {
246
-			$this->log->error(
247
-				'Admin section instance must implement \OCP\Settings\ISection. Invalid class: {class}',
248
-				['class' => $settingsClassName]
249
-			);
250
-			return;
251
-		}
252
-		if (!$this->hasAdminSettings(get_class($settings))) {
253
-			$this->addAdminSettings($settings);
254
-		} else {
255
-			$this->updateAdminSettings($settings);
256
-		}
257
-	}
245
+        if (!$settings instanceof ISettings) {
246
+            $this->log->error(
247
+                'Admin section instance must implement \OCP\Settings\ISection. Invalid class: {class}',
248
+                ['class' => $settingsClassName]
249
+            );
250
+            return;
251
+        }
252
+        if (!$this->hasAdminSettings(get_class($settings))) {
253
+            $this->addAdminSettings($settings);
254
+        } else {
255
+            $this->updateAdminSettings($settings);
256
+        }
257
+    }
258 258
 
259
-	private function query($className) {
260
-		try {
261
-			return \OC::$server->query($className);
262
-		} catch (QueryException $e) {
263
-			$this->log->logException($e);
264
-			throw $e;
265
-		}
266
-	}
259
+    private function query($className) {
260
+        try {
261
+            return \OC::$server->query($className);
262
+        } catch (QueryException $e) {
263
+            $this->log->logException($e);
264
+            throw $e;
265
+        }
266
+    }
267 267
 
268
-	/**
269
-	 * @inheritdoc
270
-	 */
271
-	public function getAdminSections() {
272
-		// built-in sections
273
-		$sections = [
274
-			0 => [new Section('server', $this->l->t('Server settings'), 0, $this->url->imagePath('settings', 'admin.svg'))],
275
-			5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
276
-			45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
277
-			98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
278
-			99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))],
279
-		];
268
+    /**
269
+     * @inheritdoc
270
+     */
271
+    public function getAdminSections() {
272
+        // built-in sections
273
+        $sections = [
274
+            0 => [new Section('server', $this->l->t('Server settings'), 0, $this->url->imagePath('settings', 'admin.svg'))],
275
+            5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
276
+            45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
277
+            98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
278
+            99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0, $this->url->imagePath('settings', 'help.svg'))],
279
+        ];
280 280
 
281
-		$rows = $this->mapper->getAdminSectionsFromDB();
281
+        $rows = $this->mapper->getAdminSectionsFromDB();
282 282
 
283
-		foreach ($rows as $row) {
284
-			if (!isset($sections[$row['priority']])) {
285
-				$sections[$row['priority']] = [];
286
-			}
287
-			try {
288
-				$sections[$row['priority']][] = $this->query($row['class']);
289
-			} catch (QueryException $e) {
290
-				// skip
291
-			}
292
-		}
283
+        foreach ($rows as $row) {
284
+            if (!isset($sections[$row['priority']])) {
285
+                $sections[$row['priority']] = [];
286
+            }
287
+            try {
288
+                $sections[$row['priority']][] = $this->query($row['class']);
289
+            } catch (QueryException $e) {
290
+                // skip
291
+            }
292
+        }
293 293
 
294
-		ksort($sections);
294
+        ksort($sections);
295 295
 
296
-		return $sections;
297
-	}
296
+        return $sections;
297
+    }
298 298
 
299
-	/**
300
-	 * @param string $section
301
-	 * @return ISection[]
302
-	 */
303
-	private function getBuiltInAdminSettings($section) {
304
-		$forms = [];
305
-		try {
306
-			if ($section === 'server') {
307
-				/** @var ISettings $form */
308
-				$form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l);
309
-				$forms[$form->getPriority()] = [$form];
310
-				$form = new Admin\ServerDevNotice();
311
-				$forms[$form->getPriority()] = [$form];
312
-			}
313
-			if ($section === 'encryption') {
314
-				/** @var ISettings $form */
315
-				$form = new Admin\Encryption($this->encryptionManager, $this->userManager);
316
-				$forms[$form->getPriority()] = [$form];
317
-			}
318
-			if ($section === 'sharing') {
319
-				/** @var ISettings $form */
320
-				$form = new Admin\Sharing($this->config);
321
-				$forms[$form->getPriority()] = [$form];
322
-			}
323
-			if ($section === 'additional') {
324
-				/** @var ISettings $form */
325
-				$form = new Admin\Additional($this->config);
326
-				$forms[$form->getPriority()] = [$form];
327
-			}
328
-			if ($section === 'tips-tricks') {
329
-				/** @var ISettings $form */
330
-				$form = new Admin\TipsTricks($this->config);
331
-				$forms[$form->getPriority()] = [$form];
332
-			}
333
-		} catch (QueryException $e) {
334
-			// skip
335
-		}
336
-		return $forms;
337
-	}
299
+    /**
300
+     * @param string $section
301
+     * @return ISection[]
302
+     */
303
+    private function getBuiltInAdminSettings($section) {
304
+        $forms = [];
305
+        try {
306
+            if ($section === 'server') {
307
+                /** @var ISettings $form */
308
+                $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l);
309
+                $forms[$form->getPriority()] = [$form];
310
+                $form = new Admin\ServerDevNotice();
311
+                $forms[$form->getPriority()] = [$form];
312
+            }
313
+            if ($section === 'encryption') {
314
+                /** @var ISettings $form */
315
+                $form = new Admin\Encryption($this->encryptionManager, $this->userManager);
316
+                $forms[$form->getPriority()] = [$form];
317
+            }
318
+            if ($section === 'sharing') {
319
+                /** @var ISettings $form */
320
+                $form = new Admin\Sharing($this->config);
321
+                $forms[$form->getPriority()] = [$form];
322
+            }
323
+            if ($section === 'additional') {
324
+                /** @var ISettings $form */
325
+                $form = new Admin\Additional($this->config);
326
+                $forms[$form->getPriority()] = [$form];
327
+            }
328
+            if ($section === 'tips-tricks') {
329
+                /** @var ISettings $form */
330
+                $form = new Admin\TipsTricks($this->config);
331
+                $forms[$form->getPriority()] = [$form];
332
+            }
333
+        } catch (QueryException $e) {
334
+            // skip
335
+        }
336
+        return $forms;
337
+    }
338 338
 
339
-	/**
340
-	 * @inheritdoc
341
-	 */
342
-	public function getAdminSettings($section) {
343
-		$settings = $this->getBuiltInAdminSettings($section);
344
-		$dbRows = $this->mapper->getAdminSettingsFromDB($section);
339
+    /**
340
+     * @inheritdoc
341
+     */
342
+    public function getAdminSettings($section) {
343
+        $settings = $this->getBuiltInAdminSettings($section);
344
+        $dbRows = $this->mapper->getAdminSettingsFromDB($section);
345 345
 
346
-		foreach ($dbRows as $row) {
347
-			if (!isset($settings[$row['priority']])) {
348
-				$settings[$row['priority']] = [];
349
-			}
350
-			try {
351
-				$settings[$row['priority']][] = $this->query($row['class']);
352
-			} catch (QueryException $e) {
353
-				// skip
354
-			}
355
-		}
346
+        foreach ($dbRows as $row) {
347
+            if (!isset($settings[$row['priority']])) {
348
+                $settings[$row['priority']] = [];
349
+            }
350
+            try {
351
+                $settings[$row['priority']][] = $this->query($row['class']);
352
+            } catch (QueryException $e) {
353
+                // skip
354
+            }
355
+        }
356 356
 
357
-		ksort($settings);
358
-		return $settings;
359
-	}
357
+        ksort($settings);
358
+        return $settings;
359
+    }
360 360
 }
Please login to merge, or discard this patch.
lib/private/Settings/Admin/Server.php 2 patches
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -37,124 +37,124 @@
 block discarded – undo
37 37
 use OCP\Settings\ISettings;
38 38
 
39 39
 class Server implements ISettings {
40
-	/** @var IDBConnection|Connection */
41
-	private $db;
42
-	/** @var IRequest */
43
-	private $request;
44
-	/** @var IConfig */
45
-	private $config;
46
-	/** @var ILockingProvider */
47
-	private $lockingProvider;
48
-	/** @var IL10N */
49
-	private $l;
40
+    /** @var IDBConnection|Connection */
41
+    private $db;
42
+    /** @var IRequest */
43
+    private $request;
44
+    /** @var IConfig */
45
+    private $config;
46
+    /** @var ILockingProvider */
47
+    private $lockingProvider;
48
+    /** @var IL10N */
49
+    private $l;
50 50
 
51
-	/**
52
-	 * @param IDBConnection $db
53
-	 * @param IRequest $request
54
-	 * @param IConfig $config
55
-	 * @param ILockingProvider $lockingProvider
56
-	 * @param IL10N $l
57
-	 */
58
-	public function __construct(IDBConnection $db,
59
-								IRequest $request,
60
-								IConfig $config,
61
-								ILockingProvider $lockingProvider,
62
-								IL10N $l) {
63
-		$this->db = $db;
64
-		$this->request = $request;
65
-		$this->config = $config;
66
-		$this->lockingProvider = $lockingProvider;
67
-		$this->l = $l;
68
-	}
51
+    /**
52
+     * @param IDBConnection $db
53
+     * @param IRequest $request
54
+     * @param IConfig $config
55
+     * @param ILockingProvider $lockingProvider
56
+     * @param IL10N $l
57
+     */
58
+    public function __construct(IDBConnection $db,
59
+                                IRequest $request,
60
+                                IConfig $config,
61
+                                ILockingProvider $lockingProvider,
62
+                                IL10N $l) {
63
+        $this->db = $db;
64
+        $this->request = $request;
65
+        $this->config = $config;
66
+        $this->lockingProvider = $lockingProvider;
67
+        $this->l = $l;
68
+    }
69 69
 
70
-	/**
71
-	 * @return TemplateResponse
72
-	 */
73
-	public function getForm() {
74
-		try {
75
-			if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
76
-				$invalidTransactionIsolationLevel = false;
77
-			} else {
78
-				$invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED;
79
-			}
80
-		} catch (DBALException $e) {
81
-			// ignore
82
-			$invalidTransactionIsolationLevel = false;
83
-		}
70
+    /**
71
+     * @return TemplateResponse
72
+     */
73
+    public function getForm() {
74
+        try {
75
+            if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
76
+                $invalidTransactionIsolationLevel = false;
77
+            } else {
78
+                $invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED;
79
+            }
80
+        } catch (DBALException $e) {
81
+            // ignore
82
+            $invalidTransactionIsolationLevel = false;
83
+        }
84 84
 
85
-		$envPath = getenv('PATH');
85
+        $envPath = getenv('PATH');
86 86
 
87
-		// warn if outdated version of a memcache module is used
88
-		$caches = [
89
-			'apcu'	=> ['name' => $this->l->t('APCu'), 'version' => '4.0.6'],
90
-			'redis'	=> ['name' => $this->l->t('Redis'), 'version' => '2.2.5'],
91
-		];
92
-		$outdatedCaches = [];
93
-		foreach ($caches as $php_module => $data) {
94
-			$isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<');
95
-			if ($isOutdated) {
96
-				$outdatedCaches[$php_module] = $data;
97
-			}
98
-		}
87
+        // warn if outdated version of a memcache module is used
88
+        $caches = [
89
+            'apcu'	=> ['name' => $this->l->t('APCu'), 'version' => '4.0.6'],
90
+            'redis'	=> ['name' => $this->l->t('Redis'), 'version' => '2.2.5'],
91
+        ];
92
+        $outdatedCaches = [];
93
+        foreach ($caches as $php_module => $data) {
94
+            $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<');
95
+            if ($isOutdated) {
96
+                $outdatedCaches[$php_module] = $data;
97
+            }
98
+        }
99 99
 
100
-		if ($this->lockingProvider instanceof NoopLockingProvider) {
101
-			$fileLockingType = 'none';
102
-		} else if ($this->lockingProvider instanceof DBLockingProvider) {
103
-			$fileLockingType = 'db';
104
-		} else {
105
-			$fileLockingType = 'cache';
106
-		}
100
+        if ($this->lockingProvider instanceof NoopLockingProvider) {
101
+            $fileLockingType = 'none';
102
+        } else if ($this->lockingProvider instanceof DBLockingProvider) {
103
+            $fileLockingType = 'db';
104
+        } else {
105
+            $fileLockingType = 'cache';
106
+        }
107 107
 
108
-		$suggestedOverwriteCliUrl = '';
109
-		if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
110
-			$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
111
-			if (!$this->config->getSystemValue('config_is_read_only', false)) {
112
-				// Set the overwrite URL when it was not set yet.
113
-				$this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
114
-				$suggestedOverwriteCliUrl = '';
115
-			}
116
-		}
108
+        $suggestedOverwriteCliUrl = '';
109
+        if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
110
+            $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
111
+            if (!$this->config->getSystemValue('config_is_read_only', false)) {
112
+                // Set the overwrite URL when it was not set yet.
113
+                $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
114
+                $suggestedOverwriteCliUrl = '';
115
+            }
116
+        }
117 117
 
118
-		$parameters = [
119
-			// Diagnosis
120
-			'readOnlyConfigEnabled'            => \OC_Helper::isReadOnlyConfigEnabled(),
121
-			'isLocaleWorking'                  => \OC_Util::isSetLocaleWorking(),
122
-			'isAnnotationsWorking'             => \OC_Util::isAnnotationsWorking(),
123
-			'checkForWorkingWellKnownSetup'    => $this->config->getSystemValue('check_for_working_wellknown_setup', true),
124
-			'has_fileinfo'                     => \OC_Util::fileInfoLoaded(),
125
-			'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel,
126
-			'getenvServerNotWorking'           => empty($envPath),
127
-			'OutdatedCacheWarning'             => $outdatedCaches,
128
-			'fileLockingType'                  => $fileLockingType,
129
-			'suggestedOverwriteCliUrl'         => $suggestedOverwriteCliUrl,
118
+        $parameters = [
119
+            // Diagnosis
120
+            'readOnlyConfigEnabled'            => \OC_Helper::isReadOnlyConfigEnabled(),
121
+            'isLocaleWorking'                  => \OC_Util::isSetLocaleWorking(),
122
+            'isAnnotationsWorking'             => \OC_Util::isAnnotationsWorking(),
123
+            'checkForWorkingWellKnownSetup'    => $this->config->getSystemValue('check_for_working_wellknown_setup', true),
124
+            'has_fileinfo'                     => \OC_Util::fileInfoLoaded(),
125
+            'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel,
126
+            'getenvServerNotWorking'           => empty($envPath),
127
+            'OutdatedCacheWarning'             => $outdatedCaches,
128
+            'fileLockingType'                  => $fileLockingType,
129
+            'suggestedOverwriteCliUrl'         => $suggestedOverwriteCliUrl,
130 130
 
131
-			// Background jobs
132
-			'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
133
-			'cron_log'            => $this->config->getSystemValue('cron_log', true),
134
-			'lastcron'            => $this->config->getAppValue('core', 'lastcron', false),
135
-			'cronErrors'		  => $this->config->getAppValue('core', 'cronErrors'),
136
-			'cli_based_cron_possible' => function_exists('posix_getpwuid'),
137
-			'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
138
-		];
131
+            // Background jobs
132
+            'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
133
+            'cron_log'            => $this->config->getSystemValue('cron_log', true),
134
+            'lastcron'            => $this->config->getAppValue('core', 'lastcron', false),
135
+            'cronErrors'		  => $this->config->getAppValue('core', 'cronErrors'),
136
+            'cli_based_cron_possible' => function_exists('posix_getpwuid'),
137
+            'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
138
+        ];
139 139
 
140
-		return new TemplateResponse('settings', 'admin/server', $parameters, '');
141
-	}
140
+        return new TemplateResponse('settings', 'admin/server', $parameters, '');
141
+    }
142 142
 
143
-	/**
144
-	 * @return string the section ID, e.g. 'sharing'
145
-	 */
146
-	public function getSection() {
147
-		return 'server';
148
-	}
143
+    /**
144
+     * @return string the section ID, e.g. 'sharing'
145
+     */
146
+    public function getSection() {
147
+        return 'server';
148
+    }
149 149
 
150
-	/**
151
-	 * @return int whether the form should be rather on the top or bottom of
152
-	 * the admin section. The forms are arranged in ascending order of the
153
-	 * priority values. It is required to return a value between 0 and 100.
154
-	 *
155
-	 * E.g.: 70
156
-	 */
157
-	public function getPriority() {
158
-		return 0;
159
-	}
150
+    /**
151
+     * @return int whether the form should be rather on the top or bottom of
152
+     * the admin section. The forms are arranged in ascending order of the
153
+     * priority values. It is required to return a value between 0 and 100.
154
+     *
155
+     * E.g.: 70
156
+     */
157
+    public function getPriority() {
158
+        return 0;
159
+    }
160 160
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 		$suggestedOverwriteCliUrl = '';
109 109
 		if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
110
-			$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
110
+			$suggestedOverwriteCliUrl = $this->request->getServerProtocol().'://'.$this->request->getInsecureServerHost().\OC::$WEBROOT;
111 111
 			if (!$this->config->getSystemValue('config_is_read_only', false)) {
112 112
 				// Set the overwrite URL when it was not set yet.
113 113
 				$this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 			'lastcron'            => $this->config->getAppValue('core', 'lastcron', false),
135 135
 			'cronErrors'		  => $this->config->getAppValue('core', 'cronErrors'),
136 136
 			'cli_based_cron_possible' => function_exists('posix_getpwuid'),
137
-			'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
137
+			'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir.'config.php'))['name'] : '',
138 138
 		];
139 139
 
140 140
 		return new TemplateResponse('settings', 'admin/server', $parameters, '');
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +1471 added lines, -1471 removed lines patch added patch discarded remove patch
@@ -108,1480 +108,1480 @@
 block discarded – undo
108 108
  * TODO: hookup all manager classes
109 109
  */
110 110
 class Server extends ServerContainer implements IServerContainer {
111
-	/** @var string */
112
-	private $webRoot;
113
-
114
-	/**
115
-	 * @param string $webRoot
116
-	 * @param \OC\Config $config
117
-	 */
118
-	public function __construct($webRoot, \OC\Config $config) {
119
-		parent::__construct();
120
-		$this->webRoot = $webRoot;
121
-
122
-		$this->registerService('ContactsManager', function ($c) {
123
-			return new ContactsManager();
124
-		});
125
-
126
-		$this->registerService('PreviewManager', function (Server $c) {
127
-			return new PreviewManager(
128
-				$c->getConfig(),
129
-				$c->getRootFolder(),
130
-				$c->getAppDataDir('preview'),
131
-				$c->getEventDispatcher(),
132
-				$c->getSession()->get('user_id')
133
-			);
134
-		});
135
-
136
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
137
-			return new \OC\Preview\Watcher(
138
-				$c->getAppDataDir('preview')
139
-			);
140
-		});
141
-
142
-		$this->registerService('EncryptionManager', function (Server $c) {
143
-			$view = new View();
144
-			$util = new Encryption\Util(
145
-				$view,
146
-				$c->getUserManager(),
147
-				$c->getGroupManager(),
148
-				$c->getConfig()
149
-			);
150
-			return new Encryption\Manager(
151
-				$c->getConfig(),
152
-				$c->getLogger(),
153
-				$c->getL10N('core'),
154
-				new View(),
155
-				$util,
156
-				new ArrayCache()
157
-			);
158
-		});
159
-
160
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
161
-			$util = new Encryption\Util(
162
-				new View(),
163
-				$c->getUserManager(),
164
-				$c->getGroupManager(),
165
-				$c->getConfig()
166
-			);
167
-			return new Encryption\File($util);
168
-		});
169
-
170
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
171
-			$view = new View();
172
-			$util = new Encryption\Util(
173
-				$view,
174
-				$c->getUserManager(),
175
-				$c->getGroupManager(),
176
-				$c->getConfig()
177
-			);
178
-
179
-			return new Encryption\Keys\Storage($view, $util);
180
-		});
181
-		$this->registerService('TagMapper', function (Server $c) {
182
-			return new TagMapper($c->getDatabaseConnection());
183
-		});
184
-		$this->registerService('TagManager', function (Server $c) {
185
-			$tagMapper = $c->query('TagMapper');
186
-			return new TagManager($tagMapper, $c->getUserSession());
187
-		});
188
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
189
-			$config = $c->getConfig();
190
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
191
-			/** @var \OC\SystemTag\ManagerFactory $factory */
192
-			$factory = new $factoryClass($this);
193
-			return $factory;
194
-		});
195
-		$this->registerService('SystemTagManager', function (Server $c) {
196
-			return $c->query('SystemTagManagerFactory')->getManager();
197
-		});
198
-		$this->registerService('SystemTagObjectMapper', function (Server $c) {
199
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
200
-		});
201
-		$this->registerService('RootFolder', function (Server $c) {
202
-			$manager = \OC\Files\Filesystem::getMountManager(null);
203
-			$view = new View();
204
-			$root = new Root(
205
-				$manager,
206
-				$view,
207
-				null,
208
-				$c->getUserMountCache(),
209
-				$this->getLogger(),
210
-				$this->getUserManager()
211
-			);
212
-			$connector = new HookConnector($root, $view);
213
-			$connector->viewToNode();
214
-
215
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
216
-			$previewConnector->connectWatcher();
217
-
218
-			return $root;
219
-		});
220
-		$this->registerService('LazyRootFolder', function(Server $c) {
221
-			return new LazyRoot(function() use ($c) {
222
-				return $c->query('RootFolder');
223
-			});
224
-		});
225
-		$this->registerService('UserManager', function (Server $c) {
226
-			$config = $c->getConfig();
227
-			return new \OC\User\Manager($config);
228
-		});
229
-		$this->registerService('GroupManager', function (Server $c) {
230
-			$groupManager = new \OC\Group\Manager($this->getUserManager());
231
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
232
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
233
-			});
234
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
235
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
236
-			});
237
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
238
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
239
-			});
240
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
241
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
242
-			});
243
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
244
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
245
-			});
246
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
247
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
248
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
249
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
250
-			});
251
-			return $groupManager;
252
-		});
253
-		$this->registerService(Store::class, function(Server $c) {
254
-			$session = $c->getSession();
255
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
256
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
257
-			} else {
258
-				$tokenProvider = null;
259
-			}
260
-			$logger = $c->getLogger();
261
-			return new Store($session, $logger, $tokenProvider);
262
-		});
263
-		$this->registerAlias(IStore::class, Store::class);
264
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
265
-			$dbConnection = $c->getDatabaseConnection();
266
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
267
-		});
268
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
269
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
270
-			$crypto = $c->getCrypto();
271
-			$config = $c->getConfig();
272
-			$logger = $c->getLogger();
273
-			$timeFactory = new TimeFactory();
274
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
275
-		});
276
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
277
-		$this->registerService('UserSession', function (Server $c) {
278
-			$manager = $c->getUserManager();
279
-			$session = new \OC\Session\Memory('');
280
-			$timeFactory = new TimeFactory();
281
-			// Token providers might require a working database. This code
282
-			// might however be called when ownCloud is not yet setup.
283
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
284
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
285
-			} else {
286
-				$defaultTokenProvider = null;
287
-			}
288
-
289
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
290
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
291
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
292
-			});
293
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
294
-				/** @var $user \OC\User\User */
295
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
296
-			});
297
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
298
-				/** @var $user \OC\User\User */
299
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
300
-			});
301
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
302
-				/** @var $user \OC\User\User */
303
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
304
-			});
305
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
306
-				/** @var $user \OC\User\User */
307
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
308
-			});
309
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
310
-				/** @var $user \OC\User\User */
311
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
312
-			});
313
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
314
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
315
-			});
316
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
317
-				/** @var $user \OC\User\User */
318
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
319
-			});
320
-			$userSession->listen('\OC\User', 'logout', function () {
321
-				\OC_Hook::emit('OC_User', 'logout', array());
322
-			});
323
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
324
-				/** @var $user \OC\User\User */
325
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
326
-			});
327
-			return $userSession;
328
-		});
329
-
330
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
331
-			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
332
-		});
333
-
334
-		$this->registerService('NavigationManager', function (Server $c) {
335
-			return new \OC\NavigationManager($c->getAppManager(),
336
-				$c->getURLGenerator(),
337
-				$c->getL10NFactory(),
338
-				$c->getUserSession(),
339
-				$c->getGroupManager());
340
-		});
341
-		$this->registerService('AllConfig', function (Server $c) {
342
-			return new \OC\AllConfig(
343
-				$c->getSystemConfig()
344
-			);
345
-		});
346
-		$this->registerService('SystemConfig', function ($c) use ($config) {
347
-			return new \OC\SystemConfig($config);
348
-		});
349
-		$this->registerService('AppConfig', function (Server $c) {
350
-			return new \OC\AppConfig($c->getDatabaseConnection());
351
-		});
352
-		$this->registerService('L10NFactory', function (Server $c) {
353
-			return new \OC\L10N\Factory(
354
-				$c->getConfig(),
355
-				$c->getRequest(),
356
-				$c->getUserSession(),
357
-				\OC::$SERVERROOT
358
-			);
359
-		});
360
-		$this->registerService('URLGenerator', function (Server $c) {
361
-			$config = $c->getConfig();
362
-			$cacheFactory = $c->getMemCacheFactory();
363
-			return new \OC\URLGenerator(
364
-				$config,
365
-				$cacheFactory
366
-			);
367
-		});
368
-		$this->registerService('AppHelper', function ($c) {
369
-			return new \OC\AppHelper();
370
-		});
371
-		$this->registerService('AppFetcher', function ($c) {
372
-			return new AppFetcher(
373
-				$this->getAppDataDir('appstore'),
374
-				$this->getHTTPClientService(),
375
-				$this->query(TimeFactory::class),
376
-				$this->getConfig()
377
-			);
378
-		});
379
-		$this->registerService('CategoryFetcher', function ($c) {
380
-			return new CategoryFetcher(
381
-				$this->getAppDataDir('appstore'),
382
-				$this->getHTTPClientService(),
383
-				$this->query(TimeFactory::class),
384
-				$this->getConfig()
385
-			);
386
-		});
387
-		$this->registerService('UserCache', function ($c) {
388
-			return new Cache\File();
389
-		});
390
-		$this->registerService('MemCacheFactory', function (Server $c) {
391
-			$config = $c->getConfig();
392
-
393
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
394
-				$v = \OC_App::getAppVersions();
395
-				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
396
-				$version = implode(',', $v);
397
-				$instanceId = \OC_Util::getInstanceId();
398
-				$path = \OC::$SERVERROOT;
399
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
400
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
401
-					$config->getSystemValue('memcache.local', null),
402
-					$config->getSystemValue('memcache.distributed', null),
403
-					$config->getSystemValue('memcache.locking', null)
404
-				);
405
-			}
406
-
407
-			return new \OC\Memcache\Factory('', $c->getLogger(),
408
-				'\\OC\\Memcache\\ArrayCache',
409
-				'\\OC\\Memcache\\ArrayCache',
410
-				'\\OC\\Memcache\\ArrayCache'
411
-			);
412
-		});
413
-		$this->registerService('RedisFactory', function (Server $c) {
414
-			$systemConfig = $c->getSystemConfig();
415
-			return new RedisFactory($systemConfig);
416
-		});
417
-		$this->registerService('ActivityManager', function (Server $c) {
418
-			return new \OC\Activity\Manager(
419
-				$c->getRequest(),
420
-				$c->getUserSession(),
421
-				$c->getConfig(),
422
-				$c->query(IValidator::class)
423
-			);
424
-		});
425
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
426
-			return new \OC\Activity\EventMerger(
427
-				$c->getL10N('lib')
428
-			);
429
-		});
430
-		$this->registerAlias(IValidator::class, Validator::class);
431
-		$this->registerService('AvatarManager', function (Server $c) {
432
-			return new AvatarManager(
433
-				$c->getUserManager(),
434
-				$c->getAppDataDir('avatar'),
435
-				$c->getL10N('lib'),
436
-				$c->getLogger(),
437
-				$c->getConfig()
438
-			);
439
-		});
440
-		$this->registerService('Logger', function (Server $c) {
441
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
442
-			$logger = Log::getLogClass($logType);
443
-			call_user_func(array($logger, 'init'));
444
-
445
-			return new Log($logger);
446
-		});
447
-		$this->registerService('JobList', function (Server $c) {
448
-			$config = $c->getConfig();
449
-			return new \OC\BackgroundJob\JobList(
450
-				$c->getDatabaseConnection(),
451
-				$config,
452
-				new TimeFactory()
453
-			);
454
-		});
455
-		$this->registerService('Router', function (Server $c) {
456
-			$cacheFactory = $c->getMemCacheFactory();
457
-			$logger = $c->getLogger();
458
-			if ($cacheFactory->isAvailable()) {
459
-				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
460
-			} else {
461
-				$router = new \OC\Route\Router($logger);
462
-			}
463
-			return $router;
464
-		});
465
-		$this->registerService('Search', function ($c) {
466
-			return new Search();
467
-		});
468
-		$this->registerService('SecureRandom', function ($c) {
469
-			return new SecureRandom();
470
-		});
471
-		$this->registerService('Crypto', function (Server $c) {
472
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
473
-		});
474
-		$this->registerService('Hasher', function (Server $c) {
475
-			return new Hasher($c->getConfig());
476
-		});
477
-		$this->registerService('CredentialsManager', function (Server $c) {
478
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
479
-		});
480
-		$this->registerService('DatabaseConnection', function (Server $c) {
481
-			$systemConfig = $c->getSystemConfig();
482
-			$factory = new \OC\DB\ConnectionFactory($c->getConfig());
483
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
484
-			if (!$factory->isValidType($type)) {
485
-				throw new \OC\DatabaseException('Invalid database type');
486
-			}
487
-			$connectionParams = $factory->createConnectionParams($systemConfig);
488
-			$connection = $factory->getConnection($type, $connectionParams);
489
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
490
-			return $connection;
491
-		});
492
-		$this->registerService('HTTPHelper', function (Server $c) {
493
-			$config = $c->getConfig();
494
-			return new HTTPHelper(
495
-				$config,
496
-				$c->getHTTPClientService()
497
-			);
498
-		});
499
-		$this->registerService('HttpClientService', function (Server $c) {
500
-			$user = \OC_User::getUser();
501
-			$uid = $user ? $user : null;
502
-			return new ClientService(
503
-				$c->getConfig(),
504
-				new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
505
-			);
506
-		});
507
-		$this->registerService('EventLogger', function (Server $c) {
508
-			if ($c->getSystemConfig()->getValue('debug', false)) {
509
-				return new EventLogger();
510
-			} else {
511
-				return new NullEventLogger();
512
-			}
513
-		});
514
-		$this->registerService('QueryLogger', function (Server $c) {
515
-			if ($c->getSystemConfig()->getValue('debug', false)) {
516
-				return new QueryLogger();
517
-			} else {
518
-				return new NullQueryLogger();
519
-			}
520
-		});
521
-		$this->registerService('TempManager', function (Server $c) {
522
-			return new TempManager(
523
-				$c->getLogger(),
524
-				$c->getConfig()
525
-			);
526
-		});
527
-		$this->registerService('AppManager', function (Server $c) {
528
-			return new \OC\App\AppManager(
529
-				$c->getUserSession(),
530
-				$c->getAppConfig(),
531
-				$c->getGroupManager(),
532
-				$c->getMemCacheFactory(),
533
-				$c->getEventDispatcher()
534
-			);
535
-		});
536
-		$this->registerService('DateTimeZone', function (Server $c) {
537
-			return new DateTimeZone(
538
-				$c->getConfig(),
539
-				$c->getSession()
540
-			);
541
-		});
542
-		$this->registerService('DateTimeFormatter', function (Server $c) {
543
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
544
-
545
-			return new DateTimeFormatter(
546
-				$c->getDateTimeZone()->getTimeZone(),
547
-				$c->getL10N('lib', $language)
548
-			);
549
-		});
550
-		$this->registerService('UserMountCache', function (Server $c) {
551
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
552
-			$listener = new UserMountCacheListener($mountCache);
553
-			$listener->listen($c->getUserManager());
554
-			return $mountCache;
555
-		});
556
-		$this->registerService('MountConfigManager', function (Server $c) {
557
-			$loader = \OC\Files\Filesystem::getLoader();
558
-			$mountCache = $c->query('UserMountCache');
559
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
560
-
561
-			// builtin providers
562
-
563
-			$config = $c->getConfig();
564
-			$manager->registerProvider(new CacheMountProvider($config));
565
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
566
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
567
-
568
-			return $manager;
569
-		});
570
-		$this->registerService('IniWrapper', function ($c) {
571
-			return new IniGetWrapper();
572
-		});
573
-		$this->registerService('AsyncCommandBus', function (Server $c) {
574
-			$jobList = $c->getJobList();
575
-			return new AsyncBus($jobList);
576
-		});
577
-		$this->registerService('TrustedDomainHelper', function ($c) {
578
-			return new TrustedDomainHelper($this->getConfig());
579
-		});
580
-		$this->registerService('Throttler', function(Server $c) {
581
-			return new Throttler(
582
-				$c->getDatabaseConnection(),
583
-				new TimeFactory(),
584
-				$c->getLogger(),
585
-				$c->getConfig()
586
-			);
587
-		});
588
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
589
-			// IConfig and IAppManager requires a working database. This code
590
-			// might however be called when ownCloud is not yet setup.
591
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
592
-				$config = $c->getConfig();
593
-				$appManager = $c->getAppManager();
594
-			} else {
595
-				$config = null;
596
-				$appManager = null;
597
-			}
598
-
599
-			return new Checker(
600
-					new EnvironmentHelper(),
601
-					new FileAccessHelper(),
602
-					new AppLocator(),
603
-					$config,
604
-					$c->getMemCacheFactory(),
605
-					$appManager,
606
-					$c->getTempManager()
607
-			);
608
-		});
609
-		$this->registerService('Request', function ($c) {
610
-			if (isset($this['urlParams'])) {
611
-				$urlParams = $this['urlParams'];
612
-			} else {
613
-				$urlParams = [];
614
-			}
615
-
616
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
617
-				&& in_array('fakeinput', stream_get_wrappers())
618
-			) {
619
-				$stream = 'fakeinput://data';
620
-			} else {
621
-				$stream = 'php://input';
622
-			}
623
-
624
-			return new Request(
625
-				[
626
-					'get' => $_GET,
627
-					'post' => $_POST,
628
-					'files' => $_FILES,
629
-					'server' => $_SERVER,
630
-					'env' => $_ENV,
631
-					'cookies' => $_COOKIE,
632
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
633
-						? $_SERVER['REQUEST_METHOD']
634
-						: null,
635
-					'urlParams' => $urlParams,
636
-				],
637
-				$this->getSecureRandom(),
638
-				$this->getConfig(),
639
-				$this->getCsrfTokenManager(),
640
-				$stream
641
-			);
642
-		});
643
-		$this->registerService('Mailer', function (Server $c) {
644
-			return new Mailer(
645
-				$c->getConfig(),
646
-				$c->getLogger(),
647
-				$c->getThemingDefaults()
648
-			);
649
-		});
650
-		$this->registerService('LDAPProvider', function(Server $c) {
651
-			$config = $c->getConfig();
652
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
653
-			if(is_null($factoryClass)) {
654
-				throw new \Exception('ldapProviderFactory not set');
655
-			}
656
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
657
-			$factory = new $factoryClass($this);
658
-			return $factory->getLDAPProvider();
659
-		});
660
-		$this->registerService('LockingProvider', function (Server $c) {
661
-			$ini = $c->getIniWrapper();
662
-			$config = $c->getConfig();
663
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
664
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
665
-				/** @var \OC\Memcache\Factory $memcacheFactory */
666
-				$memcacheFactory = $c->getMemCacheFactory();
667
-				$memcache = $memcacheFactory->createLocking('lock');
668
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
669
-					return new MemcacheLockingProvider($memcache, $ttl);
670
-				}
671
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
672
-			}
673
-			return new NoopLockingProvider();
674
-		});
675
-		$this->registerService('MountManager', function () {
676
-			return new \OC\Files\Mount\Manager();
677
-		});
678
-		$this->registerService('MimeTypeDetector', function (Server $c) {
679
-			return new \OC\Files\Type\Detection(
680
-				$c->getURLGenerator(),
681
-				\OC::$configDir,
682
-				\OC::$SERVERROOT . '/resources/config/'
683
-			);
684
-		});
685
-		$this->registerService('MimeTypeLoader', function (Server $c) {
686
-			return new \OC\Files\Type\Loader(
687
-				$c->getDatabaseConnection()
688
-			);
689
-		});
690
-		$this->registerService('NotificationManager', function (Server $c) {
691
-			return new Manager(
692
-				$c->query(IValidator::class)
693
-			);
694
-		});
695
-		$this->registerService('CapabilitiesManager', function (Server $c) {
696
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
697
-			$manager->registerCapability(function () use ($c) {
698
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
699
-			});
700
-			return $manager;
701
-		});
702
-		$this->registerService('CommentsManager', function(Server $c) {
703
-			$config = $c->getConfig();
704
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
705
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
706
-			$factory = new $factoryClass($this);
707
-			return $factory->getManager();
708
-		});
709
-		$this->registerService('ThemingDefaults', function(Server $c) {
710
-			/*
111
+    /** @var string */
112
+    private $webRoot;
113
+
114
+    /**
115
+     * @param string $webRoot
116
+     * @param \OC\Config $config
117
+     */
118
+    public function __construct($webRoot, \OC\Config $config) {
119
+        parent::__construct();
120
+        $this->webRoot = $webRoot;
121
+
122
+        $this->registerService('ContactsManager', function ($c) {
123
+            return new ContactsManager();
124
+        });
125
+
126
+        $this->registerService('PreviewManager', function (Server $c) {
127
+            return new PreviewManager(
128
+                $c->getConfig(),
129
+                $c->getRootFolder(),
130
+                $c->getAppDataDir('preview'),
131
+                $c->getEventDispatcher(),
132
+                $c->getSession()->get('user_id')
133
+            );
134
+        });
135
+
136
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
137
+            return new \OC\Preview\Watcher(
138
+                $c->getAppDataDir('preview')
139
+            );
140
+        });
141
+
142
+        $this->registerService('EncryptionManager', function (Server $c) {
143
+            $view = new View();
144
+            $util = new Encryption\Util(
145
+                $view,
146
+                $c->getUserManager(),
147
+                $c->getGroupManager(),
148
+                $c->getConfig()
149
+            );
150
+            return new Encryption\Manager(
151
+                $c->getConfig(),
152
+                $c->getLogger(),
153
+                $c->getL10N('core'),
154
+                new View(),
155
+                $util,
156
+                new ArrayCache()
157
+            );
158
+        });
159
+
160
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
161
+            $util = new Encryption\Util(
162
+                new View(),
163
+                $c->getUserManager(),
164
+                $c->getGroupManager(),
165
+                $c->getConfig()
166
+            );
167
+            return new Encryption\File($util);
168
+        });
169
+
170
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
171
+            $view = new View();
172
+            $util = new Encryption\Util(
173
+                $view,
174
+                $c->getUserManager(),
175
+                $c->getGroupManager(),
176
+                $c->getConfig()
177
+            );
178
+
179
+            return new Encryption\Keys\Storage($view, $util);
180
+        });
181
+        $this->registerService('TagMapper', function (Server $c) {
182
+            return new TagMapper($c->getDatabaseConnection());
183
+        });
184
+        $this->registerService('TagManager', function (Server $c) {
185
+            $tagMapper = $c->query('TagMapper');
186
+            return new TagManager($tagMapper, $c->getUserSession());
187
+        });
188
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
189
+            $config = $c->getConfig();
190
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
191
+            /** @var \OC\SystemTag\ManagerFactory $factory */
192
+            $factory = new $factoryClass($this);
193
+            return $factory;
194
+        });
195
+        $this->registerService('SystemTagManager', function (Server $c) {
196
+            return $c->query('SystemTagManagerFactory')->getManager();
197
+        });
198
+        $this->registerService('SystemTagObjectMapper', function (Server $c) {
199
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
200
+        });
201
+        $this->registerService('RootFolder', function (Server $c) {
202
+            $manager = \OC\Files\Filesystem::getMountManager(null);
203
+            $view = new View();
204
+            $root = new Root(
205
+                $manager,
206
+                $view,
207
+                null,
208
+                $c->getUserMountCache(),
209
+                $this->getLogger(),
210
+                $this->getUserManager()
211
+            );
212
+            $connector = new HookConnector($root, $view);
213
+            $connector->viewToNode();
214
+
215
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
216
+            $previewConnector->connectWatcher();
217
+
218
+            return $root;
219
+        });
220
+        $this->registerService('LazyRootFolder', function(Server $c) {
221
+            return new LazyRoot(function() use ($c) {
222
+                return $c->query('RootFolder');
223
+            });
224
+        });
225
+        $this->registerService('UserManager', function (Server $c) {
226
+            $config = $c->getConfig();
227
+            return new \OC\User\Manager($config);
228
+        });
229
+        $this->registerService('GroupManager', function (Server $c) {
230
+            $groupManager = new \OC\Group\Manager($this->getUserManager());
231
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
232
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
233
+            });
234
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
235
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
236
+            });
237
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
238
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
239
+            });
240
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
241
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
242
+            });
243
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
244
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
245
+            });
246
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
247
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
248
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
249
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
250
+            });
251
+            return $groupManager;
252
+        });
253
+        $this->registerService(Store::class, function(Server $c) {
254
+            $session = $c->getSession();
255
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
256
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
257
+            } else {
258
+                $tokenProvider = null;
259
+            }
260
+            $logger = $c->getLogger();
261
+            return new Store($session, $logger, $tokenProvider);
262
+        });
263
+        $this->registerAlias(IStore::class, Store::class);
264
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
265
+            $dbConnection = $c->getDatabaseConnection();
266
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
267
+        });
268
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
269
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
270
+            $crypto = $c->getCrypto();
271
+            $config = $c->getConfig();
272
+            $logger = $c->getLogger();
273
+            $timeFactory = new TimeFactory();
274
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
275
+        });
276
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
277
+        $this->registerService('UserSession', function (Server $c) {
278
+            $manager = $c->getUserManager();
279
+            $session = new \OC\Session\Memory('');
280
+            $timeFactory = new TimeFactory();
281
+            // Token providers might require a working database. This code
282
+            // might however be called when ownCloud is not yet setup.
283
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
284
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
285
+            } else {
286
+                $defaultTokenProvider = null;
287
+            }
288
+
289
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
290
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
291
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
292
+            });
293
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
294
+                /** @var $user \OC\User\User */
295
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
296
+            });
297
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
298
+                /** @var $user \OC\User\User */
299
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
300
+            });
301
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
302
+                /** @var $user \OC\User\User */
303
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
304
+            });
305
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
306
+                /** @var $user \OC\User\User */
307
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
308
+            });
309
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
310
+                /** @var $user \OC\User\User */
311
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
312
+            });
313
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
314
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
315
+            });
316
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
317
+                /** @var $user \OC\User\User */
318
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
319
+            });
320
+            $userSession->listen('\OC\User', 'logout', function () {
321
+                \OC_Hook::emit('OC_User', 'logout', array());
322
+            });
323
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
324
+                /** @var $user \OC\User\User */
325
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
326
+            });
327
+            return $userSession;
328
+        });
329
+
330
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
331
+            return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
332
+        });
333
+
334
+        $this->registerService('NavigationManager', function (Server $c) {
335
+            return new \OC\NavigationManager($c->getAppManager(),
336
+                $c->getURLGenerator(),
337
+                $c->getL10NFactory(),
338
+                $c->getUserSession(),
339
+                $c->getGroupManager());
340
+        });
341
+        $this->registerService('AllConfig', function (Server $c) {
342
+            return new \OC\AllConfig(
343
+                $c->getSystemConfig()
344
+            );
345
+        });
346
+        $this->registerService('SystemConfig', function ($c) use ($config) {
347
+            return new \OC\SystemConfig($config);
348
+        });
349
+        $this->registerService('AppConfig', function (Server $c) {
350
+            return new \OC\AppConfig($c->getDatabaseConnection());
351
+        });
352
+        $this->registerService('L10NFactory', function (Server $c) {
353
+            return new \OC\L10N\Factory(
354
+                $c->getConfig(),
355
+                $c->getRequest(),
356
+                $c->getUserSession(),
357
+                \OC::$SERVERROOT
358
+            );
359
+        });
360
+        $this->registerService('URLGenerator', function (Server $c) {
361
+            $config = $c->getConfig();
362
+            $cacheFactory = $c->getMemCacheFactory();
363
+            return new \OC\URLGenerator(
364
+                $config,
365
+                $cacheFactory
366
+            );
367
+        });
368
+        $this->registerService('AppHelper', function ($c) {
369
+            return new \OC\AppHelper();
370
+        });
371
+        $this->registerService('AppFetcher', function ($c) {
372
+            return new AppFetcher(
373
+                $this->getAppDataDir('appstore'),
374
+                $this->getHTTPClientService(),
375
+                $this->query(TimeFactory::class),
376
+                $this->getConfig()
377
+            );
378
+        });
379
+        $this->registerService('CategoryFetcher', function ($c) {
380
+            return new CategoryFetcher(
381
+                $this->getAppDataDir('appstore'),
382
+                $this->getHTTPClientService(),
383
+                $this->query(TimeFactory::class),
384
+                $this->getConfig()
385
+            );
386
+        });
387
+        $this->registerService('UserCache', function ($c) {
388
+            return new Cache\File();
389
+        });
390
+        $this->registerService('MemCacheFactory', function (Server $c) {
391
+            $config = $c->getConfig();
392
+
393
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
394
+                $v = \OC_App::getAppVersions();
395
+                $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
396
+                $version = implode(',', $v);
397
+                $instanceId = \OC_Util::getInstanceId();
398
+                $path = \OC::$SERVERROOT;
399
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
400
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
401
+                    $config->getSystemValue('memcache.local', null),
402
+                    $config->getSystemValue('memcache.distributed', null),
403
+                    $config->getSystemValue('memcache.locking', null)
404
+                );
405
+            }
406
+
407
+            return new \OC\Memcache\Factory('', $c->getLogger(),
408
+                '\\OC\\Memcache\\ArrayCache',
409
+                '\\OC\\Memcache\\ArrayCache',
410
+                '\\OC\\Memcache\\ArrayCache'
411
+            );
412
+        });
413
+        $this->registerService('RedisFactory', function (Server $c) {
414
+            $systemConfig = $c->getSystemConfig();
415
+            return new RedisFactory($systemConfig);
416
+        });
417
+        $this->registerService('ActivityManager', function (Server $c) {
418
+            return new \OC\Activity\Manager(
419
+                $c->getRequest(),
420
+                $c->getUserSession(),
421
+                $c->getConfig(),
422
+                $c->query(IValidator::class)
423
+            );
424
+        });
425
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
426
+            return new \OC\Activity\EventMerger(
427
+                $c->getL10N('lib')
428
+            );
429
+        });
430
+        $this->registerAlias(IValidator::class, Validator::class);
431
+        $this->registerService('AvatarManager', function (Server $c) {
432
+            return new AvatarManager(
433
+                $c->getUserManager(),
434
+                $c->getAppDataDir('avatar'),
435
+                $c->getL10N('lib'),
436
+                $c->getLogger(),
437
+                $c->getConfig()
438
+            );
439
+        });
440
+        $this->registerService('Logger', function (Server $c) {
441
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
442
+            $logger = Log::getLogClass($logType);
443
+            call_user_func(array($logger, 'init'));
444
+
445
+            return new Log($logger);
446
+        });
447
+        $this->registerService('JobList', function (Server $c) {
448
+            $config = $c->getConfig();
449
+            return new \OC\BackgroundJob\JobList(
450
+                $c->getDatabaseConnection(),
451
+                $config,
452
+                new TimeFactory()
453
+            );
454
+        });
455
+        $this->registerService('Router', function (Server $c) {
456
+            $cacheFactory = $c->getMemCacheFactory();
457
+            $logger = $c->getLogger();
458
+            if ($cacheFactory->isAvailable()) {
459
+                $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
460
+            } else {
461
+                $router = new \OC\Route\Router($logger);
462
+            }
463
+            return $router;
464
+        });
465
+        $this->registerService('Search', function ($c) {
466
+            return new Search();
467
+        });
468
+        $this->registerService('SecureRandom', function ($c) {
469
+            return new SecureRandom();
470
+        });
471
+        $this->registerService('Crypto', function (Server $c) {
472
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
473
+        });
474
+        $this->registerService('Hasher', function (Server $c) {
475
+            return new Hasher($c->getConfig());
476
+        });
477
+        $this->registerService('CredentialsManager', function (Server $c) {
478
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
479
+        });
480
+        $this->registerService('DatabaseConnection', function (Server $c) {
481
+            $systemConfig = $c->getSystemConfig();
482
+            $factory = new \OC\DB\ConnectionFactory($c->getConfig());
483
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
484
+            if (!$factory->isValidType($type)) {
485
+                throw new \OC\DatabaseException('Invalid database type');
486
+            }
487
+            $connectionParams = $factory->createConnectionParams($systemConfig);
488
+            $connection = $factory->getConnection($type, $connectionParams);
489
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
490
+            return $connection;
491
+        });
492
+        $this->registerService('HTTPHelper', function (Server $c) {
493
+            $config = $c->getConfig();
494
+            return new HTTPHelper(
495
+                $config,
496
+                $c->getHTTPClientService()
497
+            );
498
+        });
499
+        $this->registerService('HttpClientService', function (Server $c) {
500
+            $user = \OC_User::getUser();
501
+            $uid = $user ? $user : null;
502
+            return new ClientService(
503
+                $c->getConfig(),
504
+                new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
505
+            );
506
+        });
507
+        $this->registerService('EventLogger', function (Server $c) {
508
+            if ($c->getSystemConfig()->getValue('debug', false)) {
509
+                return new EventLogger();
510
+            } else {
511
+                return new NullEventLogger();
512
+            }
513
+        });
514
+        $this->registerService('QueryLogger', function (Server $c) {
515
+            if ($c->getSystemConfig()->getValue('debug', false)) {
516
+                return new QueryLogger();
517
+            } else {
518
+                return new NullQueryLogger();
519
+            }
520
+        });
521
+        $this->registerService('TempManager', function (Server $c) {
522
+            return new TempManager(
523
+                $c->getLogger(),
524
+                $c->getConfig()
525
+            );
526
+        });
527
+        $this->registerService('AppManager', function (Server $c) {
528
+            return new \OC\App\AppManager(
529
+                $c->getUserSession(),
530
+                $c->getAppConfig(),
531
+                $c->getGroupManager(),
532
+                $c->getMemCacheFactory(),
533
+                $c->getEventDispatcher()
534
+            );
535
+        });
536
+        $this->registerService('DateTimeZone', function (Server $c) {
537
+            return new DateTimeZone(
538
+                $c->getConfig(),
539
+                $c->getSession()
540
+            );
541
+        });
542
+        $this->registerService('DateTimeFormatter', function (Server $c) {
543
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
544
+
545
+            return new DateTimeFormatter(
546
+                $c->getDateTimeZone()->getTimeZone(),
547
+                $c->getL10N('lib', $language)
548
+            );
549
+        });
550
+        $this->registerService('UserMountCache', function (Server $c) {
551
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
552
+            $listener = new UserMountCacheListener($mountCache);
553
+            $listener->listen($c->getUserManager());
554
+            return $mountCache;
555
+        });
556
+        $this->registerService('MountConfigManager', function (Server $c) {
557
+            $loader = \OC\Files\Filesystem::getLoader();
558
+            $mountCache = $c->query('UserMountCache');
559
+            $manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
560
+
561
+            // builtin providers
562
+
563
+            $config = $c->getConfig();
564
+            $manager->registerProvider(new CacheMountProvider($config));
565
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
566
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
567
+
568
+            return $manager;
569
+        });
570
+        $this->registerService('IniWrapper', function ($c) {
571
+            return new IniGetWrapper();
572
+        });
573
+        $this->registerService('AsyncCommandBus', function (Server $c) {
574
+            $jobList = $c->getJobList();
575
+            return new AsyncBus($jobList);
576
+        });
577
+        $this->registerService('TrustedDomainHelper', function ($c) {
578
+            return new TrustedDomainHelper($this->getConfig());
579
+        });
580
+        $this->registerService('Throttler', function(Server $c) {
581
+            return new Throttler(
582
+                $c->getDatabaseConnection(),
583
+                new TimeFactory(),
584
+                $c->getLogger(),
585
+                $c->getConfig()
586
+            );
587
+        });
588
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
589
+            // IConfig and IAppManager requires a working database. This code
590
+            // might however be called when ownCloud is not yet setup.
591
+            if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
592
+                $config = $c->getConfig();
593
+                $appManager = $c->getAppManager();
594
+            } else {
595
+                $config = null;
596
+                $appManager = null;
597
+            }
598
+
599
+            return new Checker(
600
+                    new EnvironmentHelper(),
601
+                    new FileAccessHelper(),
602
+                    new AppLocator(),
603
+                    $config,
604
+                    $c->getMemCacheFactory(),
605
+                    $appManager,
606
+                    $c->getTempManager()
607
+            );
608
+        });
609
+        $this->registerService('Request', function ($c) {
610
+            if (isset($this['urlParams'])) {
611
+                $urlParams = $this['urlParams'];
612
+            } else {
613
+                $urlParams = [];
614
+            }
615
+
616
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
617
+                && in_array('fakeinput', stream_get_wrappers())
618
+            ) {
619
+                $stream = 'fakeinput://data';
620
+            } else {
621
+                $stream = 'php://input';
622
+            }
623
+
624
+            return new Request(
625
+                [
626
+                    'get' => $_GET,
627
+                    'post' => $_POST,
628
+                    'files' => $_FILES,
629
+                    'server' => $_SERVER,
630
+                    'env' => $_ENV,
631
+                    'cookies' => $_COOKIE,
632
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
633
+                        ? $_SERVER['REQUEST_METHOD']
634
+                        : null,
635
+                    'urlParams' => $urlParams,
636
+                ],
637
+                $this->getSecureRandom(),
638
+                $this->getConfig(),
639
+                $this->getCsrfTokenManager(),
640
+                $stream
641
+            );
642
+        });
643
+        $this->registerService('Mailer', function (Server $c) {
644
+            return new Mailer(
645
+                $c->getConfig(),
646
+                $c->getLogger(),
647
+                $c->getThemingDefaults()
648
+            );
649
+        });
650
+        $this->registerService('LDAPProvider', function(Server $c) {
651
+            $config = $c->getConfig();
652
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
653
+            if(is_null($factoryClass)) {
654
+                throw new \Exception('ldapProviderFactory not set');
655
+            }
656
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
657
+            $factory = new $factoryClass($this);
658
+            return $factory->getLDAPProvider();
659
+        });
660
+        $this->registerService('LockingProvider', function (Server $c) {
661
+            $ini = $c->getIniWrapper();
662
+            $config = $c->getConfig();
663
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
664
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
665
+                /** @var \OC\Memcache\Factory $memcacheFactory */
666
+                $memcacheFactory = $c->getMemCacheFactory();
667
+                $memcache = $memcacheFactory->createLocking('lock');
668
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
669
+                    return new MemcacheLockingProvider($memcache, $ttl);
670
+                }
671
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
672
+            }
673
+            return new NoopLockingProvider();
674
+        });
675
+        $this->registerService('MountManager', function () {
676
+            return new \OC\Files\Mount\Manager();
677
+        });
678
+        $this->registerService('MimeTypeDetector', function (Server $c) {
679
+            return new \OC\Files\Type\Detection(
680
+                $c->getURLGenerator(),
681
+                \OC::$configDir,
682
+                \OC::$SERVERROOT . '/resources/config/'
683
+            );
684
+        });
685
+        $this->registerService('MimeTypeLoader', function (Server $c) {
686
+            return new \OC\Files\Type\Loader(
687
+                $c->getDatabaseConnection()
688
+            );
689
+        });
690
+        $this->registerService('NotificationManager', function (Server $c) {
691
+            return new Manager(
692
+                $c->query(IValidator::class)
693
+            );
694
+        });
695
+        $this->registerService('CapabilitiesManager', function (Server $c) {
696
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
697
+            $manager->registerCapability(function () use ($c) {
698
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
699
+            });
700
+            return $manager;
701
+        });
702
+        $this->registerService('CommentsManager', function(Server $c) {
703
+            $config = $c->getConfig();
704
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
705
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
706
+            $factory = new $factoryClass($this);
707
+            return $factory->getManager();
708
+        });
709
+        $this->registerService('ThemingDefaults', function(Server $c) {
710
+            /*
711 711
 			 * Dark magic for autoloader.
712 712
 			 * If we do a class_exists it will try to load the class which will
713 713
 			 * make composer cache the result. Resulting in errors when enabling
714 714
 			 * the theming app.
715 715
 			 */
716
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
717
-			if (isset($prefixes['OCA\\Theming\\'])) {
718
-				$classExists = true;
719
-			} else {
720
-				$classExists = false;
721
-			}
722
-
723
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
724
-				return new ThemingDefaults(
725
-					$c->getConfig(),
726
-					$c->getL10N('theming'),
727
-					$c->getURLGenerator(),
728
-					new \OC_Defaults(),
729
-					$c->getLazyRootFolder(),
730
-					$c->getMemCacheFactory()
731
-				);
732
-			}
733
-			return new \OC_Defaults();
734
-		});
735
-		$this->registerService('EventDispatcher', function () {
736
-			return new EventDispatcher();
737
-		});
738
-		$this->registerService('CryptoWrapper', function (Server $c) {
739
-			// FIXME: Instantiiated here due to cyclic dependency
740
-			$request = new Request(
741
-				[
742
-					'get' => $_GET,
743
-					'post' => $_POST,
744
-					'files' => $_FILES,
745
-					'server' => $_SERVER,
746
-					'env' => $_ENV,
747
-					'cookies' => $_COOKIE,
748
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
749
-						? $_SERVER['REQUEST_METHOD']
750
-						: null,
751
-				],
752
-				$c->getSecureRandom(),
753
-				$c->getConfig()
754
-			);
755
-
756
-			return new CryptoWrapper(
757
-				$c->getConfig(),
758
-				$c->getCrypto(),
759
-				$c->getSecureRandom(),
760
-				$request
761
-			);
762
-		});
763
-		$this->registerService('CsrfTokenManager', function (Server $c) {
764
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
765
-
766
-			return new CsrfTokenManager(
767
-				$tokenGenerator,
768
-				$c->query(SessionStorage::class)
769
-			);
770
-		});
771
-		$this->registerService(SessionStorage::class, function (Server $c) {
772
-			return new SessionStorage($c->getSession());
773
-		});
774
-		$this->registerService('ContentSecurityPolicyManager', function (Server $c) {
775
-			return new ContentSecurityPolicyManager();
776
-		});
777
-		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
778
-			return new ContentSecurityPolicyNonceManager(
779
-				$c->getCsrfTokenManager(),
780
-				$c->getRequest()
781
-			);
782
-		});
783
-		$this->registerService('ShareManager', function(Server $c) {
784
-			$config = $c->getConfig();
785
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
786
-			/** @var \OCP\Share\IProviderFactory $factory */
787
-			$factory = new $factoryClass($this);
788
-
789
-			$manager = new \OC\Share20\Manager(
790
-				$c->getLogger(),
791
-				$c->getConfig(),
792
-				$c->getSecureRandom(),
793
-				$c->getHasher(),
794
-				$c->getMountManager(),
795
-				$c->getGroupManager(),
796
-				$c->getL10N('core'),
797
-				$factory,
798
-				$c->getUserManager(),
799
-				$c->getLazyRootFolder(),
800
-				$c->getEventDispatcher()
801
-			);
802
-
803
-			return $manager;
804
-		});
805
-		$this->registerService('SettingsManager', function(Server $c) {
806
-			$manager = new \OC\Settings\Manager(
807
-				$c->getLogger(),
808
-				$c->getDatabaseConnection(),
809
-				$c->getL10N('lib'),
810
-				$c->getConfig(),
811
-				$c->getEncryptionManager(),
812
-				$c->getUserManager(),
813
-				$c->getLockingProvider(),
814
-				$c->getRequest(),
815
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
816
-				$c->getURLGenerator()
817
-			);
818
-			return $manager;
819
-		});
820
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
821
-			return new \OC\Files\AppData\Factory(
822
-				$c->getRootFolder(),
823
-				$c->getSystemConfig()
824
-			);
825
-		});
826
-
827
-		$this->registerService('LockdownManager', function (Server $c) {
828
-			return new LockdownManager();
829
-		});
830
-
831
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
832
-			return new CloudIdManager();
833
-		});
834
-
835
-		/* To trick DI since we don't extend the DIContainer here */
836
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
837
-			return new CleanPreviewsBackgroundJob(
838
-				$c->getRootFolder(),
839
-				$c->getLogger(),
840
-				$c->getJobList(),
841
-				new TimeFactory()
842
-			);
843
-		});
844
-	}
845
-
846
-	/**
847
-	 * @return \OCP\Contacts\IManager
848
-	 */
849
-	public function getContactsManager() {
850
-		return $this->query('ContactsManager');
851
-	}
852
-
853
-	/**
854
-	 * @return \OC\Encryption\Manager
855
-	 */
856
-	public function getEncryptionManager() {
857
-		return $this->query('EncryptionManager');
858
-	}
859
-
860
-	/**
861
-	 * @return \OC\Encryption\File
862
-	 */
863
-	public function getEncryptionFilesHelper() {
864
-		return $this->query('EncryptionFileHelper');
865
-	}
866
-
867
-	/**
868
-	 * @return \OCP\Encryption\Keys\IStorage
869
-	 */
870
-	public function getEncryptionKeyStorage() {
871
-		return $this->query('EncryptionKeyStorage');
872
-	}
873
-
874
-	/**
875
-	 * The current request object holding all information about the request
876
-	 * currently being processed is returned from this method.
877
-	 * In case the current execution was not initiated by a web request null is returned
878
-	 *
879
-	 * @return \OCP\IRequest
880
-	 */
881
-	public function getRequest() {
882
-		return $this->query('Request');
883
-	}
884
-
885
-	/**
886
-	 * Returns the preview manager which can create preview images for a given file
887
-	 *
888
-	 * @return \OCP\IPreview
889
-	 */
890
-	public function getPreviewManager() {
891
-		return $this->query('PreviewManager');
892
-	}
893
-
894
-	/**
895
-	 * Returns the tag manager which can get and set tags for different object types
896
-	 *
897
-	 * @see \OCP\ITagManager::load()
898
-	 * @return \OCP\ITagManager
899
-	 */
900
-	public function getTagManager() {
901
-		return $this->query('TagManager');
902
-	}
903
-
904
-	/**
905
-	 * Returns the system-tag manager
906
-	 *
907
-	 * @return \OCP\SystemTag\ISystemTagManager
908
-	 *
909
-	 * @since 9.0.0
910
-	 */
911
-	public function getSystemTagManager() {
912
-		return $this->query('SystemTagManager');
913
-	}
914
-
915
-	/**
916
-	 * Returns the system-tag object mapper
917
-	 *
918
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
919
-	 *
920
-	 * @since 9.0.0
921
-	 */
922
-	public function getSystemTagObjectMapper() {
923
-		return $this->query('SystemTagObjectMapper');
924
-	}
925
-
926
-	/**
927
-	 * Returns the avatar manager, used for avatar functionality
928
-	 *
929
-	 * @return \OCP\IAvatarManager
930
-	 */
931
-	public function getAvatarManager() {
932
-		return $this->query('AvatarManager');
933
-	}
934
-
935
-	/**
936
-	 * Returns the root folder of ownCloud's data directory
937
-	 *
938
-	 * @return \OCP\Files\IRootFolder
939
-	 */
940
-	public function getRootFolder() {
941
-		return $this->query('LazyRootFolder');
942
-	}
943
-
944
-	/**
945
-	 * Returns the root folder of ownCloud's data directory
946
-	 * This is the lazy variant so this gets only initialized once it
947
-	 * is actually used.
948
-	 *
949
-	 * @return \OCP\Files\IRootFolder
950
-	 */
951
-	public function getLazyRootFolder() {
952
-		return $this->query('LazyRootFolder');
953
-	}
954
-
955
-	/**
956
-	 * Returns a view to ownCloud's files folder
957
-	 *
958
-	 * @param string $userId user ID
959
-	 * @return \OCP\Files\Folder|null
960
-	 */
961
-	public function getUserFolder($userId = null) {
962
-		if ($userId === null) {
963
-			$user = $this->getUserSession()->getUser();
964
-			if (!$user) {
965
-				return null;
966
-			}
967
-			$userId = $user->getUID();
968
-		}
969
-		$root = $this->getRootFolder();
970
-		return $root->getUserFolder($userId);
971
-	}
972
-
973
-	/**
974
-	 * Returns an app-specific view in ownClouds data directory
975
-	 *
976
-	 * @return \OCP\Files\Folder
977
-	 * @deprecated since 9.2.0 use IAppData
978
-	 */
979
-	public function getAppFolder() {
980
-		$dir = '/' . \OC_App::getCurrentApp();
981
-		$root = $this->getRootFolder();
982
-		if (!$root->nodeExists($dir)) {
983
-			$folder = $root->newFolder($dir);
984
-		} else {
985
-			$folder = $root->get($dir);
986
-		}
987
-		return $folder;
988
-	}
989
-
990
-	/**
991
-	 * @return \OC\User\Manager
992
-	 */
993
-	public function getUserManager() {
994
-		return $this->query('UserManager');
995
-	}
996
-
997
-	/**
998
-	 * @return \OC\Group\Manager
999
-	 */
1000
-	public function getGroupManager() {
1001
-		return $this->query('GroupManager');
1002
-	}
1003
-
1004
-	/**
1005
-	 * @return \OC\User\Session
1006
-	 */
1007
-	public function getUserSession() {
1008
-		return $this->query('UserSession');
1009
-	}
1010
-
1011
-	/**
1012
-	 * @return \OCP\ISession
1013
-	 */
1014
-	public function getSession() {
1015
-		return $this->query('UserSession')->getSession();
1016
-	}
1017
-
1018
-	/**
1019
-	 * @param \OCP\ISession $session
1020
-	 */
1021
-	public function setSession(\OCP\ISession $session) {
1022
-		$this->query(SessionStorage::class)->setSession($session);
1023
-		$this->query('UserSession')->setSession($session);
1024
-		$this->query(Store::class)->setSession($session);
1025
-	}
1026
-
1027
-	/**
1028
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1029
-	 */
1030
-	public function getTwoFactorAuthManager() {
1031
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1032
-	}
1033
-
1034
-	/**
1035
-	 * @return \OC\NavigationManager
1036
-	 */
1037
-	public function getNavigationManager() {
1038
-		return $this->query('NavigationManager');
1039
-	}
1040
-
1041
-	/**
1042
-	 * @return \OCP\IConfig
1043
-	 */
1044
-	public function getConfig() {
1045
-		return $this->query('AllConfig');
1046
-	}
1047
-
1048
-	/**
1049
-	 * @internal For internal use only
1050
-	 * @return \OC\SystemConfig
1051
-	 */
1052
-	public function getSystemConfig() {
1053
-		return $this->query('SystemConfig');
1054
-	}
1055
-
1056
-	/**
1057
-	 * Returns the app config manager
1058
-	 *
1059
-	 * @return \OCP\IAppConfig
1060
-	 */
1061
-	public function getAppConfig() {
1062
-		return $this->query('AppConfig');
1063
-	}
1064
-
1065
-	/**
1066
-	 * @return \OCP\L10N\IFactory
1067
-	 */
1068
-	public function getL10NFactory() {
1069
-		return $this->query('L10NFactory');
1070
-	}
1071
-
1072
-	/**
1073
-	 * get an L10N instance
1074
-	 *
1075
-	 * @param string $app appid
1076
-	 * @param string $lang
1077
-	 * @return IL10N
1078
-	 */
1079
-	public function getL10N($app, $lang = null) {
1080
-		return $this->getL10NFactory()->get($app, $lang);
1081
-	}
1082
-
1083
-	/**
1084
-	 * @return \OCP\IURLGenerator
1085
-	 */
1086
-	public function getURLGenerator() {
1087
-		return $this->query('URLGenerator');
1088
-	}
1089
-
1090
-	/**
1091
-	 * @return \OCP\IHelper
1092
-	 */
1093
-	public function getHelper() {
1094
-		return $this->query('AppHelper');
1095
-	}
1096
-
1097
-	/**
1098
-	 * @return AppFetcher
1099
-	 */
1100
-	public function getAppFetcher() {
1101
-		return $this->query('AppFetcher');
1102
-	}
1103
-
1104
-	/**
1105
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1106
-	 * getMemCacheFactory() instead.
1107
-	 *
1108
-	 * @return \OCP\ICache
1109
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1110
-	 */
1111
-	public function getCache() {
1112
-		return $this->query('UserCache');
1113
-	}
1114
-
1115
-	/**
1116
-	 * Returns an \OCP\CacheFactory instance
1117
-	 *
1118
-	 * @return \OCP\ICacheFactory
1119
-	 */
1120
-	public function getMemCacheFactory() {
1121
-		return $this->query('MemCacheFactory');
1122
-	}
1123
-
1124
-	/**
1125
-	 * Returns an \OC\RedisFactory instance
1126
-	 *
1127
-	 * @return \OC\RedisFactory
1128
-	 */
1129
-	public function getGetRedisFactory() {
1130
-		return $this->query('RedisFactory');
1131
-	}
1132
-
1133
-
1134
-	/**
1135
-	 * Returns the current session
1136
-	 *
1137
-	 * @return \OCP\IDBConnection
1138
-	 */
1139
-	public function getDatabaseConnection() {
1140
-		return $this->query('DatabaseConnection');
1141
-	}
1142
-
1143
-	/**
1144
-	 * Returns the activity manager
1145
-	 *
1146
-	 * @return \OCP\Activity\IManager
1147
-	 */
1148
-	public function getActivityManager() {
1149
-		return $this->query('ActivityManager');
1150
-	}
1151
-
1152
-	/**
1153
-	 * Returns an job list for controlling background jobs
1154
-	 *
1155
-	 * @return \OCP\BackgroundJob\IJobList
1156
-	 */
1157
-	public function getJobList() {
1158
-		return $this->query('JobList');
1159
-	}
1160
-
1161
-	/**
1162
-	 * Returns a logger instance
1163
-	 *
1164
-	 * @return \OCP\ILogger
1165
-	 */
1166
-	public function getLogger() {
1167
-		return $this->query('Logger');
1168
-	}
1169
-
1170
-	/**
1171
-	 * Returns a router for generating and matching urls
1172
-	 *
1173
-	 * @return \OCP\Route\IRouter
1174
-	 */
1175
-	public function getRouter() {
1176
-		return $this->query('Router');
1177
-	}
1178
-
1179
-	/**
1180
-	 * Returns a search instance
1181
-	 *
1182
-	 * @return \OCP\ISearch
1183
-	 */
1184
-	public function getSearch() {
1185
-		return $this->query('Search');
1186
-	}
1187
-
1188
-	/**
1189
-	 * Returns a SecureRandom instance
1190
-	 *
1191
-	 * @return \OCP\Security\ISecureRandom
1192
-	 */
1193
-	public function getSecureRandom() {
1194
-		return $this->query('SecureRandom');
1195
-	}
1196
-
1197
-	/**
1198
-	 * Returns a Crypto instance
1199
-	 *
1200
-	 * @return \OCP\Security\ICrypto
1201
-	 */
1202
-	public function getCrypto() {
1203
-		return $this->query('Crypto');
1204
-	}
1205
-
1206
-	/**
1207
-	 * Returns a Hasher instance
1208
-	 *
1209
-	 * @return \OCP\Security\IHasher
1210
-	 */
1211
-	public function getHasher() {
1212
-		return $this->query('Hasher');
1213
-	}
1214
-
1215
-	/**
1216
-	 * Returns a CredentialsManager instance
1217
-	 *
1218
-	 * @return \OCP\Security\ICredentialsManager
1219
-	 */
1220
-	public function getCredentialsManager() {
1221
-		return $this->query('CredentialsManager');
1222
-	}
1223
-
1224
-	/**
1225
-	 * Returns an instance of the HTTP helper class
1226
-	 *
1227
-	 * @deprecated Use getHTTPClientService()
1228
-	 * @return \OC\HTTPHelper
1229
-	 */
1230
-	public function getHTTPHelper() {
1231
-		return $this->query('HTTPHelper');
1232
-	}
1233
-
1234
-	/**
1235
-	 * Get the certificate manager for the user
1236
-	 *
1237
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1238
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1239
-	 */
1240
-	public function getCertificateManager($userId = '') {
1241
-		if ($userId === '') {
1242
-			$userSession = $this->getUserSession();
1243
-			$user = $userSession->getUser();
1244
-			if (is_null($user)) {
1245
-				return null;
1246
-			}
1247
-			$userId = $user->getUID();
1248
-		}
1249
-		return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1250
-	}
1251
-
1252
-	/**
1253
-	 * Returns an instance of the HTTP client service
1254
-	 *
1255
-	 * @return \OCP\Http\Client\IClientService
1256
-	 */
1257
-	public function getHTTPClientService() {
1258
-		return $this->query('HttpClientService');
1259
-	}
1260
-
1261
-	/**
1262
-	 * Create a new event source
1263
-	 *
1264
-	 * @return \OCP\IEventSource
1265
-	 */
1266
-	public function createEventSource() {
1267
-		return new \OC_EventSource();
1268
-	}
1269
-
1270
-	/**
1271
-	 * Get the active event logger
1272
-	 *
1273
-	 * The returned logger only logs data when debug mode is enabled
1274
-	 *
1275
-	 * @return \OCP\Diagnostics\IEventLogger
1276
-	 */
1277
-	public function getEventLogger() {
1278
-		return $this->query('EventLogger');
1279
-	}
1280
-
1281
-	/**
1282
-	 * Get the active query logger
1283
-	 *
1284
-	 * The returned logger only logs data when debug mode is enabled
1285
-	 *
1286
-	 * @return \OCP\Diagnostics\IQueryLogger
1287
-	 */
1288
-	public function getQueryLogger() {
1289
-		return $this->query('QueryLogger');
1290
-	}
1291
-
1292
-	/**
1293
-	 * Get the manager for temporary files and folders
1294
-	 *
1295
-	 * @return \OCP\ITempManager
1296
-	 */
1297
-	public function getTempManager() {
1298
-		return $this->query('TempManager');
1299
-	}
1300
-
1301
-	/**
1302
-	 * Get the app manager
1303
-	 *
1304
-	 * @return \OCP\App\IAppManager
1305
-	 */
1306
-	public function getAppManager() {
1307
-		return $this->query('AppManager');
1308
-	}
1309
-
1310
-	/**
1311
-	 * Creates a new mailer
1312
-	 *
1313
-	 * @return \OCP\Mail\IMailer
1314
-	 */
1315
-	public function getMailer() {
1316
-		return $this->query('Mailer');
1317
-	}
1318
-
1319
-	/**
1320
-	 * Get the webroot
1321
-	 *
1322
-	 * @return string
1323
-	 */
1324
-	public function getWebRoot() {
1325
-		return $this->webRoot;
1326
-	}
1327
-
1328
-	/**
1329
-	 * @return \OC\OCSClient
1330
-	 */
1331
-	public function getOcsClient() {
1332
-		return $this->query('OcsClient');
1333
-	}
1334
-
1335
-	/**
1336
-	 * @return \OCP\IDateTimeZone
1337
-	 */
1338
-	public function getDateTimeZone() {
1339
-		return $this->query('DateTimeZone');
1340
-	}
1341
-
1342
-	/**
1343
-	 * @return \OCP\IDateTimeFormatter
1344
-	 */
1345
-	public function getDateTimeFormatter() {
1346
-		return $this->query('DateTimeFormatter');
1347
-	}
1348
-
1349
-	/**
1350
-	 * @return \OCP\Files\Config\IMountProviderCollection
1351
-	 */
1352
-	public function getMountProviderCollection() {
1353
-		return $this->query('MountConfigManager');
1354
-	}
1355
-
1356
-	/**
1357
-	 * Get the IniWrapper
1358
-	 *
1359
-	 * @return IniGetWrapper
1360
-	 */
1361
-	public function getIniWrapper() {
1362
-		return $this->query('IniWrapper');
1363
-	}
1364
-
1365
-	/**
1366
-	 * @return \OCP\Command\IBus
1367
-	 */
1368
-	public function getCommandBus() {
1369
-		return $this->query('AsyncCommandBus');
1370
-	}
1371
-
1372
-	/**
1373
-	 * Get the trusted domain helper
1374
-	 *
1375
-	 * @return TrustedDomainHelper
1376
-	 */
1377
-	public function getTrustedDomainHelper() {
1378
-		return $this->query('TrustedDomainHelper');
1379
-	}
1380
-
1381
-	/**
1382
-	 * Get the locking provider
1383
-	 *
1384
-	 * @return \OCP\Lock\ILockingProvider
1385
-	 * @since 8.1.0
1386
-	 */
1387
-	public function getLockingProvider() {
1388
-		return $this->query('LockingProvider');
1389
-	}
1390
-
1391
-	/**
1392
-	 * @return \OCP\Files\Mount\IMountManager
1393
-	 **/
1394
-	function getMountManager() {
1395
-		return $this->query('MountManager');
1396
-	}
1397
-
1398
-	/** @return \OCP\Files\Config\IUserMountCache */
1399
-	function getUserMountCache() {
1400
-		return $this->query('UserMountCache');
1401
-	}
1402
-
1403
-	/**
1404
-	 * Get the MimeTypeDetector
1405
-	 *
1406
-	 * @return \OCP\Files\IMimeTypeDetector
1407
-	 */
1408
-	public function getMimeTypeDetector() {
1409
-		return $this->query('MimeTypeDetector');
1410
-	}
1411
-
1412
-	/**
1413
-	 * Get the MimeTypeLoader
1414
-	 *
1415
-	 * @return \OCP\Files\IMimeTypeLoader
1416
-	 */
1417
-	public function getMimeTypeLoader() {
1418
-		return $this->query('MimeTypeLoader');
1419
-	}
1420
-
1421
-	/**
1422
-	 * Get the manager of all the capabilities
1423
-	 *
1424
-	 * @return \OC\CapabilitiesManager
1425
-	 */
1426
-	public function getCapabilitiesManager() {
1427
-		return $this->query('CapabilitiesManager');
1428
-	}
1429
-
1430
-	/**
1431
-	 * Get the EventDispatcher
1432
-	 *
1433
-	 * @return EventDispatcherInterface
1434
-	 * @since 8.2.0
1435
-	 */
1436
-	public function getEventDispatcher() {
1437
-		return $this->query('EventDispatcher');
1438
-	}
1439
-
1440
-	/**
1441
-	 * Get the Notification Manager
1442
-	 *
1443
-	 * @return \OCP\Notification\IManager
1444
-	 * @since 8.2.0
1445
-	 */
1446
-	public function getNotificationManager() {
1447
-		return $this->query('NotificationManager');
1448
-	}
1449
-
1450
-	/**
1451
-	 * @return \OCP\Comments\ICommentsManager
1452
-	 */
1453
-	public function getCommentsManager() {
1454
-		return $this->query('CommentsManager');
1455
-	}
1456
-
1457
-	/**
1458
-	 * @return \OC_Defaults
1459
-	 */
1460
-	public function getThemingDefaults() {
1461
-		return $this->query('ThemingDefaults');
1462
-	}
1463
-
1464
-	/**
1465
-	 * @return \OC\IntegrityCheck\Checker
1466
-	 */
1467
-	public function getIntegrityCodeChecker() {
1468
-		return $this->query('IntegrityCodeChecker');
1469
-	}
1470
-
1471
-	/**
1472
-	 * @return \OC\Session\CryptoWrapper
1473
-	 */
1474
-	public function getSessionCryptoWrapper() {
1475
-		return $this->query('CryptoWrapper');
1476
-	}
1477
-
1478
-	/**
1479
-	 * @return CsrfTokenManager
1480
-	 */
1481
-	public function getCsrfTokenManager() {
1482
-		return $this->query('CsrfTokenManager');
1483
-	}
1484
-
1485
-	/**
1486
-	 * @return Throttler
1487
-	 */
1488
-	public function getBruteForceThrottler() {
1489
-		return $this->query('Throttler');
1490
-	}
1491
-
1492
-	/**
1493
-	 * @return IContentSecurityPolicyManager
1494
-	 */
1495
-	public function getContentSecurityPolicyManager() {
1496
-		return $this->query('ContentSecurityPolicyManager');
1497
-	}
1498
-
1499
-	/**
1500
-	 * @return ContentSecurityPolicyNonceManager
1501
-	 */
1502
-	public function getContentSecurityPolicyNonceManager() {
1503
-		return $this->query('ContentSecurityPolicyNonceManager');
1504
-	}
1505
-
1506
-	/**
1507
-	 * Not a public API as of 8.2, wait for 9.0
1508
-	 *
1509
-	 * @return \OCA\Files_External\Service\BackendService
1510
-	 */
1511
-	public function getStoragesBackendService() {
1512
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1513
-	}
1514
-
1515
-	/**
1516
-	 * Not a public API as of 8.2, wait for 9.0
1517
-	 *
1518
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1519
-	 */
1520
-	public function getGlobalStoragesService() {
1521
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1522
-	}
1523
-
1524
-	/**
1525
-	 * Not a public API as of 8.2, wait for 9.0
1526
-	 *
1527
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1528
-	 */
1529
-	public function getUserGlobalStoragesService() {
1530
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1531
-	}
1532
-
1533
-	/**
1534
-	 * Not a public API as of 8.2, wait for 9.0
1535
-	 *
1536
-	 * @return \OCA\Files_External\Service\UserStoragesService
1537
-	 */
1538
-	public function getUserStoragesService() {
1539
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1540
-	}
1541
-
1542
-	/**
1543
-	 * @return \OCP\Share\IManager
1544
-	 */
1545
-	public function getShareManager() {
1546
-		return $this->query('ShareManager');
1547
-	}
1548
-
1549
-	/**
1550
-	 * Returns the LDAP Provider
1551
-	 *
1552
-	 * @return \OCP\LDAP\ILDAPProvider
1553
-	 */
1554
-	public function getLDAPProvider() {
1555
-		return $this->query('LDAPProvider');
1556
-	}
1557
-
1558
-	/**
1559
-	 * @return \OCP\Settings\IManager
1560
-	 */
1561
-	public function getSettingsManager() {
1562
-		return $this->query('SettingsManager');
1563
-	}
1564
-
1565
-	/**
1566
-	 * @return \OCP\Files\IAppData
1567
-	 */
1568
-	public function getAppDataDir($app) {
1569
-		/** @var \OC\Files\AppData\Factory $factory */
1570
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1571
-		return $factory->get($app);
1572
-	}
1573
-
1574
-	/**
1575
-	 * @return \OCP\Lockdown\ILockdownManager
1576
-	 */
1577
-	public function getLockdownManager() {
1578
-		return $this->query('LockdownManager');
1579
-	}
1580
-
1581
-	/**
1582
-	 * @return \OCP\Federation\ICloudIdManager
1583
-	 */
1584
-	public function getCloudIdManager() {
1585
-		return $this->query(ICloudIdManager::class);
1586
-	}
716
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
717
+            if (isset($prefixes['OCA\\Theming\\'])) {
718
+                $classExists = true;
719
+            } else {
720
+                $classExists = false;
721
+            }
722
+
723
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
724
+                return new ThemingDefaults(
725
+                    $c->getConfig(),
726
+                    $c->getL10N('theming'),
727
+                    $c->getURLGenerator(),
728
+                    new \OC_Defaults(),
729
+                    $c->getLazyRootFolder(),
730
+                    $c->getMemCacheFactory()
731
+                );
732
+            }
733
+            return new \OC_Defaults();
734
+        });
735
+        $this->registerService('EventDispatcher', function () {
736
+            return new EventDispatcher();
737
+        });
738
+        $this->registerService('CryptoWrapper', function (Server $c) {
739
+            // FIXME: Instantiiated here due to cyclic dependency
740
+            $request = new Request(
741
+                [
742
+                    'get' => $_GET,
743
+                    'post' => $_POST,
744
+                    'files' => $_FILES,
745
+                    'server' => $_SERVER,
746
+                    'env' => $_ENV,
747
+                    'cookies' => $_COOKIE,
748
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
749
+                        ? $_SERVER['REQUEST_METHOD']
750
+                        : null,
751
+                ],
752
+                $c->getSecureRandom(),
753
+                $c->getConfig()
754
+            );
755
+
756
+            return new CryptoWrapper(
757
+                $c->getConfig(),
758
+                $c->getCrypto(),
759
+                $c->getSecureRandom(),
760
+                $request
761
+            );
762
+        });
763
+        $this->registerService('CsrfTokenManager', function (Server $c) {
764
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
765
+
766
+            return new CsrfTokenManager(
767
+                $tokenGenerator,
768
+                $c->query(SessionStorage::class)
769
+            );
770
+        });
771
+        $this->registerService(SessionStorage::class, function (Server $c) {
772
+            return new SessionStorage($c->getSession());
773
+        });
774
+        $this->registerService('ContentSecurityPolicyManager', function (Server $c) {
775
+            return new ContentSecurityPolicyManager();
776
+        });
777
+        $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
778
+            return new ContentSecurityPolicyNonceManager(
779
+                $c->getCsrfTokenManager(),
780
+                $c->getRequest()
781
+            );
782
+        });
783
+        $this->registerService('ShareManager', function(Server $c) {
784
+            $config = $c->getConfig();
785
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
786
+            /** @var \OCP\Share\IProviderFactory $factory */
787
+            $factory = new $factoryClass($this);
788
+
789
+            $manager = new \OC\Share20\Manager(
790
+                $c->getLogger(),
791
+                $c->getConfig(),
792
+                $c->getSecureRandom(),
793
+                $c->getHasher(),
794
+                $c->getMountManager(),
795
+                $c->getGroupManager(),
796
+                $c->getL10N('core'),
797
+                $factory,
798
+                $c->getUserManager(),
799
+                $c->getLazyRootFolder(),
800
+                $c->getEventDispatcher()
801
+            );
802
+
803
+            return $manager;
804
+        });
805
+        $this->registerService('SettingsManager', function(Server $c) {
806
+            $manager = new \OC\Settings\Manager(
807
+                $c->getLogger(),
808
+                $c->getDatabaseConnection(),
809
+                $c->getL10N('lib'),
810
+                $c->getConfig(),
811
+                $c->getEncryptionManager(),
812
+                $c->getUserManager(),
813
+                $c->getLockingProvider(),
814
+                $c->getRequest(),
815
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
816
+                $c->getURLGenerator()
817
+            );
818
+            return $manager;
819
+        });
820
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
821
+            return new \OC\Files\AppData\Factory(
822
+                $c->getRootFolder(),
823
+                $c->getSystemConfig()
824
+            );
825
+        });
826
+
827
+        $this->registerService('LockdownManager', function (Server $c) {
828
+            return new LockdownManager();
829
+        });
830
+
831
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
832
+            return new CloudIdManager();
833
+        });
834
+
835
+        /* To trick DI since we don't extend the DIContainer here */
836
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
837
+            return new CleanPreviewsBackgroundJob(
838
+                $c->getRootFolder(),
839
+                $c->getLogger(),
840
+                $c->getJobList(),
841
+                new TimeFactory()
842
+            );
843
+        });
844
+    }
845
+
846
+    /**
847
+     * @return \OCP\Contacts\IManager
848
+     */
849
+    public function getContactsManager() {
850
+        return $this->query('ContactsManager');
851
+    }
852
+
853
+    /**
854
+     * @return \OC\Encryption\Manager
855
+     */
856
+    public function getEncryptionManager() {
857
+        return $this->query('EncryptionManager');
858
+    }
859
+
860
+    /**
861
+     * @return \OC\Encryption\File
862
+     */
863
+    public function getEncryptionFilesHelper() {
864
+        return $this->query('EncryptionFileHelper');
865
+    }
866
+
867
+    /**
868
+     * @return \OCP\Encryption\Keys\IStorage
869
+     */
870
+    public function getEncryptionKeyStorage() {
871
+        return $this->query('EncryptionKeyStorage');
872
+    }
873
+
874
+    /**
875
+     * The current request object holding all information about the request
876
+     * currently being processed is returned from this method.
877
+     * In case the current execution was not initiated by a web request null is returned
878
+     *
879
+     * @return \OCP\IRequest
880
+     */
881
+    public function getRequest() {
882
+        return $this->query('Request');
883
+    }
884
+
885
+    /**
886
+     * Returns the preview manager which can create preview images for a given file
887
+     *
888
+     * @return \OCP\IPreview
889
+     */
890
+    public function getPreviewManager() {
891
+        return $this->query('PreviewManager');
892
+    }
893
+
894
+    /**
895
+     * Returns the tag manager which can get and set tags for different object types
896
+     *
897
+     * @see \OCP\ITagManager::load()
898
+     * @return \OCP\ITagManager
899
+     */
900
+    public function getTagManager() {
901
+        return $this->query('TagManager');
902
+    }
903
+
904
+    /**
905
+     * Returns the system-tag manager
906
+     *
907
+     * @return \OCP\SystemTag\ISystemTagManager
908
+     *
909
+     * @since 9.0.0
910
+     */
911
+    public function getSystemTagManager() {
912
+        return $this->query('SystemTagManager');
913
+    }
914
+
915
+    /**
916
+     * Returns the system-tag object mapper
917
+     *
918
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
919
+     *
920
+     * @since 9.0.0
921
+     */
922
+    public function getSystemTagObjectMapper() {
923
+        return $this->query('SystemTagObjectMapper');
924
+    }
925
+
926
+    /**
927
+     * Returns the avatar manager, used for avatar functionality
928
+     *
929
+     * @return \OCP\IAvatarManager
930
+     */
931
+    public function getAvatarManager() {
932
+        return $this->query('AvatarManager');
933
+    }
934
+
935
+    /**
936
+     * Returns the root folder of ownCloud's data directory
937
+     *
938
+     * @return \OCP\Files\IRootFolder
939
+     */
940
+    public function getRootFolder() {
941
+        return $this->query('LazyRootFolder');
942
+    }
943
+
944
+    /**
945
+     * Returns the root folder of ownCloud's data directory
946
+     * This is the lazy variant so this gets only initialized once it
947
+     * is actually used.
948
+     *
949
+     * @return \OCP\Files\IRootFolder
950
+     */
951
+    public function getLazyRootFolder() {
952
+        return $this->query('LazyRootFolder');
953
+    }
954
+
955
+    /**
956
+     * Returns a view to ownCloud's files folder
957
+     *
958
+     * @param string $userId user ID
959
+     * @return \OCP\Files\Folder|null
960
+     */
961
+    public function getUserFolder($userId = null) {
962
+        if ($userId === null) {
963
+            $user = $this->getUserSession()->getUser();
964
+            if (!$user) {
965
+                return null;
966
+            }
967
+            $userId = $user->getUID();
968
+        }
969
+        $root = $this->getRootFolder();
970
+        return $root->getUserFolder($userId);
971
+    }
972
+
973
+    /**
974
+     * Returns an app-specific view in ownClouds data directory
975
+     *
976
+     * @return \OCP\Files\Folder
977
+     * @deprecated since 9.2.0 use IAppData
978
+     */
979
+    public function getAppFolder() {
980
+        $dir = '/' . \OC_App::getCurrentApp();
981
+        $root = $this->getRootFolder();
982
+        if (!$root->nodeExists($dir)) {
983
+            $folder = $root->newFolder($dir);
984
+        } else {
985
+            $folder = $root->get($dir);
986
+        }
987
+        return $folder;
988
+    }
989
+
990
+    /**
991
+     * @return \OC\User\Manager
992
+     */
993
+    public function getUserManager() {
994
+        return $this->query('UserManager');
995
+    }
996
+
997
+    /**
998
+     * @return \OC\Group\Manager
999
+     */
1000
+    public function getGroupManager() {
1001
+        return $this->query('GroupManager');
1002
+    }
1003
+
1004
+    /**
1005
+     * @return \OC\User\Session
1006
+     */
1007
+    public function getUserSession() {
1008
+        return $this->query('UserSession');
1009
+    }
1010
+
1011
+    /**
1012
+     * @return \OCP\ISession
1013
+     */
1014
+    public function getSession() {
1015
+        return $this->query('UserSession')->getSession();
1016
+    }
1017
+
1018
+    /**
1019
+     * @param \OCP\ISession $session
1020
+     */
1021
+    public function setSession(\OCP\ISession $session) {
1022
+        $this->query(SessionStorage::class)->setSession($session);
1023
+        $this->query('UserSession')->setSession($session);
1024
+        $this->query(Store::class)->setSession($session);
1025
+    }
1026
+
1027
+    /**
1028
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1029
+     */
1030
+    public function getTwoFactorAuthManager() {
1031
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1032
+    }
1033
+
1034
+    /**
1035
+     * @return \OC\NavigationManager
1036
+     */
1037
+    public function getNavigationManager() {
1038
+        return $this->query('NavigationManager');
1039
+    }
1040
+
1041
+    /**
1042
+     * @return \OCP\IConfig
1043
+     */
1044
+    public function getConfig() {
1045
+        return $this->query('AllConfig');
1046
+    }
1047
+
1048
+    /**
1049
+     * @internal For internal use only
1050
+     * @return \OC\SystemConfig
1051
+     */
1052
+    public function getSystemConfig() {
1053
+        return $this->query('SystemConfig');
1054
+    }
1055
+
1056
+    /**
1057
+     * Returns the app config manager
1058
+     *
1059
+     * @return \OCP\IAppConfig
1060
+     */
1061
+    public function getAppConfig() {
1062
+        return $this->query('AppConfig');
1063
+    }
1064
+
1065
+    /**
1066
+     * @return \OCP\L10N\IFactory
1067
+     */
1068
+    public function getL10NFactory() {
1069
+        return $this->query('L10NFactory');
1070
+    }
1071
+
1072
+    /**
1073
+     * get an L10N instance
1074
+     *
1075
+     * @param string $app appid
1076
+     * @param string $lang
1077
+     * @return IL10N
1078
+     */
1079
+    public function getL10N($app, $lang = null) {
1080
+        return $this->getL10NFactory()->get($app, $lang);
1081
+    }
1082
+
1083
+    /**
1084
+     * @return \OCP\IURLGenerator
1085
+     */
1086
+    public function getURLGenerator() {
1087
+        return $this->query('URLGenerator');
1088
+    }
1089
+
1090
+    /**
1091
+     * @return \OCP\IHelper
1092
+     */
1093
+    public function getHelper() {
1094
+        return $this->query('AppHelper');
1095
+    }
1096
+
1097
+    /**
1098
+     * @return AppFetcher
1099
+     */
1100
+    public function getAppFetcher() {
1101
+        return $this->query('AppFetcher');
1102
+    }
1103
+
1104
+    /**
1105
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1106
+     * getMemCacheFactory() instead.
1107
+     *
1108
+     * @return \OCP\ICache
1109
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1110
+     */
1111
+    public function getCache() {
1112
+        return $this->query('UserCache');
1113
+    }
1114
+
1115
+    /**
1116
+     * Returns an \OCP\CacheFactory instance
1117
+     *
1118
+     * @return \OCP\ICacheFactory
1119
+     */
1120
+    public function getMemCacheFactory() {
1121
+        return $this->query('MemCacheFactory');
1122
+    }
1123
+
1124
+    /**
1125
+     * Returns an \OC\RedisFactory instance
1126
+     *
1127
+     * @return \OC\RedisFactory
1128
+     */
1129
+    public function getGetRedisFactory() {
1130
+        return $this->query('RedisFactory');
1131
+    }
1132
+
1133
+
1134
+    /**
1135
+     * Returns the current session
1136
+     *
1137
+     * @return \OCP\IDBConnection
1138
+     */
1139
+    public function getDatabaseConnection() {
1140
+        return $this->query('DatabaseConnection');
1141
+    }
1142
+
1143
+    /**
1144
+     * Returns the activity manager
1145
+     *
1146
+     * @return \OCP\Activity\IManager
1147
+     */
1148
+    public function getActivityManager() {
1149
+        return $this->query('ActivityManager');
1150
+    }
1151
+
1152
+    /**
1153
+     * Returns an job list for controlling background jobs
1154
+     *
1155
+     * @return \OCP\BackgroundJob\IJobList
1156
+     */
1157
+    public function getJobList() {
1158
+        return $this->query('JobList');
1159
+    }
1160
+
1161
+    /**
1162
+     * Returns a logger instance
1163
+     *
1164
+     * @return \OCP\ILogger
1165
+     */
1166
+    public function getLogger() {
1167
+        return $this->query('Logger');
1168
+    }
1169
+
1170
+    /**
1171
+     * Returns a router for generating and matching urls
1172
+     *
1173
+     * @return \OCP\Route\IRouter
1174
+     */
1175
+    public function getRouter() {
1176
+        return $this->query('Router');
1177
+    }
1178
+
1179
+    /**
1180
+     * Returns a search instance
1181
+     *
1182
+     * @return \OCP\ISearch
1183
+     */
1184
+    public function getSearch() {
1185
+        return $this->query('Search');
1186
+    }
1187
+
1188
+    /**
1189
+     * Returns a SecureRandom instance
1190
+     *
1191
+     * @return \OCP\Security\ISecureRandom
1192
+     */
1193
+    public function getSecureRandom() {
1194
+        return $this->query('SecureRandom');
1195
+    }
1196
+
1197
+    /**
1198
+     * Returns a Crypto instance
1199
+     *
1200
+     * @return \OCP\Security\ICrypto
1201
+     */
1202
+    public function getCrypto() {
1203
+        return $this->query('Crypto');
1204
+    }
1205
+
1206
+    /**
1207
+     * Returns a Hasher instance
1208
+     *
1209
+     * @return \OCP\Security\IHasher
1210
+     */
1211
+    public function getHasher() {
1212
+        return $this->query('Hasher');
1213
+    }
1214
+
1215
+    /**
1216
+     * Returns a CredentialsManager instance
1217
+     *
1218
+     * @return \OCP\Security\ICredentialsManager
1219
+     */
1220
+    public function getCredentialsManager() {
1221
+        return $this->query('CredentialsManager');
1222
+    }
1223
+
1224
+    /**
1225
+     * Returns an instance of the HTTP helper class
1226
+     *
1227
+     * @deprecated Use getHTTPClientService()
1228
+     * @return \OC\HTTPHelper
1229
+     */
1230
+    public function getHTTPHelper() {
1231
+        return $this->query('HTTPHelper');
1232
+    }
1233
+
1234
+    /**
1235
+     * Get the certificate manager for the user
1236
+     *
1237
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1238
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1239
+     */
1240
+    public function getCertificateManager($userId = '') {
1241
+        if ($userId === '') {
1242
+            $userSession = $this->getUserSession();
1243
+            $user = $userSession->getUser();
1244
+            if (is_null($user)) {
1245
+                return null;
1246
+            }
1247
+            $userId = $user->getUID();
1248
+        }
1249
+        return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1250
+    }
1251
+
1252
+    /**
1253
+     * Returns an instance of the HTTP client service
1254
+     *
1255
+     * @return \OCP\Http\Client\IClientService
1256
+     */
1257
+    public function getHTTPClientService() {
1258
+        return $this->query('HttpClientService');
1259
+    }
1260
+
1261
+    /**
1262
+     * Create a new event source
1263
+     *
1264
+     * @return \OCP\IEventSource
1265
+     */
1266
+    public function createEventSource() {
1267
+        return new \OC_EventSource();
1268
+    }
1269
+
1270
+    /**
1271
+     * Get the active event logger
1272
+     *
1273
+     * The returned logger only logs data when debug mode is enabled
1274
+     *
1275
+     * @return \OCP\Diagnostics\IEventLogger
1276
+     */
1277
+    public function getEventLogger() {
1278
+        return $this->query('EventLogger');
1279
+    }
1280
+
1281
+    /**
1282
+     * Get the active query logger
1283
+     *
1284
+     * The returned logger only logs data when debug mode is enabled
1285
+     *
1286
+     * @return \OCP\Diagnostics\IQueryLogger
1287
+     */
1288
+    public function getQueryLogger() {
1289
+        return $this->query('QueryLogger');
1290
+    }
1291
+
1292
+    /**
1293
+     * Get the manager for temporary files and folders
1294
+     *
1295
+     * @return \OCP\ITempManager
1296
+     */
1297
+    public function getTempManager() {
1298
+        return $this->query('TempManager');
1299
+    }
1300
+
1301
+    /**
1302
+     * Get the app manager
1303
+     *
1304
+     * @return \OCP\App\IAppManager
1305
+     */
1306
+    public function getAppManager() {
1307
+        return $this->query('AppManager');
1308
+    }
1309
+
1310
+    /**
1311
+     * Creates a new mailer
1312
+     *
1313
+     * @return \OCP\Mail\IMailer
1314
+     */
1315
+    public function getMailer() {
1316
+        return $this->query('Mailer');
1317
+    }
1318
+
1319
+    /**
1320
+     * Get the webroot
1321
+     *
1322
+     * @return string
1323
+     */
1324
+    public function getWebRoot() {
1325
+        return $this->webRoot;
1326
+    }
1327
+
1328
+    /**
1329
+     * @return \OC\OCSClient
1330
+     */
1331
+    public function getOcsClient() {
1332
+        return $this->query('OcsClient');
1333
+    }
1334
+
1335
+    /**
1336
+     * @return \OCP\IDateTimeZone
1337
+     */
1338
+    public function getDateTimeZone() {
1339
+        return $this->query('DateTimeZone');
1340
+    }
1341
+
1342
+    /**
1343
+     * @return \OCP\IDateTimeFormatter
1344
+     */
1345
+    public function getDateTimeFormatter() {
1346
+        return $this->query('DateTimeFormatter');
1347
+    }
1348
+
1349
+    /**
1350
+     * @return \OCP\Files\Config\IMountProviderCollection
1351
+     */
1352
+    public function getMountProviderCollection() {
1353
+        return $this->query('MountConfigManager');
1354
+    }
1355
+
1356
+    /**
1357
+     * Get the IniWrapper
1358
+     *
1359
+     * @return IniGetWrapper
1360
+     */
1361
+    public function getIniWrapper() {
1362
+        return $this->query('IniWrapper');
1363
+    }
1364
+
1365
+    /**
1366
+     * @return \OCP\Command\IBus
1367
+     */
1368
+    public function getCommandBus() {
1369
+        return $this->query('AsyncCommandBus');
1370
+    }
1371
+
1372
+    /**
1373
+     * Get the trusted domain helper
1374
+     *
1375
+     * @return TrustedDomainHelper
1376
+     */
1377
+    public function getTrustedDomainHelper() {
1378
+        return $this->query('TrustedDomainHelper');
1379
+    }
1380
+
1381
+    /**
1382
+     * Get the locking provider
1383
+     *
1384
+     * @return \OCP\Lock\ILockingProvider
1385
+     * @since 8.1.0
1386
+     */
1387
+    public function getLockingProvider() {
1388
+        return $this->query('LockingProvider');
1389
+    }
1390
+
1391
+    /**
1392
+     * @return \OCP\Files\Mount\IMountManager
1393
+     **/
1394
+    function getMountManager() {
1395
+        return $this->query('MountManager');
1396
+    }
1397
+
1398
+    /** @return \OCP\Files\Config\IUserMountCache */
1399
+    function getUserMountCache() {
1400
+        return $this->query('UserMountCache');
1401
+    }
1402
+
1403
+    /**
1404
+     * Get the MimeTypeDetector
1405
+     *
1406
+     * @return \OCP\Files\IMimeTypeDetector
1407
+     */
1408
+    public function getMimeTypeDetector() {
1409
+        return $this->query('MimeTypeDetector');
1410
+    }
1411
+
1412
+    /**
1413
+     * Get the MimeTypeLoader
1414
+     *
1415
+     * @return \OCP\Files\IMimeTypeLoader
1416
+     */
1417
+    public function getMimeTypeLoader() {
1418
+        return $this->query('MimeTypeLoader');
1419
+    }
1420
+
1421
+    /**
1422
+     * Get the manager of all the capabilities
1423
+     *
1424
+     * @return \OC\CapabilitiesManager
1425
+     */
1426
+    public function getCapabilitiesManager() {
1427
+        return $this->query('CapabilitiesManager');
1428
+    }
1429
+
1430
+    /**
1431
+     * Get the EventDispatcher
1432
+     *
1433
+     * @return EventDispatcherInterface
1434
+     * @since 8.2.0
1435
+     */
1436
+    public function getEventDispatcher() {
1437
+        return $this->query('EventDispatcher');
1438
+    }
1439
+
1440
+    /**
1441
+     * Get the Notification Manager
1442
+     *
1443
+     * @return \OCP\Notification\IManager
1444
+     * @since 8.2.0
1445
+     */
1446
+    public function getNotificationManager() {
1447
+        return $this->query('NotificationManager');
1448
+    }
1449
+
1450
+    /**
1451
+     * @return \OCP\Comments\ICommentsManager
1452
+     */
1453
+    public function getCommentsManager() {
1454
+        return $this->query('CommentsManager');
1455
+    }
1456
+
1457
+    /**
1458
+     * @return \OC_Defaults
1459
+     */
1460
+    public function getThemingDefaults() {
1461
+        return $this->query('ThemingDefaults');
1462
+    }
1463
+
1464
+    /**
1465
+     * @return \OC\IntegrityCheck\Checker
1466
+     */
1467
+    public function getIntegrityCodeChecker() {
1468
+        return $this->query('IntegrityCodeChecker');
1469
+    }
1470
+
1471
+    /**
1472
+     * @return \OC\Session\CryptoWrapper
1473
+     */
1474
+    public function getSessionCryptoWrapper() {
1475
+        return $this->query('CryptoWrapper');
1476
+    }
1477
+
1478
+    /**
1479
+     * @return CsrfTokenManager
1480
+     */
1481
+    public function getCsrfTokenManager() {
1482
+        return $this->query('CsrfTokenManager');
1483
+    }
1484
+
1485
+    /**
1486
+     * @return Throttler
1487
+     */
1488
+    public function getBruteForceThrottler() {
1489
+        return $this->query('Throttler');
1490
+    }
1491
+
1492
+    /**
1493
+     * @return IContentSecurityPolicyManager
1494
+     */
1495
+    public function getContentSecurityPolicyManager() {
1496
+        return $this->query('ContentSecurityPolicyManager');
1497
+    }
1498
+
1499
+    /**
1500
+     * @return ContentSecurityPolicyNonceManager
1501
+     */
1502
+    public function getContentSecurityPolicyNonceManager() {
1503
+        return $this->query('ContentSecurityPolicyNonceManager');
1504
+    }
1505
+
1506
+    /**
1507
+     * Not a public API as of 8.2, wait for 9.0
1508
+     *
1509
+     * @return \OCA\Files_External\Service\BackendService
1510
+     */
1511
+    public function getStoragesBackendService() {
1512
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1513
+    }
1514
+
1515
+    /**
1516
+     * Not a public API as of 8.2, wait for 9.0
1517
+     *
1518
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1519
+     */
1520
+    public function getGlobalStoragesService() {
1521
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1522
+    }
1523
+
1524
+    /**
1525
+     * Not a public API as of 8.2, wait for 9.0
1526
+     *
1527
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1528
+     */
1529
+    public function getUserGlobalStoragesService() {
1530
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1531
+    }
1532
+
1533
+    /**
1534
+     * Not a public API as of 8.2, wait for 9.0
1535
+     *
1536
+     * @return \OCA\Files_External\Service\UserStoragesService
1537
+     */
1538
+    public function getUserStoragesService() {
1539
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1540
+    }
1541
+
1542
+    /**
1543
+     * @return \OCP\Share\IManager
1544
+     */
1545
+    public function getShareManager() {
1546
+        return $this->query('ShareManager');
1547
+    }
1548
+
1549
+    /**
1550
+     * Returns the LDAP Provider
1551
+     *
1552
+     * @return \OCP\LDAP\ILDAPProvider
1553
+     */
1554
+    public function getLDAPProvider() {
1555
+        return $this->query('LDAPProvider');
1556
+    }
1557
+
1558
+    /**
1559
+     * @return \OCP\Settings\IManager
1560
+     */
1561
+    public function getSettingsManager() {
1562
+        return $this->query('SettingsManager');
1563
+    }
1564
+
1565
+    /**
1566
+     * @return \OCP\Files\IAppData
1567
+     */
1568
+    public function getAppDataDir($app) {
1569
+        /** @var \OC\Files\AppData\Factory $factory */
1570
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1571
+        return $factory->get($app);
1572
+    }
1573
+
1574
+    /**
1575
+     * @return \OCP\Lockdown\ILockdownManager
1576
+     */
1577
+    public function getLockdownManager() {
1578
+        return $this->query('LockdownManager');
1579
+    }
1580
+
1581
+    /**
1582
+     * @return \OCP\Federation\ICloudIdManager
1583
+     */
1584
+    public function getCloudIdManager() {
1585
+        return $this->query(ICloudIdManager::class);
1586
+    }
1587 1587
 }
Please login to merge, or discard this patch.