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