Skip to content

Commit 42e604e

Browse files
committed
fix(Router): Load attribute routes of all apps when not app is specified
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent b8ab7b7 commit 42e604e

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

lib/private/Route/Router.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ public function loadRoutes($app = null) {
114114
if (is_null($app)) {
115115
$this->loaded = true;
116116
$routingFiles = $this->getRoutingFiles();
117+
118+
foreach (\OC_App::getEnabledApps() as $enabledApp) {
119+
$this->loadAttributeRoutes($enabledApp);
120+
}
117121
} else {
118122
if (isset($this->loadedApps[$app])) {
119123
return;
@@ -125,23 +129,10 @@ public function loadRoutes($app = null) {
125129
} else {
126130
$routingFiles = [];
127131
}
128-
}
129-
$this->eventLogger->start('route:load:' . $requestedApp, 'Loading Routes for ' . $requestedApp);
130-
131-
if ($requestedApp !== null && in_array($requestedApp, \OC_App::getEnabledApps())) {
132-
$routes = $this->getAttributeRoutes($requestedApp);
133-
if (count($routes) > 0) {
134-
$this->useCollection($requestedApp);
135-
$this->setupRoutes($routes, $requestedApp);
136-
$collection = $this->getCollection($requestedApp);
137-
$this->root->addCollection($collection);
138132

139-
// Also add the OCS collection
140-
$collection = $this->getCollection($requestedApp . '.ocs');
141-
$collection->addPrefix('/ocsapp');
142-
$this->root->addCollection($collection);
143-
}
133+
$this->loadAttributeRoutes($app);
144134
}
135+
$this->eventLogger->start('route:load:' . $requestedApp, 'Loading Routes for ' . $requestedApp);
145136

146137
foreach ($routingFiles as $app => $file) {
147138
if (!isset($this->loadedApps[$app])) {
@@ -413,6 +404,27 @@ protected function fixLegacyRootName(string $routeName): string {
413404
return $routeName;
414405
}
415406

407+
private function loadAttributeRoutes(string $app): void {
408+
if (!in_array($app, \OC_App::getEnabledApps())) {
409+
return;
410+
}
411+
412+
$routes = $this->getAttributeRoutes($app);
413+
if (count($routes) === 0) {
414+
return;
415+
}
416+
417+
$this->useCollection($app);
418+
$this->setupRoutes($routes, $app);
419+
$collection = $this->getCollection($app);
420+
$this->root->addCollection($collection);
421+
422+
// Also add the OCS collection
423+
$collection = $this->getCollection($app . '.ocs');
424+
$collection->addPrefix('/ocsapp');
425+
$this->root->addCollection($collection);
426+
}
427+
416428
/**
417429
* @throws ReflectionException
418430
*/

0 commit comments

Comments
 (0)