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