Passed
Push — master ( 6d2471...46e04a )
by John
11:00 queued 10s
created
apps/theming/lib/Controller/ThemingController.php 2 patches
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -65,337 +65,337 @@
 block discarded – undo
65 65
  * @package OCA\Theming\Controller
66 66
  */
67 67
 class ThemingController extends Controller {
68
-	/** @var ThemingDefaults */
69
-	private $themingDefaults;
70
-	/** @var IL10N */
71
-	private $l10n;
72
-	/** @var IConfig */
73
-	private $config;
74
-	/** @var ITempManager */
75
-	private $tempManager;
76
-	/** @var IAppData */
77
-	private $appData;
78
-	/** @var SCSSCacher */
79
-	private $scssCacher;
80
-	/** @var IURLGenerator */
81
-	private $urlGenerator;
82
-	/** @var IAppManager */
83
-	private $appManager;
84
-	/** @var ImageManager */
85
-	private $imageManager;
68
+    /** @var ThemingDefaults */
69
+    private $themingDefaults;
70
+    /** @var IL10N */
71
+    private $l10n;
72
+    /** @var IConfig */
73
+    private $config;
74
+    /** @var ITempManager */
75
+    private $tempManager;
76
+    /** @var IAppData */
77
+    private $appData;
78
+    /** @var SCSSCacher */
79
+    private $scssCacher;
80
+    /** @var IURLGenerator */
81
+    private $urlGenerator;
82
+    /** @var IAppManager */
83
+    private $appManager;
84
+    /** @var ImageManager */
85
+    private $imageManager;
86 86
 
87
-	/**
88
-	 * ThemingController constructor.
89
-	 *
90
-	 * @param string $appName
91
-	 * @param IRequest $request
92
-	 * @param IConfig $config
93
-	 * @param ThemingDefaults $themingDefaults
94
-	 * @param IL10N $l
95
-	 * @param ITempManager $tempManager
96
-	 * @param IAppData $appData
97
-	 * @param SCSSCacher $scssCacher
98
-	 * @param IURLGenerator $urlGenerator
99
-	 * @param IAppManager $appManager
100
-	 * @param ImageManager $imageManager
101
-	 */
102
-	public function __construct(
103
-		$appName,
104
-		IRequest $request,
105
-		IConfig $config,
106
-		ThemingDefaults $themingDefaults,
107
-		IL10N $l,
108
-		ITempManager $tempManager,
109
-		IAppData $appData,
110
-		SCSSCacher $scssCacher,
111
-		IURLGenerator $urlGenerator,
112
-		IAppManager $appManager,
113
-		ImageManager $imageManager
114
-	) {
115
-		parent::__construct($appName, $request);
87
+    /**
88
+     * ThemingController constructor.
89
+     *
90
+     * @param string $appName
91
+     * @param IRequest $request
92
+     * @param IConfig $config
93
+     * @param ThemingDefaults $themingDefaults
94
+     * @param IL10N $l
95
+     * @param ITempManager $tempManager
96
+     * @param IAppData $appData
97
+     * @param SCSSCacher $scssCacher
98
+     * @param IURLGenerator $urlGenerator
99
+     * @param IAppManager $appManager
100
+     * @param ImageManager $imageManager
101
+     */
102
+    public function __construct(
103
+        $appName,
104
+        IRequest $request,
105
+        IConfig $config,
106
+        ThemingDefaults $themingDefaults,
107
+        IL10N $l,
108
+        ITempManager $tempManager,
109
+        IAppData $appData,
110
+        SCSSCacher $scssCacher,
111
+        IURLGenerator $urlGenerator,
112
+        IAppManager $appManager,
113
+        ImageManager $imageManager
114
+    ) {
115
+        parent::__construct($appName, $request);
116 116
 
117
-		$this->themingDefaults = $themingDefaults;
118
-		$this->l10n = $l;
119
-		$this->config = $config;
120
-		$this->tempManager = $tempManager;
121
-		$this->appData = $appData;
122
-		$this->scssCacher = $scssCacher;
123
-		$this->urlGenerator = $urlGenerator;
124
-		$this->appManager = $appManager;
125
-		$this->imageManager = $imageManager;
126
-	}
117
+        $this->themingDefaults = $themingDefaults;
118
+        $this->l10n = $l;
119
+        $this->config = $config;
120
+        $this->tempManager = $tempManager;
121
+        $this->appData = $appData;
122
+        $this->scssCacher = $scssCacher;
123
+        $this->urlGenerator = $urlGenerator;
124
+        $this->appManager = $appManager;
125
+        $this->imageManager = $imageManager;
126
+    }
127 127
 
128
-	/**
129
-	 * @param string $setting
130
-	 * @param string $value
131
-	 * @return DataResponse
132
-	 * @throws NotPermittedException
133
-	 */
134
-	public function updateStylesheet($setting, $value) {
135
-		$value = trim($value);
136
-		$error = null;
137
-		switch ($setting) {
138
-			case 'name':
139
-				if (strlen($value) > 250) {
140
-					$error = $this->l10n->t('The given name is too long');
141
-				}
142
-				break;
143
-			case 'url':
144
-				if (strlen($value) > 500) {
145
-					$error = $this->l10n->t('The given web address is too long');
146
-				}
147
-				if (!$this->isValidUrl($value)) {
148
-					$error = $this->l10n->t('The given web address is not a valid URL');
149
-				}
150
-				break;
151
-			case 'imprintUrl':
152
-				if (strlen($value) > 500) {
153
-					$error = $this->l10n->t('The given legal notice address is too long');
154
-				}
155
-				if (!$this->isValidUrl($value)) {
156
-					$error = $this->l10n->t('The given legal notice address is not a valid URL');
157
-				}
158
-				break;
159
-			case 'privacyUrl':
160
-				if (strlen($value) > 500) {
161
-					$error = $this->l10n->t('The given privacy policy address is too long');
162
-				}
163
-				if (!$this->isValidUrl($value)) {
164
-					$error = $this->l10n->t('The given privacy policy address is not a valid URL');
165
-				}
166
-				break;
167
-			case 'slogan':
168
-				if (strlen($value) > 500) {
169
-					$error = $this->l10n->t('The given slogan is too long');
170
-				}
171
-				break;
172
-			case 'color':
173
-				if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
174
-					$error = $this->l10n->t('The given color is invalid');
175
-				}
176
-				break;
177
-		}
178
-		if ($error !== null) {
179
-			return new DataResponse([
180
-				'data' => [
181
-					'message' => $error,
182
-				],
183
-				'status' => 'error'
184
-			], Http::STATUS_BAD_REQUEST);
185
-		}
128
+    /**
129
+     * @param string $setting
130
+     * @param string $value
131
+     * @return DataResponse
132
+     * @throws NotPermittedException
133
+     */
134
+    public function updateStylesheet($setting, $value) {
135
+        $value = trim($value);
136
+        $error = null;
137
+        switch ($setting) {
138
+            case 'name':
139
+                if (strlen($value) > 250) {
140
+                    $error = $this->l10n->t('The given name is too long');
141
+                }
142
+                break;
143
+            case 'url':
144
+                if (strlen($value) > 500) {
145
+                    $error = $this->l10n->t('The given web address is too long');
146
+                }
147
+                if (!$this->isValidUrl($value)) {
148
+                    $error = $this->l10n->t('The given web address is not a valid URL');
149
+                }
150
+                break;
151
+            case 'imprintUrl':
152
+                if (strlen($value) > 500) {
153
+                    $error = $this->l10n->t('The given legal notice address is too long');
154
+                }
155
+                if (!$this->isValidUrl($value)) {
156
+                    $error = $this->l10n->t('The given legal notice address is not a valid URL');
157
+                }
158
+                break;
159
+            case 'privacyUrl':
160
+                if (strlen($value) > 500) {
161
+                    $error = $this->l10n->t('The given privacy policy address is too long');
162
+                }
163
+                if (!$this->isValidUrl($value)) {
164
+                    $error = $this->l10n->t('The given privacy policy address is not a valid URL');
165
+                }
166
+                break;
167
+            case 'slogan':
168
+                if (strlen($value) > 500) {
169
+                    $error = $this->l10n->t('The given slogan is too long');
170
+                }
171
+                break;
172
+            case 'color':
173
+                if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
174
+                    $error = $this->l10n->t('The given color is invalid');
175
+                }
176
+                break;
177
+        }
178
+        if ($error !== null) {
179
+            return new DataResponse([
180
+                'data' => [
181
+                    'message' => $error,
182
+                ],
183
+                'status' => 'error'
184
+            ], Http::STATUS_BAD_REQUEST);
185
+        }
186 186
 
187
-		$this->themingDefaults->set($setting, $value);
187
+        $this->themingDefaults->set($setting, $value);
188 188
 
189
-		// reprocess server scss for preview
190
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
189
+        // reprocess server scss for preview
190
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
191 191
 
192
-		return new DataResponse(
193
-			[
194
-				'data' =>
195
-					[
196
-						'message' => $this->l10n->t('Saved'),
197
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/css-variables.scss'))
198
-					],
199
-				'status' => 'success'
200
-			]
201
-		);
202
-	}
192
+        return new DataResponse(
193
+            [
194
+                'data' =>
195
+                    [
196
+                        'message' => $this->l10n->t('Saved'),
197
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/css-variables.scss'))
198
+                    ],
199
+                'status' => 'success'
200
+            ]
201
+        );
202
+    }
203 203
 
