diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-04 21:06:00 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-09 15:41:50 +0200 |
commit | c97b4274ccdc4fa841b164dedb608fdf351a0412 (patch) | |
tree | 562862bfafb4840ec2265712965bc1eb621a44f9 /lib/private/URLGenerator.php | |
parent | 877823eb9dc08f0675bb1183d35cbb1918348712 (diff) | |
download | nextcloud-server-c97b4274ccdc4fa841b164dedb608fdf351a0412.tar.gz nextcloud-server-c97b4274ccdc4fa841b164dedb608fdf351a0412.zip |
Add function to generate urls for OCS routes
fixes #11617
The OCS routes are only absolute for now as they are often exposed to
the outside anyway and are on a different endpoint than index.php in
anyway.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/URLGenerator.php')
-rw-r--r-- | lib/private/URLGenerator.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 6f4f869238c..f4a83138e4c 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -91,6 +91,19 @@ class URLGenerator implements IURLGenerator { return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments)); } + public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string { + $route = \OC::$server->getRouter()->generate('ocs.'.$routeName, $arguments, false); + + if (strpos($route, '/index.php') === 0) { + $route = substr($route, 10); + } + + $route = substr($route, 7); + $route = '/ocs/v2.php' . $route; + + return $this->getAbsoluteURL($route); + } + /** * Creates an url * @param string $app app |