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