204
-	/**
205
-	 * Check that a string is a valid http/https url
206
-	 */
207
-	private function isValidUrl(string $url): bool {
208
-		return ((strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0) &&
209
-			filter_var($url, FILTER_VALIDATE_URL) !== false);
210
-	}
204
+    /**
205
+     * Check that a string is a valid http/https url
206
+     */
207
+    private function isValidUrl(string $url): bool {
208
+        return ((strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0) &&
209
+            filter_var($url, FILTER_VALIDATE_URL) !== false);
210
+    }
211 211
 
212
-	/**
213
-	 * @return DataResponse
214
-	 * @throws NotPermittedException
215
-	 */
216
-	public function uploadImage(): DataResponse {
217
-		$key = $this->request->getParam('key');
218
-		$image = $this->request->getUploadedFile('image');
219
-		$error = null;
220
-		$phpFileUploadErrors = [
221
-			UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'),
222
-			UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
223
-			UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
224
-			UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'),
225
-			UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
226
-			UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
227
-			UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'),
228
-			UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'),
229
-		];
230
-		if (empty($image)) {
231
-			$error = $this->l10n->t('No file uploaded');
232
-		}
233
-		if (!empty($image) && array_key_exists('error', $image) && $image['error'] !== UPLOAD_ERR_OK) {
234
-			$error = $phpFileUploadErrors[$image['error']];
235
-		}
212
+    /**
213
+     * @return DataResponse
214
+     * @throws NotPermittedException
215
+     */
216
+    public function uploadImage(): DataResponse {
217
+        $key = $this->request->getParam('key');
218
+        $image = $this->request->getUploadedFile('image');
219
+        $error = null;
220
+        $phpFileUploadErrors = [
221
+            UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'),
222
+            UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
223
+            UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
224
+            UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'),
225
+            UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
226
+            UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
227
+            UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'),
228
+            UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'),
229
+        ];
230
+        if (empty($image)) {
231
+            $error = $this->l10n->t('No file uploaded');
232
+        }
233
+        if (!empty($image) && array_key_exists('error', $image) && $image['error'] !== UPLOAD_ERR_OK) {
234
+            $error = $phpFileUploadErrors[$image['error']];
235
+        }
236 236
 
237
-		if ($error !== null) {
238
-			return new DataResponse(
239
-				[
240
-					'data' => [
241
-						'message' => $error
242
-					],
243
-					'status' => 'failure',
244
-				],
245
-				Http::STATUS_UNPROCESSABLE_ENTITY
246
-			);
247
-		}
237
+        if ($error !== null) {
238
+            return new DataResponse(
239
+                [
240
+                    'data' => [
241
+                        'message' => $error
242
+                    ],
243
+                    'status' => 'failure',
244
+                ],
245
+                Http::STATUS_UNPROCESSABLE_ENTITY
246
+            );
247
+        }
248 248
 
249
-		try {
250
-			$mime = $this->imageManager->updateImage($key, $image['tmp_name']);
251
-			$this->themingDefaults->set($key . 'Mime', $mime);
252
-		} catch (\Exception $e) {
253
-			return new DataResponse(
254
-				[
255
-					'data' => [
256
-						'message' => $e->getMessage()
257
-					],
258
-					'status' => 'failure',
259
-				],
260
-				Http::STATUS_UNPROCESSABLE_ENTITY
261
-			);
262
-		}
249
+        try {
250
+            $mime = $this->imageManager->updateImage($key, $image['tmp_name']);
251
+            $this->themingDefaults->set($key . 'Mime', $mime);
252
+        } catch (\Exception $e) {
253
+            return new DataResponse(
254
+                [
255
+                    'data' => [
256
+                        'message' => $e->getMessage()
257
+                    ],
258
+                    'status' => 'failure',
259
+                ],
260
+                Http::STATUS_UNPROCESSABLE_ENTITY
261
+            );
262
+        }
263 263
 
264
-		$name = $image['name'];
265
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
264
+        $name = $image['name'];
265
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
266 266
 
267
-		return new DataResponse(
268
-			[
269
-				'data' =>
270
-					[
271
-						'name' => $name,
272
-						'url' => $this->imageManager->getImageUrl($key),
273
-						'message' => $this->l10n->t('Saved'),
274
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/css-variables.scss'))
275
-					],
276
-				'status' => 'success'
277
-			]
278
-		);
279
-	}
267
+        return new DataResponse(
268
+            [
269
+                'data' =>
270
+                    [
271
+                        'name' => $name,
272
+                        'url' => $this->imageManager->getImageUrl($key),
273
+                        'message' => $this->l10n->t('Saved'),
274
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/css-variables.scss'))
275
+                    ],
276
+                'status' => 'success'
277
+            ]
278
+        );
279
+    }
280 280
 
