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