diff options
author | Kate <26026535+provokateurin@users.noreply.github.com> | 2024-08-27 12:48:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-27 12:48:50 +0200 |
commit | 829642c9e504813bad55e39be7527abe70e488cc (patch) | |
tree | 7a78314b2bd69252897dde47ca3087c74b4071d9 | |
parent | d2c372639c587dde931014884682a22bc7eccdf4 (diff) | |
parent | 12b44844e1dab74706fc9dee55f17d826e533a46 (diff) | |
download | nextcloud-server-829642c9e504813bad55e39be7527abe70e488cc.tar.gz nextcloud-server-829642c9e504813bad55e39be7527abe70e488cc.zip |
Merge pull request #47508 from nextcloud/fix/router/attribute-routes-all-apps
-rw-r--r-- | lib/private/Route/Router.php | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index b04b6a4d21c..646d1d4e6ed 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -111,9 +111,14 @@ class Router implements IRouter { if ($this->loaded) { return; } + $this->eventLogger->start('route:load:' . $requestedApp, 'Loading Routes for ' . $requestedApp); if (is_null($app)) { $this->loaded = true; $routingFiles = $this->getRoutingFiles(); + + foreach (\OC_App::getEnabledApps() as $enabledApp) { + $this->loadAttributeRoutes($enabledApp); + } } else { if (isset($this->loadedApps[$app])) { return; @@ -125,21 +130,9 @@ class Router implements IRouter { } else { $routingFiles = []; } - } - $this->eventLogger->start('route:load:' . $requestedApp, 'Loading Routes for ' . $requestedApp); - - if ($requestedApp !== null && in_array($requestedApp, \OC_App::getEnabledApps())) { - $routes = $this->getAttributeRoutes($requestedApp); - if (count($routes) > 0) { - $this->useCollection($requestedApp); - $this->setupRoutes($routes, $requestedApp); - $collection = $this->getCollection($requestedApp); - $this->root->addCollection($collection); - // Also add the OCS collection - $collection = $this->getCollection($requestedApp . '.ocs'); - $collection->addPrefix('/ocsapp'); - $this->root->addCollection($collection); + if ($this->appManager->isEnabledForUser($app)) { + $this->loadAttributeRoutes($app); } } @@ -413,6 +406,23 @@ class Router implements IRouter { return $routeName; } + private function loadAttributeRoutes(string $app): void { + $routes = $this->getAttributeRoutes($app); + if (count($routes) === 0) { + return; + } + + $this->useCollection($app); + $this->setupRoutes($routes, $app); + $collection = $this->getCollection($app); + $this->root->addCollection($collection); + + // Also add the OCS collection + $collection = $this->getCollection($app . '.ocs'); + $collection->addPrefix('/ocsapp'); + $this->root->addCollection($collection); + } + /** * @throws ReflectionException */ |