diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-02-01 12:18:24 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-02-12 17:22:33 +0100 |
commit | 922cf44c81770a28c1e4791e9559a101d2263de9 (patch) | |
tree | 02fd1af450e2d40307de4b25788c079126a10596 /core/Controller/NavigationController.php | |
parent | 8ecac5654323e5d335386874f01b15d680d0febb (diff) | |
download | nextcloud-server-922cf44c81770a28c1e4791e9559a101d2263de9.tar.gz nextcloud-server-922cf44c81770a28c1e4791e9559a101d2263de9.zip |
Move to OCS endpoint
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core/Controller/NavigationController.php')
-rw-r--r-- | core/Controller/NavigationController.php | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php index 98744171198..92f103c3a34 100644 --- a/core/Controller/NavigationController.php +++ b/core/Controller/NavigationController.php @@ -22,13 +22,13 @@ */ namespace OC\Core\Controller; -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\OCSController; use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; -class NavigationController extends Controller { +class NavigationController extends OCSController { /** @var INavigationManager */ private $navigationManager; @@ -47,14 +47,14 @@ class NavigationController extends Controller { * @NoCSRFRequired * * @param bool $absolute - * @return JSONResponse + * @return DataResponse */ - public function getAppsNavigation(bool $absolute = false) { - $navigation = $this->navigationManager->getAll('link'); + public function getAppsNavigation(bool $absolute = false): DataResponse { + $navigation = $this->navigationManager->getAll(); if ($absolute) { - $this->rewriteToAbsoluteUrls($navigation); + $navigation = $this->rewriteToAbsoluteUrls($navigation); } - return new JSONResponse($navigation); + return new DataResponse($navigation); } /** @@ -62,26 +62,28 @@ class NavigationController extends Controller { * @NoCSRFRequired * * @param bool $absolute - * @return JSONResponse + * @return DataResponse */ - public function getSettingsNavigation(bool $absolute = false) { + public function getSettingsNavigation(bool $absolute = false): DataResponse { $navigation = $this->navigationManager->getAll('settings'); if ($absolute) { - $this->rewriteToAbsoluteUrls($navigation); + $navigation = $this->rewriteToAbsoluteUrls($navigation); } - return new JSONResponse($navigation); + return new DataResponse($navigation); } /** * Rewrite href attribute of navigation entries to an absolute URL * * @param array $navigation + * @return array */ - private function rewriteToAbsoluteUrls(array &$navigation) { + private function rewriteToAbsoluteUrls(array $navigation): array { foreach ($navigation as &$entry) { - if (substr($entry['href'], 0, strlen($this->urlGenerator->getBaseUrl())) !== $this->urlGenerator->getBaseUrl()) { + if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) { $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']); } } + return $navigation; } } |