281
-	/**
282
-	 * Revert setting to default value
283
-	 *
284
-	 * @param string $setting setting which should be reverted
285
-	 * @return DataResponse
286
-	 * @throws NotPermittedException
287
-	 */
288
-	public function undo(string $setting): DataResponse {
289
-		$value = $this->themingDefaults->undo($setting);
290
-		// reprocess server scss for preview
291
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
281
+    /**
282
+     * Revert setting to default value
283
+     *
284
+     * @param string $setting setting which should be reverted
285
+     * @return DataResponse
286
+     * @throws NotPermittedException
287
+     */
288
+    public function undo(string $setting): DataResponse {
289
+        $value = $this->themingDefaults->undo($setting);
290
+        // reprocess server scss for preview
291
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
292 292
 
293
-		return new DataResponse(
294
-			[
295
-				'data' =>
296
-					[
297
-						'value' => $value,
298
-						'message' => $this->l10n->t('Saved'),
299
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/css-variables.scss'))
300
-					],
301
-				'status' => 'success'
302
-			]
303
-		);
304
-	}
293
+        return new DataResponse(
294
+            [
295
+                'data' =>
296
+                    [
297
+                        'value' => $value,
298
+                        'message' => $this->l10n->t('Saved'),
299
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/css-variables.scss'))
300
+                    ],
301
+                'status' => 'success'
302
+            ]
303
+        );
304
+    }
305 305
 
