@@ -111,9 +111,14 @@ public function loadRoutes($app = null) {
111111 if ($ this ->loaded ) {
112112 return ;
113113 }
114+ $ this ->eventLogger ->start ('route:load: ' . $ requestedApp , 'Loading Routes for ' . $ requestedApp );
114115 if (is_null ($ app )) {
115116 $ this ->loaded = true ;
116117 $ routingFiles = $ this ->getRoutingFiles ();
118+
119+ foreach (\OC_App::getEnabledApps () as $ enabledApp ) {
120+ $ this ->loadAttributeRoutes ($ enabledApp );
121+ }
117122 } else {
118123 if (isset ($ this ->loadedApps [$ app ])) {
119124 return ;
@@ -125,21 +130,9 @@ public function loadRoutes($app = null) {
125130 } else {
126131 $ routingFiles = [];
127132 }
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 );
138133
139- // Also add the OCS collection
140- $ collection = $ this ->getCollection ($ requestedApp . '.ocs ' );
141- $ collection ->addPrefix ('/ocsapp ' );
142- $ this ->root ->addCollection ($ collection );
134+ if ($ this ->appManager ->isEnabledForUser ($ app )) {
135+ $ this ->loadAttributeRoutes ($ app );
143136 }
144137 }
145138
@@ -413,6 +406,23 @@ protected function fixLegacyRootName(string $routeName): string {
413406 return $ routeName ;
414407 }
415408
409+ private function loadAttributeRoutes (string $ app ): void {
410+ $ routes = $ this ->getAttributeRoutes ($ app );
411+ if (count ($ routes ) === 0 ) {
412+ return ;
413+ }
414+
415+ $ this ->useCollection ($ app );
416+ $ this ->setupRoutes ($ routes , $ app );
417+ $ collection = $ this ->getCollection ($ app );
418+ $ this ->root ->addCollection ($ collection );
419+
420+ // Also add the OCS collection
421+ $ collection = $ this ->getCollection ($ app . '.ocs ' );
422+ $ collection ->addPrefix ('/ocsapp ' );
423+ $ this ->root ->addCollection ($ collection );
424+ }
425+
416426 /**
417427 * @throws ReflectionException
418428 */
0 commit comments