diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-01-21 12:02:30 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-08-19 21:58:20 +0200 |
commit | 053ee7b3860c352004bede82d040b4bd34ecb072 (patch) | |
tree | ac54cc9c4626f7fda2fb1363b1f3c2b203bd6b2c /lib | |
parent | d3a53d6f3911bcb68cebbe661bc87a9cde594a8d (diff) | |
download | nextcloud-server-053ee7b3860c352004bede82d040b4bd34ecb072.tar.gz nextcloud-server-053ee7b3860c352004bede82d040b4bd34ecb072.zip |
Only load routes of the app which is requested
* Add fallback to load all routes if needed
* Move partial loaded routes test to proper place
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Route/Router.php | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index 6de581ffa96..ec91e08472c 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -346,13 +346,27 @@ class Router implements IRouter { public function generate($name, $parameters = [], $absolute = false) { + $referenceType = UrlGenerator::ABSOLUTE_URL; + if ($absolute === false) { + $referenceType = UrlGenerator::ABSOLUTE_PATH; + } + $name = $this->fixLegacyRootName($name); + if (strpos($name, '.') !== false) { + list($appName, $other) = explode('.', $name, 3); + // OCS routes are prefixed with "ocs." + if ($appName === 'ocs') { + $appName = $other; + } + $this->loadRoutes($appName); + try { + return $this->getGenerator()->generate($name, $parameters, $referenceType); + } catch (RouteNotFoundException $e) { + } + } + + // Fallback load all routes $this->loadRoutes(); try { - $referenceType = UrlGenerator::ABSOLUTE_URL; - if ($absolute === false) { - $referenceType = UrlGenerator::ABSOLUTE_PATH; - } - $name = $this->fixLegacyRootName($name); return $this->getGenerator()->generate($name, $parameters, $referenceType); } catch (RouteNotFoundException $e) { $this->logger->logException($e, ['level' => ILogger::INFO]); |