306
-	/**
307
-	 * @PublicPage
308
-	 * @NoCSRFRequired
309
-	 *
310
-	 * @param string $key
311
-	 * @param bool $useSvg
312
-	 * @return FileDisplayResponse|NotFoundResponse
313
-	 * @throws NotPermittedException
314
-	 */
315
-	public function getImage(string $key, bool $useSvg = true) {
316
-		try {
317
-			$file = $this->imageManager->getImage($key, $useSvg);
318
-		} catch (NotFoundException $e) {
319
-			return new NotFoundResponse();
320
-		}
306
+    /**
307
+     * @PublicPage
308
+     * @NoCSRFRequired
309
+     *
310
+     * @param string $key
311
+     * @param bool $useSvg
312
+     * @return FileDisplayResponse|NotFoundResponse
313
+     * @throws NotPermittedException
314
+     */
315
+    public function getImage(string $key, bool $useSvg = true) {
316
+        try {
317
+            $file = $this->imageManager->getImage($key, $useSvg);
318
+        } catch (NotFoundException $e) {
319
+            return new NotFoundResponse();
320
+        }
321 321
 
322
-		$response = new FileDisplayResponse($file);
323
-		$csp = new Http\ContentSecurityPolicy();
324
-		$csp->allowInlineStyle();
325
-		$response->setContentSecurityPolicy($csp);
326
-		$response->cacheFor(3600);
327
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
328
-		$response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
329
-		if (!$useSvg) {
330
-			$response->addHeader('Content-Type', 'image/png');
331
-		} else {
332
-			$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
333
-		}
334
-		return $response;
335
-	}
322
+        $response = new FileDisplayResponse($file);
323
+        $csp = new Http\ContentSecurityPolicy();
324
+        $csp->allowInlineStyle();
325
+        $response->setContentSecurityPolicy($csp);
326
+        $response->cacheFor(3600);
327
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
328
+        $response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
329
+        if (!$useSvg) {
330
+            $response->addHeader('Content-Type', 'image/png');
331
+        } else {
332
+            $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
333
+        }
334
+        return $response;
335
+    }
336 336
 
