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