diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-06-26 10:10:49 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-07-19 08:16:30 +0200 |
commit | 98a0113d4083d4dff73f8212106673ccc1c4b744 (patch) | |
tree | f19c53febc5cf59246ee6ca7087cdc1778469d67 /core/Controller | |
parent | 84e90e26c0a257c11ebdd05e01046e1a90e6c9bd (diff) | |
download | nextcloud-server-98a0113d4083d4dff73f8212106673ccc1c4b744.tar.gz nextcloud-server-98a0113d4083d4dff73f8212106673ccc1c4b744.zip |
Svg from app
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/Controller')
-rw-r--r-- | core/Controller/SvgController.php | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php index b2202f88a24..6fba2f050b3 100644 --- a/core/Controller/SvgController.php +++ b/core/Controller/SvgController.php @@ -59,8 +59,39 @@ class SvgController extends Controller { * @param string $color * @return DataDisplayResponse|NotFoundException */ - public function getSvg(string $fileName, $color = 'ffffff') { + public function getSvgFromCore(string $fileName, string $color = 'ffffff') { $path = $this->serverRoot . "/core/img/actions/$fileName.svg"; + return $this->getSvg($path, $color); + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * + * Generate svg from filename with the requested color + * + * @param string $fileName + * @param string $color + * @return DataDisplayResponse|NotFoundException + */ + public function getSvgFromApp(string $app, string $fileName, string $color = 'ffffff') { + $appPath = \OC_App::getAppWebPath($app); + if (!$appPath) { + return new NotFoundResponse(); + } + $path = $this->serverRoot . $appPath ."/img/$fileName.svg"; + return $this->getSvg($path, $color); + } + + + /** + * Generate svg from filename with the requested color + * + * @param string $path + * @param string $color + * @return DataDisplayResponse|NotFoundException + */ + private function getSvg(string $path, string $color) { if (!file_exists($path)) { return new NotFoundResponse(); } |