337
-	/**
338
-	 * @NoCSRFRequired
339
-	 * @PublicPage
340
-	 * @NoSameSiteCookieRequired
341
-	 *
342
-	 * @return FileDisplayResponse|NotFoundResponse
343
-	 * @throws NotPermittedException
344
-	 * @throws \Exception
345
-	 * @throws \OCP\App\AppPathNotFoundException
346
-	 */
347
-	public function getStylesheet() {
348
-		$appPath = $this->appManager->getAppPath('theming');
337
+    /**
338
+     * @NoCSRFRequired
339
+     * @PublicPage
340
+     * @NoSameSiteCookieRequired
341
+     *
342
+     * @return FileDisplayResponse|NotFoundResponse
343
+     * @throws NotPermittedException
344
+     * @throws \Exception
345
+     * @throws \OCP\App\AppPathNotFoundException
346
+     */
347
+    public function getStylesheet() {
348
+        $appPath = $this->appManager->getAppPath('theming');
349 349
 
350
-		/* SCSSCacher is required here
350
+        /* SCSSCacher is required here
351 351
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
352 352
 		 * since we need to add the cacheBuster value to the url
353 353
 		 */
354
-		$cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming');
355
-		if (!$cssCached) {
356
-			return new NotFoundResponse();
357
-		}
354
+        $cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming');
355
+        if (!$cssCached) {
356
+            return new NotFoundResponse();
357
+        }
358 358
 
359
-		try {
360
-			$cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
361
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
362
-			$response->cacheFor(86400);
363
-			return $response;
364
-		} catch (NotFoundException $e) {
365
-			return new NotFoundResponse();
366
-		}
367
-	}
359
+        try {
360
+            $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
361
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
362
+            $response->cacheFor(86400);
363
+            return $response;
364
+        } catch (NotFoundException $e) {
365
+            return new NotFoundResponse();
366
+        }
367
+    }
368 368
 
