Skip to content

Commit

Permalink
Merge pull request #47508 from nextcloud/fix/router/attribute-routes-…
Browse files Browse the repository at this point in the history
…all-apps
  • Loading branch information
provokateurin authored Aug 27, 2024
2 parents d2c3726 + 12b4484 commit 829642c
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions lib/private/Route/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ public function loadRoutes($app = null) {
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;
Expand All @@ -125,21 +130,9 @@ public function loadRoutes($app = null) {
} 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);
}
}

Expand Down Expand Up @@ -413,6 +406,23 @@ protected function fixLegacyRootName(string $routeName): string {
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
*/
Expand Down

0 comments on commit 829642c

Please sign in to comment.