369
-	/**
370
-	 * @NoCSRFRequired
371
-	 * @PublicPage
372
-	 *
373
-	 * @return Http\JSONResponse
374
-	 */
375
-	public function getManifest($app) {
376
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
377
-		$responseJS = [
378
-			'name' => $this->themingDefaults->getName(),
379
-			'start_url' => $this->urlGenerator->getBaseUrl(),
380
-			'icons' =>
381
-				[
382
-					[
383
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
384
-								['app' => $app]) . '?v=' . $cacheBusterValue,
385
-						'type' => 'image/png',
386
-						'sizes' => '512x512'
387
-					],
388
-					[
389
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
390
-								['app' => $app]) . '?v=' . $cacheBusterValue,
391
-						'type' => 'image/svg+xml',
392
-						'sizes' => '16x16'
393
-					]
394
-				],
395
-			'display' => 'standalone'
396
-		];
397
-		$response = new Http\JSONResponse($responseJS);
398
-		$response->cacheFor(3600);
399
-		return $response;
400
-	}
369
+    /**
370
+     * @NoCSRFRequired
371
+     * @PublicPage
372
+     *
373
+     * @return Http\JSONResponse
374
+     */
375
+    public function getManifest($app) {
376
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
377
+        $responseJS = [
378
+            'name' => $this->themingDefaults->getName(),
379
+            'start_url' => $this->urlGenerator->getBaseUrl(),
380
+            'icons' =>
381
+                [
382
+                    [
383
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
384
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
385
+                        'type' => 'image/png',
386
+                        'sizes' => '512x512'
387
+                    ],
388
+                    [
389
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
390
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
391
+                        'type' => 'image/svg+xml',
392
+                        'sizes' => '16x16'
393
+                    ]
394
+                ],
395
+            'display' => 'standalone'
396
+        ];
397
+        $response = new Http\JSONResponse($responseJS);
398
+        $response->cacheFor(3600);
399
+        return $response;
400
+    }
401 401
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 		try {
250 250
 			$mime = $this->imageManager->updateImage($key, $image['tmp_name']);
251
-			$this->themingDefaults->set($key . 'Mime', $mime);
251
+			$this->themingDefaults->set($key.'Mime', $mime);
252 252
 		} catch (\Exception $e) {
253 253
 			return new DataResponse(
254 254
 				[
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 		$csp->allowInlineStyle();
325 325
 		$response->setContentSecurityPolicy($csp);
326 326
 		$response->cacheFor(3600);
327
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
328
-		$response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
327
+		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key.'Mime', ''));
328
+		$response->addHeader('Content-Disposition', 'attachment; filename="'.$key.'"');
329 329
 		if (!$useSvg) {
330 330
 			$response->addHeader('Content-Type', 'image/png');
331 331
 		} else {
332
-			$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
332
+			$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key.'Mime', ''));
333 333
 		}
334 334
 		return $response;
335 335
 	}
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
 				[
382 382
 					[
383 383
 						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
384
-								['app' => $app]) . '?v=' . $cacheBusterValue,
384
+								['app' => $app]).'?v='.$cacheBusterValue,
385 385
 						'type' => 'image/png',
386 386
 						'sizes' => '512x512'
387 387
 					],
388 388
 					[
389 389
 						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
390
-								['app' => $app]) . '?v=' . $cacheBusterValue,
390
+								['app' => $app]).'?v='.$cacheBusterValue,
391 391
 						'type' => 'image/svg+xml',
392 392
 						'sizes' => '16x16'
393 393
 					]
Please login to merge, or discard this patch.